Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package;
- import openfl.display.Sprite;
- import openfl.display.Shape;
- import openfl.geom.Matrix;
- import openfl.display.Bitmap;
- import openfl.display.BitmapData;
- class Main extends Sprite
- {
- static private var coords : Array<Float> = [ 100, 100, 200, 100, 200, 200, 150, 200, 150, 150, 180, 150, 180,
- 120, 120, 120, 120, 150, 150, 150, 150, 200, 100, 200, 100, 100 ];
- static var holeIn : Int = 4;
- static var holeOut : Int = 10;
- public function new () {
- super ();
- var s = new Shape();
- var s2 = new Shape();
- var g = s.graphics;
- var g2 = s2.graphics;
- g.lineStyle( 1.0, 0, 1.0 ,true,openfl.display.LineScaleMode.NONE);
- g.beginFill( 0x00ccbb, 1.0 );
- g.moveTo( coords[0], coords[1] );
- g2.lineStyle( 1.0, 0, 1.0 ,true,openfl.display.LineScaleMode.NONE);
- g2.beginFill( 0x00ccbb, 1.0 );
- g2.moveTo( coords[0], coords[1] );
- var i = 2;
- while ( i < coords.length ) {
- if ((i == holeIn * 2) || (i == holeOut * 2)) {
- g.lineStyle(null, 0, 0);
- g.lineTo( coords[i], coords[i + 1] );
- g.lineStyle( 1.0, 0, 1.0, true, openfl.display.LineScaleMode.NONE);
- g2.lineStyle(null, 0, 0);
- g2.lineTo( coords[i], coords[i + 1] );
- g2.lineStyle( 1.0, 0, 1.0 , true,openfl.display.LineScaleMode.NONE);
- } else {
- g.lineTo( coords[i], coords[i + 1] );
- g2.lineTo( coords[i], coords[i + 1] );
- }
- i += 2;
- }
- g.endFill();
- g2.endFill();
- //display 1st as vector
- addChild( s );
- //display 2nd as bitmap scaled down with matrix
- var sc = 0.25;
- var m = new Matrix();
- m.scale(sc, sc);
- var bmd = new BitmapData(500, 500,true,0xFFFFFF);
- bmd.draw(s,m);
- var bm = new Bitmap(bmd, openfl.display.PixelSnapping.ALWAYS, false); // , openfl.display.PixelSnapping.AUTO, false);
- bm.x = 300;
- addChild(bm);
- //display 3rd as vector scaled down
- s2.scaleX = s2.scaleY = sc;
- s2.x = 400;
- addChild(s2);
- //display 4rd as bitmap from scaled down vector (different behaviour in html and flash)
- var bmd2 = new BitmapData(500, 500, true, 0xFFFFFF);
- bmd2.draw(s2);
- var bm2 = new Bitmap(bmd2, openfl.display.PixelSnapping.ALWAYS, false); // , openfl.display.PixelSnapping.AUTO, false);
- bm2.x = 500;
- addChild(bm2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement