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); }
/// <summary> /// Default constructor /// </summary> public FlashPlasma() { this.InvokeWhenStageIsReady( delegate { Buffer = new BitmapData(DefaultWidth, DefaultHeight, false); var bitmap = new Bitmap(Buffer); addChild(bitmap); generatePlasma(); RenderMode = 0; stage.click += delegate { RenderMode++; }; stage.enterFrame += delegate { enterFrame2(); }; KnownEmbeddedResources.Default[KnownAssets.Path.Assets + "/jsc.png"].ToBitmapAsset().AttachTo(this).MoveTo(DefaultWidth - 128, DefaultHeight - 128); } ); }
private void Initialize() { //stage.frameRate = 30; //stage.quality = StageQuality.HIGH; _perlinNoiseBitmapData = new BitmapData(_perlinNoiseSizeW, _perlinNoiseSizeH, false); for (var i = 0; i < octaves; i++) _offsetList[i] = new Point(); _displacementBitmapData = new BitmapData(STAGE_W, STAGE_H, false); _displacementMapFilter = new DisplacementMapFilter(null, _point, 0, BitmapDataChannel.RED, 0, 100, DisplacementMapFilterMode.CLAMP); _palletBitmapData = new BitmapData(STAGE_W, STAGE_H, false); createGradation(); _scaleChangeBitmapData = new BitmapData(STAGE_W, STAGE_H, false); _scaleChangeMatrix = new Matrix(); _scaleChangeMatrix.scale(1 / _perlinNoiseSize, 1 / _perlinNoiseSize / _H_RATE); _cover = new Sprite(); var matrix = new Matrix(); matrix.createGradientBox(STAGE_W, STAGE_H, Math.PI / 2); var colors = new[] { 0x666666u, 0xaaaaaau }; var alphas = new[] { 1.0, 1.0 }; var ratios = new[] { 128, 255 }; _cover.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix ); _cover.graphics.drawRect(0, 0, STAGE_W, STAGE_H); _cover.blendMode = BlendMode.OVERLAY; addChild(new Bitmap(_scaleChangeBitmapData)); addChild(_cover); this.enterFrame += new Action<ScriptCoreLib.ActionScript.flash.events.Event>(TheCloudEffect_enterFrame); // some branding KnownEmbeddedResources.Default["assets/ScriptCoreLib/jsc.png"].ToBitmapAsset().AttachTo(this).MoveTo(STAGE_W - 128, STAGE_H - 128); this.stage.click += delegate { this.stage.SetFullscreen(true); }; }
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"; }
/// <summary> /// Default constructor /// </summary> public RayCaster2() { stage.keyDown += e => { var key = e.keyCode; fKeyUp.ProcessKeyDown(key); fKeyDown.ProcessKeyDown(key); fKeyLeft.ProcessKeyDown(key); fKeyRight.ProcessKeyDown(key); }; stage.keyUp += e => { var key = e.keyCode; fKeyUp.ProcessKeyUp(key); fKeyDown.ProcessKeyUp(key); fKeyLeft.ProcessKeyUp(key); fKeyRight.ProcessKeyUp(key); }; createTables(); var data = new BitmapData(DefaultWidth, DefaultHeight, false); var bitmap = new Bitmap(data); bitmap.scaleX = DefaultScale; bitmap.scaleY = DefaultScale; fOffscreenGraphics = data; bitmap.AttachTo(this); stage.enterFrame += e => run(); }
public HTest() { var roofs = new roofs().AttachTo(this); image = roofs.bitmapData; anchors = new Vector<Anchor>(4, true); anchors[0] = new Anchor(100, 257).AttachTo(this); anchors[1] = new Anchor(122, 218).AttachTo(this); anchors[2] = new Anchor(131, 251).AttachTo(this); anchors[3] = new Anchor(111, 296).AttachTo(this); homography = new Homography().AttachTo(this); homography.x = homography.y = 350; homography.filters = new[] { new GlowFilter(0xFF7F00, 1, 2, 2, 200, 2) }; stage.mouseMove += onMouseMove; onMouseMove(null); }
/// <summary> /// Default constructor /// </summary> public MandelbrotFlash() { this.InvokeWhenStageIsReady( delegate { var Buffer = new BitmapData(MandelbrotProvider.DefaultWidth, MandelbrotProvider.DefaultHeight, false); var bitmap = new Bitmap(Buffer); addChild(bitmap); MandelbrotProxy.InitializeMandelbrotProvider(); var shift = 0; stage.enterFrame += delegate { var ptr = MandelbrotProxy.DrawMandelbrotSet(shift); Buffer.@lock(); MandelbrotProxy.Memory.position = ptr; Buffer.setPixels(Buffer.rect, MandelbrotProxy.Memory); Buffer.unlock(); shift++; }; //KnownEmbeddedResources.Default[KnownAssets.Path.Assets + "/jsc.png"].ToBitmapAsset().AttachTo(this).MoveTo( // MandelbrotProvider.DefaultWidth - 128, // MandelbrotProvider.DefaultHeight - 128); } ); }
protected void prepare() { stage.align = StageAlign.TOP_LEFT; //stage.quality = StageQuality.LOW; txtMain = new TextField(); tfNormal = new TextFormat(); tfNormal.font = "Verdana"; tfNormal.align = TextFormatAlign.LEFT; tfNormal.size = 10; tfNormal.color = 0xffffff; txtMain.defaultTextFormat = tfNormal; txtMain.autoSize = "left"; txtMain.appendText("0"); moveSpeed = 0.2; rotSpeed = 0.12; texWidth = 256; texHeight = 256; posX = 22; posY = 11.5; dirX = -1; dirY = 0; planeX = 0; planeY = 0.66; w = 320; h = 240; time = getTimer(); setWorldMap(); //floorVals = new[] { // 80,40,26.6666666666667,20,16,13.3333333333333,11.4285714285714,10,8.88888888888889,8,7.27272727272727,6.66666666666667,6.15384615384615,5.71428571428571,5.33333333333333,5,4.70588235294118,4.44444444444444,4.21052631578947,4,3.80952380952381,3.63636363636364,3.47826086956522,3.33333333333333,3.2,3.07692307692308,2.96296296296296,2.85714285714286,2.75862068965517,2.66666666666667,2.58064516129032,2.5,2.42424242424242,2.35294117647059,2.28571428571429,2.22222222222222,2.16216216216216,2.10526315789474,2.05128205128205,2, //1.95121951219512,1.9047619047619,1.86046511627907,1.81818181818182,1.77777777777778,1.73913043478261,1.70212765957447,1.66666666666667,1.63265306122449,1.6,1.56862745098039,1.53846153846154,1.50943396226415,1.48148148148148,1.45454545454545,1.42857142857143,1.40350877192982,1.37931034482759,1.35593220338983,1.33333333333333,1.31147540983607,1.29032258064516,1.26984126984127,1.25,1.23076923076923,1.21212121212121,1.19402985074627,1.17647058823529,1.15942028985507,1.14285714285714,1.12676056338028,1.11111111111111,1.0958904109589,1.08108108108108,1.06666666666667,1.05263157894737,1.03896103896104,1.02564102564103,1.0126582278481 }; time = getTimer(); counter = 0; ZBuffer = new double[0]; screen = new BitmapData(w, h, false, 0x0); screenImage = new Bitmap(); screenImage.bitmapData = screen; addChild(screenImage); addChild(txtMain); this.enterFrame += render; //addEventListener(Event.ENTER_FRAME, render); }
/// <summary> /// Initializes a Bitmap object to refer to the specified BitmapData object. /// </summary> public Bitmap(BitmapData bitmapData, string pixelSnapping, bool smoothing) { }
/// <summary> /// Initializes a DisplacementMapFilter instance with the specified parameters. /// </summary> public DisplacementMapFilter(BitmapData mapBitmap, Point mapPoint, uint componentX, uint componentY, double scaleX) { }
/// <summary> /// Tests pixel values in an image against a specified threshold and sets pixels that pass the test to new color values. /// </summary> public uint threshold(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, string operation, uint threshold, uint color, uint mask, bool copySource) { return default(uint); }
/// <summary> /// Takes a source image and a filter object and generates the filtered image. /// </summary> public void applyFilter(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, BitmapFilter filter) { }
/// <summary> /// Remaps the color channel values in an image that has up to four arrays of color palette data, one for each channel. /// </summary> public void paletteMap(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint) { }
/// <summary> /// Tests pixel values in an image against a specified threshold and sets pixels that pass the test to new color values. /// </summary> public uint threshold(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, string operation, uint threshold) { return default(uint); }
public void setTransform(BitmapData src, Point p0, Point p1, Point p2, Point p3, int destWidth = 100, int destHeight = 100) { // Find diagonals intersection point var pc = new Point(); var a1 = p2.y - p0.y; var b1 = p0.x - p2.x; var a2 = p3.y - p1.y; var b2 = p1.x - p3.x; var denom = a1 * b2 - a2 * b1; if (denom == 0) { // something is better than nothing pc.x = 0.25 * (p0.x + p1.x + p2.x + p3.x); pc.y = 0.25 * (p0.y + p1.y + p2.y + p3.y); } else { var c1 = p2.x * p0.y - p0.x * p2.y; var c2 = p3.x * p1.y - p1.x * p3.y; pc.x = (b1 * c2 - b2 * c1) / denom; pc.y = (a2 * c1 - a1 * c2) / denom; } // Lengths of first diagonal var ll1 = Point.distance(p0, pc); var ll2 = Point.distance(pc, p2); // Lengths of second diagonal var lr1 = Point.distance(p1, pc); var lr2 = Point.distance(pc, p3); // Ratio between diagonals var f = (ll1 + ll2) / (lr1 + lr2); var sw = src.width; var sh = src.height; var dw = destWidth; var dh = destHeight; v8[2] = dw; v8[4] = dw; v8[5] = dh; v8[7] = dh; v12[0] = p0.x / sw; v12[1] = p0.y / sh; v12[2] = ll2 / f; v12[3] = p1.x / sw; v12[4] = p1.y / sh; v12[5] = lr2; v12[6] = p2.x / sw; v12[7] = p2.y / sh; v12[8] = ll1 / f; v12[9] = p3.x / sw; v12[10] = p3.y / sh; v12[11] = lr1; graphics.clear(); graphics.beginBitmapFill(src, null, false, true); graphics.drawTriangles(v8, v6, v12); }
/// <summary> /// Initializes a Bitmap object to refer to the specified BitmapData object. /// </summary> public Bitmap(BitmapData bitmapData, string pixelSnapping) { }
/// <summary> /// Provides a fast routine to perform pixel manipulation between images with no stretching, rotation, or color effects. /// </summary> public void copyPixels(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint) { }
/// <summary> /// Provides a fast routine to perform pixel manipulation between images with no stretching, rotation, or color effects. /// </summary> public void copyPixels(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, BitmapData alphaBitmapData, Point alphaPoint, bool mergeAlpha) { }
/// <summary> /// Transfers data from one channel of another BitmapData object or the current BitmapData object into a channel of the current BitmapData object. /// </summary> public void copyChannel(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, uint sourceChannel, uint destChannel) { }
/// <summary> /// Compares two BitmapData objects. /// </summary> public object compare(BitmapData otherBitmapData) { return default(object); }
/// <summary> /// Initializes a Bitmap object to refer to the specified BitmapData object. /// </summary> public Bitmap(BitmapData bitmapData) { }
/// <summary> /// Initializes a DisplacementMapFilter instance with the specified parameters. /// </summary> public DisplacementMapFilter(BitmapData mapBitmap, Point mapPoint, uint componentX) { }
/// <summary> /// Performs a pixel dissolve either from a source image to a destination image or by using the same image. /// </summary> public int pixelDissolve(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, int randomSeed, int numPixels) { return default(int); }
//bool DrawMinimapEnabled = true; private void DrawMinimap() { //if (!DrawMinimapEnabled) // return; var EgoView = this; var _WallMap = EgoView.Map.WallMap; var posX = EgoView.ViewPositionX; var posY = EgoView.ViewPositionY; var rayDirLeft = EgoView.ViewDirectionLeftBorder; var rayDirRight = EgoView.ViewDirectionRightBorder; int isize = 3; var minimap = new BitmapData(isize * (_WallMap.Size + 2), isize * (_WallMap.Size + 2), true, 0x0); var minimap_bmp = new Bitmap(minimap); for (int ix = 0; ix < _WallMap.Size; ix++) for (int iy = 0; iy < _WallMap.Size; iy++) { if (_WallMap[ix, iy] == 0) minimap.fillRect(new Rectangle((ix + 1) * isize, (iy + 1) * isize, isize, isize), 0x4f00ff00); } //minimap.applyFilter(minimap, minimap.rect, new Point(), new GlowFilter(0x00ff00)); minimap.drawLine(0xffffffff, (posX + 1) * isize, (posY + 1) * isize, (posX + 1 + Math.Cos(rayDirLeft) * isize) * isize, (posY + 1 + Math.Sin(rayDirLeft) * isize) * isize ); minimap.drawLine(0xffffffff, (posX + 1) * isize, (posY + 1) * isize, (posX + 1 + Math.Cos(rayDirRight) * isize) * isize, (posY + 1 + Math.Sin(rayDirRight) * isize) * isize ); //Console.WriteLine("left: " + rayDirLeft); //Console.WriteLine("right: " + rayDirLeft); foreach (var ss in EgoView.SpritesFromPointOfView) { uint color = 0xff00ff00; if (!ss.ViewInfo.IsInView) color = 0x9f008000; minimap.fillRect(new Rectangle( (ss.Sprite.Position.x + 0.5) * isize, (ss.Sprite.Position.y + 0.5) * isize, isize, isize), color); var _x = (ss.Sprite.Position.x + 1) * isize; var _y = (ss.Sprite.Position.y + 1) * isize; if (ss.Sprite.Frames.Length > 1) minimap.drawLine( 0xffffffff, _x, _y, _x + Math.Cos(ss.Sprite.Direction) * isize, _y + Math.Sin(ss.Sprite.Direction) * isize ); } minimap.fillRect(new Rectangle((posX + 0.5) * isize, (posY + 0.5) * isize, isize, isize), 0xffff0000); EgoView.Buffer.draw(minimap); }
/// <summary> /// Initializes a DisplacementMapFilter instance with the specified parameters. /// </summary> public DisplacementMapFilter(BitmapData mapBitmap, Point mapPoint) { }
/// <summary> /// Performs a pixel dissolve either from a source image to a destination image or by using the same image. /// </summary> public int pixelDissolve(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint) { return default(int); }
/// <summary> /// Initializes a DisplacementMapFilter instance with the specified parameters. /// </summary> public DisplacementMapFilter(BitmapData mapBitmap) { }
/// <summary> /// Initializes a DisplacementMapFilter instance with the specified parameters. /// </summary> public DisplacementMapFilter(BitmapData mapBitmap, Point mapPoint, uint componentX, uint componentY, double scaleX, double scaleY, string mode, uint color) { }
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); } }
/// <summary> /// Remaps the color channel values in an image that has up to four arrays of color palette data, one for each channel. /// </summary> public void paletteMap(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, uint[] redArray) { }