Flash / Flex / ActionScript/Graphics/Curve — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 08:15, 26 мая 2010
Curve control point
package{
import flash.display.Sprite;
import flash.display.*;
public class Main extends Sprite{
public function Main(){
var canvas:Shape = new Shape( );
addChild(canvas);
canvas.graphics.lineStyle(2, 0x0000FF);
curveThrough3Pts(canvas.graphics, 100, 100, 150, 50, 200, 100);
}// Adapted from Robert Penner"s drawCurve3Pts( ) method
public function curveThrough3Pts (g:Graphics,startX:Number, startY:Number,
throughX:Number, throughY:Number,
endX:Number, endY:Number) {
var controlX:Number = (2 * throughX) - .5 * (startX + endX);
var controlY:Number = (2 * throughY) - .5 * (startY + endY);
g.moveTo(startX, startY);
g.curveTo(controlX, controlY, endX, endY);
}
}
}
Drawing Curves: curveTo(controlX:Number, controlY:Number, anchorX:Number, anchorY:Number)
package{
import flash.display.*;
public class Main extends Sprite{
public function Main(){
var canvas:Shape = new Shape( );
addChild(canvas);
canvas.graphics.lineStyle(4); // Set the stroke to 4-point, black
canvas.graphics.curveTo(50, 100, 100, 0); // Draw the curve
}
}
}
Drawing Curves in a Graphics Object
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var spr:Sprite = new Sprite();
spr.graphics.beginFill(0x0000ff, 1.0);
spr.graphics.lineStyle(1, 0x0000ff);
spr.graphics.moveTo(30, 30);
spr.graphics.curveTo(180, 20, 250, 30);
spr.graphics.endFill();
addChild(spr);
}
}
}