private void drawImage(Event e) { var mySprite = new Sprite(); var myBitmap = new BitmapData((int)loader.width, (int)loader.height, false); myBitmap.draw(loader, new Matrix()); Action<Matrix> update = matrix => { mySprite.graphics.beginBitmapFill(myBitmap, matrix, true); mySprite.graphics.drawRect(100, 50, 200, 90); mySprite.graphics.endFill(); }; this.mouseMove += ev => { var matrix = new Matrix(); matrix.rotate(Math.PI / 4 * ev.stageX / this.stage.stageWidth); update(matrix); }; update(new Matrix()); addChild(mySprite); }
public ApplicationSprite() { // http://www.adobe.com/devnet/flash/articles/avoiding-mistakes-assets.html // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/ui/MouseCursorData.html //Returns a Vector containing 8 cursor images Func<Vector<BitmapData>> makeCursorImages = () => { var cursorData = new Vector<BitmapData>(); var cursorShape = new Shape(); cursorShape.graphics.beginFill(0xff5555, .75); cursorShape.graphics.lineStyle(1); //Graphics path data for an arrow var cursorPoints = new double[] { 0, 8, 16, 8, 16, 0, 24, 12, 16, 24, 16, 16, 0, 16, 0, 8 }; var cursorDrawCommands = new int[] { 1, 2, 2, 2, 2, 2, 2, 2 }; cursorShape.graphics.drawPath( cursorDrawCommands, cursorPoints ); cursorShape.graphics.endFill(); var transformer = new Matrix(); //Rotate and draw the arrow shape to a BitmapData object for each of 8 frames for (var i = 0; i < 8; i++) { var cursorFrame = new BitmapData(32, 32, true, 0); cursorFrame.draw(cursorShape, transformer); cursorData.push(cursorFrame); transformer.translate(-15, -15); transformer.rotate(0.785398163); transformer.translate(15, 15); } return cursorData; }; // wtf? missing api? not defined in air? var mouseCursorData = new MouseCursorData(); mouseCursorData.data = makeCursorImages(); mouseCursorData.frameRate = 1; Mouse.registerCursor("spinningArrow", mouseCursorData); Mouse.cursor = "spinningArrow"; }
public void createGradation() { var tmpShape = new Shape(); var matrix = new Matrix(); matrix.createGradientBox(255, 0); //var colorList = new[] { 0xa7a7c4u, 0xf3f8ffu, 0xffffffu, 0x418fdfu }; var colorListA = new[] { new[] { 0xa7a7c4u, 0xf3f8ffu, 0xffffffu, 0x418fdfu }, new[] {0x824229u, 0xfb8f1bu, 0xffc768u, 0xa0afacu } }; var colorList = colorListA[ColorListIndex % colorListA.Length]; //new[] { 0xa7a7FFu, 0xf3f8FFu, 0xffffffu, 0x418fFFu }; //new[] { 0xFFa7a7u, 0xFFf3f8u, 0xffffffu, 0xFF418fu }; //new[] { 0x007777u, 0x007378u, 0x0u, 0x00214fu }; //= new[] {0x824229u, 0xfb8f1bu, 0xffc768u, 0xa0afacu }; var alphaList = new[] { 1.0, 1.0, 1.0, 1.0 }; var ratioList = new[] { 0, 80, 100, 200 }; tmpShape.graphics.beginGradientFill(GradientType.LINEAR, colorList, alphaList, ratioList, matrix); tmpShape.graphics.drawRect(0, 0, 255, 1); var tmpBitmap = new BitmapData(255, 1, false); tmpBitmap.draw(tmpShape); for (var i = 0; i < 256; i++) { _pallet[i] = (tmpBitmap.getPixel(i, 0)); _nullPallet[i] = (0x000000); } }
public static void ToMouseCursor(this Sprite c) { // http://www.kirupa.com/forum/showthread.php?274754-bitmapData-transparency var u = new BitmapData(32, 32, transparent: true, fillColor: 0x00FFFFFFu); var adjustAlpha = new ColorTransform(); //adjustAlpha.alphaMultiplier = 0.5; var m = new Matrix(); u.draw(c, m, adjustAlpha, BlendMode.NORMAL); var data = new BitmapData[] { u }; // X:\jsc.svn\examples\actionscript\FlashMouseCursorDataExperiment\FlashMouseCursorDataExperiment\ApplicationSprite.cs var cursor = new MouseCursorData { data = data }; // http://stackoverflow.com/questions/16004940/error-2136-swf-contains-invalid-data //Error: Error #2136: The SWF file file:///X|/jsc.svn/examples/actionscript/svg/FlashSVGCursorExperiment/FlashSVGCursorExperiment/bin/Debug/staging/FlashSVGCursorExperiment.ApplicationSprite/web/FlashSVGCursorExperiment.ApplicationSprite.swf contains invalid data. // at FlashSVGCursorExperiment::ApplicationSprite()[V:\web\FlashSVGCursorExperiment\ApplicationSprite.as:34] Mouse.registerCursor("c", cursor); Mouse.cursor = "c"; }