CanvasScript3
>
Tests
> Graphics - BeginLinearGradientFill
Replacement for Graphics.beginGradientFill(type=GradientType.LINEAR)
Code
var stage = new Stage("canvas", 420, 500, 30); var shape; // 2 colors, rotation 0 shape = new Shape(); shape.x = 20; shape.y = 20; shape.graphics.beginLinearGradientFill([0xFF0000, 0x0000FF], [1, 1], [0, 255], 0, 0, 100, 0); shape.graphics.drawRect(0, 0, 100, 100); shape.graphics.endFill(); stage.addChild(shape); // 2 colors, rotation 45 shape = new Shape(); shape.x = 140; shape.y = 20; shape.graphics.beginLinearGradientFill([0xFF0000, 0x0000FF], [1, 1], [0, 255], 0, 0, 100, 100); shape.graphics.drawRect(0, 0, 100, 100); shape.graphics.endFill(); stage.addChild(shape); // 2 colors, rotation 90 shape = new Shape(); shape.x = 260; shape.y = 20; shape.graphics.beginLinearGradientFill([0xFF0000, 0x0000FF], [1, 1], [0, 255], 0, 0, 0, 100); shape.graphics.drawRect(0, 0, 100, 100); shape.graphics.endFill(); stage.addChild(shape); // 3 colors, rotation 0 shape = new Shape(); shape.x = 20; shape.y = 140; shape.graphics.beginLinearGradientFill([0xFF0000, 0x0000FF, 0x00FF00], [1, 1, 1], [0, 127, 255], 0, 0, 100, 0); shape.graphics.drawRect(0, 0, 100, 100); stage.addChild(shape); // 3 colors, rotation 45 shape = new Shape(); shape.x = 140; shape.y = 140; shape.graphics.beginLinearGradientFill([0xFF0000, 0x0000FF, 0x00FF00], [1, 1, 1], [0, 127, 255], 0, 0, 100, 100); shape.graphics.drawRect(0, 0, 100, 100); stage.addChild(shape); // 3 colors, rotation 90 shape = new Shape(); shape.x = 260; shape.y = 140; shape.graphics.beginLinearGradientFill([0xFF0000, 0x0000FF, 0x00FF00], [1, 1, 1], [0, 127, 255], 0, 0, 0, 100); shape.graphics.drawRect(0, 0, 100, 100); stage.addChild(shape); // alpha, rotation 0 shape = new Shape(); shape.x = 20; shape.y = 260; shape.graphics.beginLinearGradientFill([0xFF0000, 0xFF0000], [1, 0], [0, 255], 0, 0, 100, 0); shape.graphics.drawRect(0, 0, 100, 100); shape.graphics.endFill(); stage.addChild(shape); // alpha, rotation 45 shape = new Shape(); shape.x = 140; shape.y = 260; shape.graphics.beginLinearGradientFill([0xFF0000, 0xFF0000], [1, 0], [0, 255], 0, 0, 100, 100); shape.graphics.drawRect(0, 0, 100, 100); shape.graphics.endFill(); stage.addChild(shape); // alpha, rotation 90 shape = new Shape(); shape.x = 260; shape.y = 260; shape.graphics.beginLinearGradientFill([0xFF0000, 0xFF0000], [1, 0], [0, 255], 0, 0, 0, 100); shape.graphics.drawRect(0, 0, 100, 100); shape.graphics.endFill(); stage.addChild(shape);
Canvas
Output