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

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值