加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

FLEX学习笔记:画图工具——Graphics使用

发布时间:2020-12-15 01:21:02 所属栏目:百科 来源:网络整理
导读:Graphics 类包含一组可用来创建矢量形状的方法。支持绘制的显示对象包括 Sprite 和 Shape 对象。 这些类中的每一个类都包括? graphics ?属性 ,该属性是一个 Graphics 对象。以下是为便于使用而提供的一些辅助函数: drawRect() 、 drawRoundRect() 、 drawC
Graphics 类包含一组可用来创建矢量形状的方法。支持绘制的显示对象包括 Sprite 和 Shape 对象。这些类中的每一个类都包括?graphics?属性,该属性是一个 Graphics 对象。以下是为便于使用而提供的一些辅助函数:drawRect()drawRoundRect()drawCircle()?和?drawEllipse()

无法通过 ActionScript 代码直接创建 Graphics 对象。如果调用?new Graphics(),则会引发异常。

? ?
clear(): void
清除绘制到此 Graphics 对象的图形,并重置填充和线条样式设置。

例子:
this.graphics.clear();

//填充背景
this.graphics.beginFill(0xFFFFFF);
this.graphics.drawRect(0,this.width,this.height);
this.graphics.endFill();

this.graphics.lineStyle(1,0xBBBBBB);

//画横线
this.graphics.moveTo(0,grapWidth * i);
this.graphics.lineTo(this.width,grapWidth * i);
this.graphics.drawCircle(endX,endY,radio);


beginFill(color: uint,alpha: Number?= 1.0): 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其它 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。
drawCircle(x: Number,y: Number): 绘制一个圆。
drawRect(x: 绘制一个矩形。
endFill(): 对从上一次调用 beginFill()、beginGradientFill() 或 beginBitmapFill() 方法之后添加的直线和曲线应用填充。
lineStyle(thickness: Number?= NaN,color: uint?= 0,204); text-decoration:none" rel="nofollow" target="_blank">Number?= 1.0,pixelHinting: Boolean?= false,scaleMode: String?= "normal",caps: String?= null,joints: Number?= 3): 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。
moveTo(x: 将当前绘画位置移动到 (x,y)。
lineTo(x: 使用当前线条样式绘制一条从当前绘画位置开始到 (x,y) 结束的直线;当前绘画位置随后会设置为 (x,y)。
API地址: http://help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/flash/display/Graphics.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
    站长推荐
    热点阅读