public override void Draw(CanvasSpriteBatch spriteBatch) { var wall = this as Wall; switch (wall.wallSide) { case WallSide.Top: spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(bounds.X + GameSprite.WallTopCapSize.Width, bounds.Y, bounds.Width - GameSprite.WallTopCapSize.Width, bounds.Height), spriteSource); spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(bounds.X, bounds.Y, GameSprite.WallTopCapSize.Width, GameSprite.WallTopCapSize.Height), wallCapASource); spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(bounds.X + (bounds.Width - GameSprite.WallTopCapSize.Width), bounds.Y, GameSprite.WallTopCapSize.Width, GameSprite.WallTopCapSize.Height), wallCapBSource); break; case WallSide.Left: case WallSide.Right: spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(bounds.X, bounds.Y, bounds.Width, bounds.Height - GameSprite.WallSideCapSize.Height), spriteSource); spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(bounds.X, bounds.Y + (bounds.Height - GameSprite.WallSideCapSize.Height), GameSprite.WallSideCapSize.Width, GameSprite.WallSideCapSize.Height), wallCapASource); break; default: break; } }
public void Draw( CanvasDrawingSession ds, CanvasSpriteBatch SBatch, TextureLoader Textures ) { lock ( PFSim ) { var Snapshot = PFSim.Snapshot(); while ( Snapshot.MoveNext() ) { Particle P = Snapshot.Current; float A = Vector2.Transform( new Vector2( 0, 1 ), Matrix3x2.CreateRotation( P.ttl * 0.01f ) ).X; Vector4 Tint = new Vector4( P.Tint.M11 + P.Tint.M21 + P.Tint.M31 + P.Tint.M41 + P.Tint.M51, P.Tint.M12 + P.Tint.M22 + P.Tint.M32 + P.Tint.M42 + P.Tint.M52, P.Tint.M13 + P.Tint.M23 + P.Tint.M33 + P.Tint.M43 + P.Tint.M53, P.Tint.M14 + P.Tint.M24 + P.Tint.M34 + P.Tint.M44 + P.Tint.M54 ); Tint.W *= A; ScrollWind.Strength *= 0.5f; SBatch.Draw( Textures[ P.TextureId ] , P.Pos, Tint , Textures.Center[ P.TextureId ], 0, P.Scale , CanvasSpriteFlip.None ); } DrawWireFrames( ds ); } }
void CreateResources(CanvasAnimatedControl sender, CanvasCreateResourcesEventArgs args) { if (args.Reason == CanvasCreateResourcesReason.DpiChanged) { return; } if (args.Reason == CanvasCreateResourcesReason.FirstTime) { bool spriteBatchSupported = false; #if WINDOWS_UWP spriteBatchSupported = CanvasSpriteBatch.IsSupported(sender.Device); #endif UseSpriteBatch = spriteBatchSupported; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("UseSpriteBatch")); } UseSpriteBatchCheckBox.Visibility = spriteBatchSupported ? Visibility.Visible : Visibility.Collapsed; } args.TrackAsyncAction(CreateResourcesAsync(sender).AsAsyncAction()); }
private void DrawClearTiles(CanvasEventArgs args, CanvasSpriteBatch spriteBatch) { var tile = args.Engine.TextureManager.GetTextureFromPath(ClearTextureKey); var cs = args.Engine.CoordinateSystem; var minTileX = cs.ScreenCoordinatesToTileCoordinates(new Vector2(0, 0)).X - 1; var maxTileX = cs.ScreenCoordinatesToTileCoordinates(new Vector2((float)args.Sender.Size.Width, (float)args.Sender.Size.Height)).X + 1; var minTileY = cs.ScreenCoordinatesToTileCoordinates(new Vector2((float)args.Sender.Size.Width, 0)).Y - 1; var maxTileY = cs.ScreenCoordinatesToTileCoordinates(new Vector2(0, (float)args.Sender.Size.Height)).Y + 1; for (var x = minTileX; x <= maxTileX; x++) { for (var y = minTileY; y <= maxTileY; y++) { var thisTileHeight = (float)tile.SourceRect.Height; var thisTileHeightFactor = thisTileHeight / cs.TileHeight; var position = cs.TileCoordinatesToScreenCoordinates(new TileCoordinate(x, y), thisTileHeightFactor); spriteBatch.DrawFromSpriteSheet( tile.Bitmap, new Rect( position.X, position.Y, cs.EffectiveTileWidth, cs.EffectiveTileHeight * thisTileHeightFactor), tile.SourceRect); } } }
public void Draw( CanvasDrawingSession ds, CanvasSpriteBatch SBatch, TextureLoader Textures ) { lock ( PFSim ) { var Snapshot = PFSim.Snapshot(); while ( Snapshot.MoveNext() ) { Particle P = Snapshot.Current; float A = ( P.Trait & PFTrait.IMMORTAL ) == 0 ? P.ttl * 0.033f : 1; P.Tint.M12 = 4 * ( 1 - A ); P.Tint.M21 = 3 * A; Vector4 Tint = new Vector4( P.Tint.M11 + P.Tint.M21 + P.Tint.M31 + P.Tint.M41 + P.Tint.M51, P.Tint.M12 + P.Tint.M22 + P.Tint.M32 + P.Tint.M42 + P.Tint.M52, P.Tint.M13 + P.Tint.M23 + P.Tint.M33 + P.Tint.M43 + P.Tint.M53, P.Tint.M14 + P.Tint.M24 + P.Tint.M34 + P.Tint.M44 + P.Tint.M54 ) * 2; Tint.W *= A * 0.125f; SBatch.Draw( Textures[ P.TextureId ], P.Pos, Tint, Textures.Center[ P.TextureId ], 0, P.Scale * A, CanvasSpriteFlip.None ); } DrawWireFrames( ds ); } }
public void Draw(CanvasDrawingSession ds, CanvasSpriteBatch SBatch, TextureLoader Textures) { lock ( PFSim ) { var Snapshot = PFSim.Snapshot(); while (Snapshot.MoveNext()) { Particle P = Snapshot.Current; float A = Vector2.Transform(new Vector2(0, 1), Matrix3x2.CreateRotation(P.ttl * 0.01f)).X; Vector4 Tint = new Vector4( P.Tint.M11 + P.Tint.M21 + P.Tint.M31 + P.Tint.M41 + P.Tint.M51, P.Tint.M12 + P.Tint.M22 + P.Tint.M32 + P.Tint.M42 + P.Tint.M52, P.Tint.M13 + P.Tint.M23 + P.Tint.M33 + P.Tint.M43 + P.Tint.M53, P.Tint.M14 + P.Tint.M24 + P.Tint.M34 + P.Tint.M44 + P.Tint.M54 ); Tint.W *= A; ScrollWind.Strength *= 0.5f; SBatch.Draw( Textures[P.TextureId] , P.Pos, Tint , Textures.Center[P.TextureId], 0, P.Scale , CanvasSpriteFlip.None); } DrawWireFrames(ds); } }
public void Draw(CanvasSpriteBatch spriteBatch, int sprite, Vector2 position, Vector4 tint) { if (sprite < 0) return; spriteBatch.DrawFromSpriteSheet(bitmap, position, GetSourceRect(sprite), tint, origin, 0, Vector2.One, CanvasSpriteFlip.None); }
public void DrawSprite(CanvasSpriteBatch spriteBatch, Vector2 pos, Vector2 imagePos) { spriteBatch.DrawFromSpriteSheet( bitmap, new Rect(pos.X, pos.Y, SpriteSize.X, SpriteSize.Y), new Rect(imagePos.X * SpriteSize.X, imagePos.Y * SpriteSize.Y, SpriteSize.X, SpriteSize.Y)); }
public void Draw(CanvasDrawingSession ds, CanvasSpriteBatch SBatch, TextureLoader Textures) { lock ( PFSim ) { var Snapshot = PFSim.Snapshot(); while (Snapshot.MoveNext()) { Particle P = Snapshot.Current; float A = (P.Trait & PFTrait.IMMORTAL) == 0 ? P.ttl * 0.033f : 1; P.Tint.M12 = 4 * (1 - A); P.Tint.M21 = 3 * A; Vector4 Tint = new Vector4( P.Tint.M11 + P.Tint.M21 + P.Tint.M31 + P.Tint.M41 + P.Tint.M51, P.Tint.M12 + P.Tint.M22 + P.Tint.M32 + P.Tint.M42 + P.Tint.M52, P.Tint.M13 + P.Tint.M23 + P.Tint.M33 + P.Tint.M43 + P.Tint.M53, P.Tint.M14 + P.Tint.M24 + P.Tint.M34 + P.Tint.M44 + P.Tint.M54 ) * 2; Tint.W *= A * 0.125f; SBatch.Draw(Textures[P.TextureId], P.Pos, Tint, Textures.Center[P.TextureId], 0, P.Scale * A, CanvasSpriteFlip.None); } DrawWireFrames(ds); } }
void DrawLayer(CanvasSpriteBatch sb, int[] layer) { for (int i = 0; i < layer.Length; ++i) { DrawTile(sb, layer, i); } }
public void Draw(CanvasSpriteBatch sb, CanvasTimingInformation timing) { foreach (IDrawable drawable in drawables.Values) { drawable.Draw(this, sb, timing); } }
protected override void OnCreateResource(CanvasControl sender, CanvasCreateResourcesEventArgs args) { // Clear all Tiles and Reload (Display Device might have changed...) _isSpriteBatchSupported = CanvasSpriteBatch.IsSupported(sender.Device); LayerConfiguration.TileProvider.ResetTiles(ParentMap, sender); _isInitialResourcesLoaded = true; }
public void Draw(EntityRenderer renderer, CanvasSpriteBatch sb, CanvasTimingInformation timing) { sb.Draw(renderer.Sprites[entity.Shape], Matrix3x2.CreateTranslation(-entity.Shape.Origin * SpriteBuilder.SCALE_FACTOR) * Matrix3x2.CreateRotation(entity.Direction) * Matrix3x2.CreateScale(1f / SpriteBuilder.SCALE_FACTOR) * Matrix3x2.CreateTranslation(entity.Position), entity.Color); }
protected override void Draw(CanvasDrawingSession drawingSession #if WINDOWS_UWP , CanvasSpriteBatch spriteBatch #endif ) { // 逆向遍历队列,可以让新粒子绘制在旧粒子下方,这样当很多粒子在同一个位置生成时,效果较好 for (int i = ActiveParticles.Count - 1; i >= 0; i--) { Particle particle = ActiveParticles[i]; // NormalizedLifeTime 是一个0到1之间的值,用来表示粒子在生命周期中的进度,这个值接近0或接近1时, // 粒子将会渐隐/渐显,使用它来计算粒子的透明度和缩放 float normalizedLifetime = particle.TimeSinceStart / 4; if (normalizedLifetime > 1) { normalizedLifetime = 1; } // We want particles to fade in and fade out, so we'll calculate alpha to be // (normalizedLifetime) * (1 - normalizedLifetime). This way, when normalizedLifetime // is 0 or 1, alpha is 0. The maximum value is at normalizedLifetime = .5, and is: // // (normalizedLifetime) * (1-normalizedLifetime) // (.5) * (1-.5) // .25 // // Since we want the maximum alpha to be 1, not .25, we'll scale the entire equation by 4. float alpha = (float)EasingHelper.QuinticEase(Windows.UI.Xaml.Media.Animation.EasingMode.EaseOut, normalizedLifetime); var x = particle.ScaleX; var y = particle.ScaleY; // Make particles grow as they age. // They'll start at 75% of their size, and increase to 100% once they're finished. if (isImmersive) { alpha *= 0.8f; x *= 1.2f; y *= 1.2f; } #if WINDOWS_UWP if (spriteBatch != null) { spriteBatch.Draw(smokeSurfaces[particle.Key], particle.Position, new Vector4(1, 1, 1, alpha), bitmapCenter, particle.Rotation, new Vector2(x, y), CanvasSpriteFlip.None); } else #endif { // Compute a transform matrix for this particle. var transform = Matrix3x2.CreateRotation(particle.Rotation, bitmapCenter) * Matrix3x2.CreateScale(x, y, bitmapCenter) * Matrix3x2.CreateTranslation(particle.Position - bitmapCenter); // Draw the particle. drawingSession.DrawImage(smokeSurfaces[particle.Key], 0, 0, bitmapBounds, alpha, CanvasImageInterpolation.Linear, new Matrix4x4(transform)); } } }
public void Draw(CanvasSpriteBatch spriteBatch, int sprite, Vector2 position, Vector4 tint) { if (sprite < 0) { return; } spriteBatch.DrawFromSpriteSheet(bitmap, position, GetSourceRect(sprite), tint, origin, 0, Vector2.One, CanvasSpriteFlip.None); }
void OnCreateResources(CanvasAnimatedControl sender, CanvasCreateResourcesEventArgs args) { spriteBatchSupported = CanvasSpriteBatch.IsSupported(sender.Device); if (!spriteBatchSupported) { return; } args.TrackAsyncAction(LoadImages(sender.Device).AsAsyncAction()); }
virtual protected void Stage_Draw(ICanvasAnimatedControl sender, CanvasAnimatedDrawEventArgs args) { using (CanvasDrawingSession ds = args.DrawingSession) using (CanvasSpriteBatch SBatch = ds.CreateSpriteBatch(CanvasSpriteSortMode.Bitmap)) { lock ( Scenes ) { Scenes.ForEach(x => x.Draw(ds, SBatch, Textures)); } } }
public void DrawSelf(CanvasSpriteBatch spriteBatch) { Sprite.DrawSpriteExt( spriteBatch, new Vector2(XPos, YPos), new Vector2(ImageX, ImageY), new Vector4(Red, Green, Blue, Alpha), 0, new Vector2(XScale, YScale), 0); }
public override void Draw(CanvasSpriteBatch spriteBatch) { spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(bounds.X + GameSprite.PaddleCapSize.Width, bounds.Y, bounds.Width - (GameSprite.PaddleCapSize.Width * 2), bounds.Height), spriteSource); spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(bounds.X, bounds.Y, GameSprite.PaddleCapSize.Width, GameSprite.PaddleCapSize.Height), paddleCapASource); spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(bounds.X + (bounds.Width - GameSprite.PaddleCapSize.Width), bounds.Y, GameSprite.PaddleCapSize.Width, GameSprite.PaddleCapSize.Height), paddleCapBSource); }
void Draw(CanvasDrawingSession drawingSession #if WINDOWS_UWP , CanvasSpriteBatch spriteBatch #endif ) { // Go through the particles in reverse order, so new ones are drawn underneath // older ones. This improves visual appearance of effects like smoke plume // where many particles are created at the same position over a period of time. for (int i = activeParticles.Count - 1; i >= 0; i--) { Particle particle = activeParticles[i]; // Normalized lifetime is a value from 0 to 1 and represents how far a particle // is through its life. 0 means it just started, .5 is half way through, and // 1.0 means it's just about to be finished. This value will be used to calculate // alpha and scale, to avoid having particles suddenly appear or disappear. float normalizedLifetime = particle.TimeSinceStart / particle.Lifetime; // We want particles to fade in and fade out, so we'll calculate alpha to be // (normalizedLifetime) * (1 - normalizedLifetime). This way, when normalizedLifetime // is 0 or 1, alpha is 0. The maximum value is at normalizedLifetime = .5, and is: // // (normalizedLifetime) * (1-normalizedLifetime) // (.5) * (1-.5) // .25 // // Since we want the maximum alpha to be 1, not .25, we'll scale the entire equation by 4. float alpha = 4 * normalizedLifetime * (1 - normalizedLifetime); // Make particles grow as they age. // They'll start at 75% of their size, and increase to 100% once they're finished. float scale = particle.Scale * (.75f + .25f * normalizedLifetime); #if WINDOWS_UWP if (spriteBatch != null) { spriteBatch.Draw(bitmap, particle.Position, new Vector4(1, 1, 1, alpha), bitmapCenter, particle.Rotation, new Vector2(scale), CanvasSpriteFlip.None); } else #endif { // Compute a transform matrix for this particle. var transform = Matrix3x2.CreateRotation(particle.Rotation, bitmapCenter) * Matrix3x2.CreateScale(scale, bitmapCenter) * Matrix3x2.CreateTranslation(particle.Position - bitmapCenter); // Draw the particle. drawingSession.DrawImage(bitmap, 0, 0, bitmapBounds, alpha, CanvasImageInterpolation.Linear, new Matrix4x4(transform)); } } }
public void DrawSpriteExt(CanvasSpriteBatch spriteBatch, Vector2 pos, Vector2 imagePos, Vector4 rgba, float rotation, Vector2 scale, CanvasSpriteFlip flip) { // Draw Sprite Extended spriteBatch.DrawFromSpriteSheet( bitmap, pos, new Rect(imagePos.X * SpriteSize.X, imagePos.Y * SpriteSize.Y, SpriteSize.X, SpriteSize.Y), rgba, // Tint -> rgba [0 to 1] new Vector2(SpriteSize.X / 2, SpriteSize.Y / 2), // Origin, now centered in the middle rotation, // Rotation in radians scale, // Scale (default: 1, 1) flip); // CanvasSpriteFlip -> 0, 1, 2 or 3 }
public void Draw(ITexture texture, Matrix3x2 transform, Vector4 tint) { CanvasBlend previousBlend = this.canvasDrawingSession.Blend; using (CanvasSpriteBatch spriteBatch = this.canvasDrawingSession.CreateSpriteBatch()) { this.canvasDrawingSession.Blend = CanvasBlend.Add; CanvasBitmap bitmap = ((Texture)texture).Bitmap; spriteBatch.Draw(bitmap, transform, tint, CanvasSpriteFlip.None); this.canvasDrawingSession.Blend = previousBlend; } }
protected override void Draw(CanvasDrawingSession drawingSession #if WINDOWS_UWP , CanvasSpriteBatch spriteBatch #endif ) { // 逆向遍历队列,可以让新粒子绘制在旧粒子下方,这样当很多粒子在同一个位置生成时,效果较好 for (int i = ActiveParticles.Count - 1; i >= 0; i--) { Particle particle = ActiveParticles[i]; // NormalizedLifeTime 是一个0到1之间的值,用来表示粒子在生命周期中的进度,这个值接近0或接近1时, // 粒子将会渐隐/渐显,使用它来计算粒子的透明度和缩放 float normalizedLifetime = particle.TimeSinceStart / particle.Lifetime; // We want particles to fade in and fade out, so we'll calculate alpha to be // (normalizedLifetime) * (1 - normalizedLifetime). This way, when normalizedLifetime // is 0 or 1, alpha is 0. The maximum value is at normalizedLifetime = .5, and is: // // (normalizedLifetime) * (1-normalizedLifetime) // (.5) * (1-.5) // .25 // // Since we want the maximum alpha to be 1, not .25, we'll scale the entire equation by 4. float alpha = 4 * normalizedLifetime * (1 - normalizedLifetime); // Make particles grow as they age. // They'll start at 75% of their size, and increase to 100% once they're finished. float scale = particle.ScaleX * (.75f + .25f * normalizedLifetime); #if WINDOWS_UWP if (spriteBatch != null) { spriteBatch.Draw(bitmap, particle.Position, new Vector4(1, 1, 1, alpha), bitmapCenter, 0, new Vector2(scale), CanvasSpriteFlip.None); } else #endif { // Compute a transform matrix for this particle. var transform = Matrix3x2.CreateRotation(particle.Rotation, bitmapCenter) * Matrix3x2.CreateScale(scale) * Matrix3x2.CreateTranslation(particle.Position - bitmapCenter); // Draw the particle. drawingSession.DrawImage(bitmap, 0, 0, bitmapBounds, alpha, CanvasImageInterpolation.Linear, new Matrix4x4(transform)); } } }
protected virtual void Draw(CanvasDrawingSession drawingSession #if WINDOWS_UWP , CanvasSpriteBatch spriteBatch #endif ) { // 逆向遍历队列,可以让新粒子绘制在旧粒子下方,这样当很多粒子在同一个位置生成时,效果较好 for (int i = activeParticles.Count - 1; i >= 0; i--) { Particle particle = activeParticles[i]; // NormalizedLifeTime 是一个0到1之间的值,用来表示粒子在生命周期中的进度,这个值接近0或接近1时, // 粒子将会渐隐/渐显,使用它来计算粒子的透明度和缩放 //float normalizedLifetime = particle.TimeSinceStart / particle.Lifetime; // We want particles to fade in and fade out, so we'll calculate alpha to be // (normalizedLifetime) * (1 - normalizedLifetime). This way, when normalizedLifetime // is 0 or 1, alpha is 0. The maximum value is at normalizedLifetime = .5, and is: // // (normalizedLifetime) * (1-normalizedLifetime) // (.5) * (1-.5) // .25 // // Since we want the maximum alpha to be 1, not .25, we'll scale the entire equation by 4. //float alpha = 4 * normalizedLifetime * (1 - normalizedLifetime); // Make particles grow as they age. // They'll start at 75% of their size, and increase to 100% once they're finished. //float scale = particle.Scale * (.75f + .25f * normalizedLifetime); #if WINDOWS_UWP if (spriteBatch != null) { spriteBatch.Draw(bitmap, particle.Position, new Vector4(1, 1, 1, 1 /*alpha*/), bitmapCenter, particle.Rotation - 1.5708f, new Vector2(particle.ScaleX, particle.ScaleY /*scale*/), CanvasSpriteFlip.None); } else #endif { // Compute a transform matrix for this particle. var transform = Matrix3x2.CreateRotation(particle.Rotation - 1.5708f, bitmapCenter) * Matrix3x2.CreateScale(/*scale*/ particle.ScaleX, particle.ScaleY, bitmapCenter) * Matrix3x2.CreateTranslation(particle.Position - bitmapCenter); // Draw the particle. drawingSession.DrawImage(bitmap, 0, 0, bitmapBounds, 1 /*alpha*/, CanvasImageInterpolation.Linear, new Matrix4x4(transform)); } } }
void CreateResources(CanvasAnimatedControl sender, CanvasCreateResourcesEventArgs args) { if (args.Reason == CanvasCreateResourcesReason.DpiChanged) { return; } bool spriteBatchSupported = false; #if WINDOWS_UWP spriteBatchSupported = CanvasSpriteBatch.IsSupported(sender.Device); #endif UseSpriteBatch = UseSpriteBatchCheckBox.IsChecked.GetValueOrDefault(false); UseSpriteBatchCheckBox.Visibility = spriteBatchSupported ? Visibility.Visible : Visibility.Collapsed; args.TrackAsyncAction(CreateResourcesAsync(sender).AsAsyncAction()); }
void DrawTile(CanvasSpriteBatch sb, int[] layer, int index) { int row = index / mapWidth; int column = index % mapWidth; Vector4 tint = Vector4.One; if (TintSprites) { tint = ((row + column) % 2 == 0) ? Vector4.One : new Vector4(2, 1, 1, 1); } if (ShowCollision) { tint = collisionLayer[index] == 0 ? Vector4.One : new Vector4(2, 0.5f, 0.5f, 1); } forestTiles.Draw(sb, layer[index], forestTiles.SpriteSize * new Vector2(column, row), tint); }
public void DrawSelf(CanvasSpriteBatch spriteBatch) { for (int x = 0; x < Layout.Length; x++) { for (int y = 0; y < Layout[x].Length; y++) { if (Layout[y][x] == 1) { Sprite.DrawSpriteExt( spriteBatch, new Vector2(x * 128, y * 128), new Vector2(0, 0), new Vector4(1, 1, 1, 1), 0, new Vector2(1, 1), 0); } } } }
public void Draw(CanvasDrawingSession ds, CanvasSpriteBatch SBatch, TextureLoader Textures) { if (InRange) { ds.FillRectangle(R0.X, R0.Y, R0.W, R0.Z, LayoutSettings.RelativeMajorBackgroundColor); ds.FillRectangle(R1.X, R1.Y, R1.W, R1.Z, LayoutSettings.SubtleColor); } else { ds.FillRectangle(R0.X, R0.Y, R0.W, R0.Z, LayoutSettings.SubtleColor); ds.FillRectangle(R1.X, R1.Y, R1.W, R1.Z, LayoutSettings.RelativeMajorBackgroundColor); } Color PinMask = LayoutSettings.MajorColor; PinMask.A = 48; ds.DrawLine(PosX, PosY.X, PosX, PosY.Y, PinMask, 10); ds.DrawLine(PosX, PosY.X, PosX, PosY.Y, LayoutSettings.MajorColor, 1); }
public override void Draw(CanvasSpriteBatch spriteBatch) { if (hasExploded) { spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect( location.X - (BLOW_RADIUS / 2), location.Y - (BLOW_RADIUS / 2), size.Width + BLOW_RADIUS, size.Height + BLOW_RADIUS), spriteSource); hasExploded = false; } else { spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(location.X, location.Y, size.Width, size.Height), spriteSource); } }
public void DrawSelf(CanvasSpriteBatch spriteBatch) { int speed = 2; if (EntityManager.EntityExists(typeof(CoordPoint))) { } XPos += (float)(speed * Math.Cos(angle)); YPos += (float)(speed * Math.Sin(angle)); Sprite.DrawSpriteExt( spriteBatch, new Vector2(XPos, YPos), new Vector2(ImageX, ImageY), new Vector4(Red, Green, Blue, Alpha), (float)(angle - 0.5 * Math.PI), new Vector2(XScale, YScale), 0); }
public SpriteBatchPerf() { Scenarios = new List <Scenario>(); bool spriteBatchSupported = CanvasSpriteBatch.IsSupported(CanvasDevice.GetSharedDevice()); Scenarios.Add(new Scenario(Scenario.DrawMethod.DrawImage, CanvasSpriteSortMode.None)); if (spriteBatchSupported) { Scenarios.Add(new Scenario(Scenario.DrawMethod.Win2DSpriteBatch, CanvasSpriteSortMode.None)); Scenarios.Add(new Scenario(Scenario.DrawMethod.Win2DSpriteBatch, CanvasSpriteSortMode.Bitmap)); Scenarios.Add(new Scenario(Scenario.DrawMethod.CppWin2DSpriteBatch, CanvasSpriteSortMode.None)); Scenarios.Add(new Scenario(Scenario.DrawMethod.CppWin2DSpriteBatch, CanvasSpriteSortMode.Bitmap)); Scenarios.Add(new Scenario(Scenario.DrawMethod.D2DSpriteBatch, CanvasSpriteSortMode.None)); } DrawCount = 0; BitmapCount = 1; if (!DesignMode.DesignModeEnabled) { DataContext = this; } if (ThumbnailGenerator.IsDrawingThumbnail) { foreach (var scenario in Scenarios) { scenario.PopulateWithThumbnailData(); } } this.InitializeComponent(); if (!spriteBatchSupported) { this.SpriteBatchNotSupportedText.Visibility = Visibility.Visible; } }
protected void Draw(CanvasDrawingSession drawingSession #if WINDOWS_UWP , CanvasSpriteBatch spriteBatch #endif ) { #if WINDOWS_UWP if (spriteBatch != null) { spriteBatch.Draw(sunSurfaces[(uint)(nowFrame * slowFactor) % surfaceCount], position, new Vector4(1, 1, 1, opcity), center, rotation, new Vector2(1, 1), CanvasSpriteFlip.None); } else #endif { // Compute a transform matrix for this particle. var transform = Matrix3x2.CreateRotation(rotation, center) * Matrix3x2.CreateScale(1, 1, center) * Matrix3x2.CreateTranslation(position - center); // Draw the particle. drawingSession.DrawImage(sunSurfaces[(uint)(nowFrame * slowFactor) % surfaceCount], 0, 0, bound, opcity, CanvasImageInterpolation.Linear, new Matrix4x4(transform)); } }
void DrawTile(CanvasSpriteBatch sb, int[] layer, int index) { int row = index / mapWidth; int column = index % mapWidth; Vector4 tint = Vector4.One; if (TintSprites) tint = ((row + column) % 2 == 0) ? Vector4.One : new Vector4(2, 1, 1, 1); if (ShowCollision) tint = collisionLayer[index] == 0 ? Vector4.One : new Vector4(2, 0.5f, 0.5f, 1); forestTiles.Draw(sb, layer[index], forestTiles.SpriteSize * new Vector2(column, row), tint); }
public SpriteBatchWrapper(CanvasDrawingSession drawingSession) { _spriteBatch = drawingSession.CreateSpriteBatch(CanvasSpriteSortMode.None, CanvasImageInterpolation.Linear, CanvasSpriteOptions.ClampToSourceRect); }
private void canvas_CreateResources(CanvasAnimatedControl sender, CanvasCreateResourcesEventArgs args) { args.TrackAsyncAction(LoadSpriteSheet(sender.Device).AsAsyncAction()); lvXCoordinate.SelectedIndex = 0; lvYCoordinate.SelectedIndex = 0; sldSpriteCount.Maximum = _maxSpriteCount; var defaultGridLength = new GridLength(0); var debugRowHeight = AnalyticsInfo.VersionInfo.DeviceFamily.ToLower().Contains("mobile") ? defaultGridLength : new GridLength(20); ViewModel.PropertyChanged += (s, e) => { if (e.PropertyName == "ShowDebug") { Application.Current.DebugSettings.EnableFrameRateCounter = ViewModel.ShowDebug; rowDebug.Height = ViewModel.ShowDebug ? debugRowHeight : defaultGridLength; } }; #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { ViewModel.ShowDebug = true; } #endif _debugTextFormat = new CanvasTextFormat() { HorizontalAlignment = CanvasHorizontalAlignment.Right, VerticalAlignment = CanvasVerticalAlignment.Bottom }; _debugTextColour = Colors.Black; _spriteColour = Color.FromArgb(60, 0, 0, 255); _spriteColourRunningSlowly = Color.FromArgb(60, 255, 0, 0); _fps = 0; _fpsCounter = 0; _fpsTime = TimeSpan.Zero; ViewModel.DeltaThetaInteger = 50; _theta = 0; ViewModel.SpriteCount = 315; _position = new Vector2[_maxSpriteCount]; _spriteBatchSupported = CanvasSpriteBatch.IsSupported(sender.Device); if (_spriteBatchSupported) { ViewModel.DrawModesAvailable.Add(DrawModes.SpriteBatch); _spriteRectNormal = new Rect(0, 0, 10, 10); _spriteRectRunningSlowly = new Rect(10, 0, 10, 10); } ViewModel.aInteger = 100; ViewModel.bInteger = 1; ViewModel.cInteger = 100; ViewModel.mInteger = -100; ViewModel.nInteger = 29; ViewModel.oInteger = 74; }
private void DrawSpriteBatched(CanvasSpriteBatch g, object o, Vector2 position) { var visualHint = o as IVisualHint; var orientation = visualHint?.VisualOrientation ?? Point.Zero; var m = _coords.GameToCanvasMatrix(position, orientation.IsDirection ? _radiansForDirection[orientation] : 0); g.DrawFromSpriteSheet(_spriteSheet.Image, m, _spriteSheet[visualHint?.VisualKey]); }