static TileAnimation() { var frameCount = 3; double tileWidth = 16; double tileHeight = 16; var tileWidthHalf = (tileWidth / 2); var tileHeightHalf = (tileHeight / 2); var tileWidthIncrement = tileWidthHalf / frameCount; var tileHeightIncrement = tileHeightHalf / frameCount; var images = new ImageSource[frameCount]; var frames = new AnimationFrame[frameCount]; for (var i = 0; i < frameCount; i++) { var rectWidth = tileWidthHalf + (tileWidthIncrement * i); var rectHeight = tileHeightHalf + (tileHeightIncrement * i); var rectTarget = new RenderTargetBitmap((int)rectWidth, (int)rectHeight, 96, 96, PixelFormats.Pbgra32); var rectVisual = new DrawingVisual(); using (var drawingContext = rectVisual.RenderOpen()) { drawingContext.DrawRectangle( new SolidColorBrush(Colors.DarkGray), null, new Rect(0, 0, rectWidth, rectHeight)); } rectTarget.Render(rectVisual); images[i] = rectTarget; frames[i] = new AnimationFrame(images[i], 50); } TileAnimation.fadeInRectanglesAnimation = new TileAnimation(frames); }
private AnimatedTilesCollection(List <Point <int> > tilesToUpdate, TileAnimation frames = null) { this.Tiles = tilesToUpdate; this.Frames = frames; }
public static AnimatedTilesCollection Create(List <Point <int> > tilesToUpdate, TileAnimation frames = null) { return(new AnimatedTilesCollection(tilesToUpdate, frames)); }