avm2: Lazily create commands and data in GraphicsPath
This commit is contained in:
parent
de8958c40b
commit
96bb0b8e2e
|
@ -6,38 +6,62 @@ package flash.display {
|
||||||
public var winding : String;
|
public var winding : String;
|
||||||
|
|
||||||
public function GraphicsPath(commands:Vector.<int> = null, data:Vector.<Number> = null, winding:String = "evenOdd") {
|
public function GraphicsPath(commands:Vector.<int> = null, data:Vector.<Number> = null, winding:String = "evenOdd") {
|
||||||
if (commands == null) {
|
|
||||||
commands = new Vector.<int>();
|
|
||||||
}
|
|
||||||
if (data == null) {
|
|
||||||
data = new Vector.<Number>();
|
|
||||||
}
|
|
||||||
this.commands = commands;
|
this.commands = commands;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.winding = winding;
|
this.winding = winding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cubicCurveTo(controlX1:Number, controlY1:Number, controlX2:Number, controlY2:Number, anchorX:Number, anchorY:Number):void {
|
public function cubicCurveTo(controlX1:Number, controlY1:Number, controlX2:Number, controlY2:Number, anchorX:Number, anchorY:Number):void {
|
||||||
|
if (commands == null) {
|
||||||
|
commands = new Vector.<int>();
|
||||||
|
}
|
||||||
|
if (data == null) {
|
||||||
|
data = new Vector.<Number>();
|
||||||
|
}
|
||||||
commands.push(GraphicsPathCommand.CUBIC_CURVE_TO);
|
commands.push(GraphicsPathCommand.CUBIC_CURVE_TO);
|
||||||
data.push(controlX1, controlY1, controlX2, controlY2, anchorX, anchorY);
|
data.push(controlX1, controlY1, controlX2, controlY2, anchorX, anchorY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function curveTo(controlX:Number, controlY:Number, anchorX:Number, anchorY:Number):void {
|
public function curveTo(controlX:Number, controlY:Number, anchorX:Number, anchorY:Number):void {
|
||||||
|
if (commands == null) {
|
||||||
|
commands = new Vector.<int>();
|
||||||
|
}
|
||||||
|
if (data == null) {
|
||||||
|
data = new Vector.<Number>();
|
||||||
|
}
|
||||||
commands.push(GraphicsPathCommand.CURVE_TO);
|
commands.push(GraphicsPathCommand.CURVE_TO);
|
||||||
data.push(controlX, controlY, anchorX, anchorY);
|
data.push(controlX, controlY, anchorX, anchorY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function lineTo(x:Number, y:Number):void {
|
public function lineTo(x:Number, y:Number):void {
|
||||||
|
if (commands == null) {
|
||||||
|
commands = new Vector.<int>();
|
||||||
|
}
|
||||||
|
if (data == null) {
|
||||||
|
data = new Vector.<Number>();
|
||||||
|
}
|
||||||
commands.push(GraphicsPathCommand.LINE_TO);
|
commands.push(GraphicsPathCommand.LINE_TO);
|
||||||
data.push(x, y);
|
data.push(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function moveTo(x:Number, y:Number):void {
|
public function moveTo(x:Number, y:Number):void {
|
||||||
|
if (commands == null) {
|
||||||
|
commands = new Vector.<int>();
|
||||||
|
}
|
||||||
|
if (data == null) {
|
||||||
|
data = new Vector.<Number>();
|
||||||
|
}
|
||||||
commands.push(GraphicsPathCommand.MOVE_TO);
|
commands.push(GraphicsPathCommand.MOVE_TO);
|
||||||
data.push(x, y);
|
data.push(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function wideLineTo(x:Number, y:Number):void {
|
public function wideLineTo(x:Number, y:Number):void {
|
||||||
|
if (commands == null) {
|
||||||
|
commands = new Vector.<int>();
|
||||||
|
}
|
||||||
|
if (data == null) {
|
||||||
|
data = new Vector.<Number>();
|
||||||
|
}
|
||||||
// "Wide" variant seems to literally just exist to use the same amount of data values as curveTo
|
// "Wide" variant seems to literally just exist to use the same amount of data values as curveTo
|
||||||
// The first two values are arbitrary. When consuming, they are ignored.
|
// The first two values are arbitrary. When consuming, they are ignored.
|
||||||
// https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/GraphicsPathCommand.html#WIDE_LINE_TO
|
// https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/GraphicsPathCommand.html#WIDE_LINE_TO
|
||||||
|
@ -46,6 +70,12 @@ package flash.display {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function wideMoveTo(x:Number, y:Number):void {
|
public function wideMoveTo(x:Number, y:Number):void {
|
||||||
|
if (commands == null) {
|
||||||
|
commands = new Vector.<int>();
|
||||||
|
}
|
||||||
|
if (data == null) {
|
||||||
|
data = new Vector.<Number>();
|
||||||
|
}
|
||||||
// "Wide" variant seems to literally just exist to use the same amount of data values as curveTo
|
// "Wide" variant seems to literally just exist to use the same amount of data values as curveTo
|
||||||
// The first two values are arbitrary. When consuming, they are ignored.
|
// The first two values are arbitrary. When consuming, they are ignored.
|
||||||
// https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/GraphicsPathCommand.html#WIDE_MOVE_TO
|
// https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/GraphicsPathCommand.html#WIDE_MOVE_TO
|
||||||
|
|
Loading…
Reference in New Issue