/// <summary>Function called to render the sprite data.</summary> /// <returns>The presentation interval to use when rendering.</returns> protected override int OnRender() { var spriteRegion = SpriteContent.Texture.ToPixel(GetSpriteTextureCoordinates()).ToRectangleF(); var imageRegion = new DX.RectangleF(0, 0, SpriteContent.Texture.Width, SpriteContent.Texture.Height); SwapChain.RenderTargetView.Clear(BackgroundColor); if (IsAnimating) { RenderSpriteTextureWithoutSprite(imageRegion, spriteRegion); } else { Graphics.SetRenderTarget(SwapChain.RenderTargetView); } RenderToRtv(); Renderer.Begin(); // Draw the pattern layer. Renderer.DrawFilledRectangle(new DX.RectangleF(0, 0, SwapChain.Width, SwapChain.Height), new GorgonColor(GorgonColor.Gray75, (0.5f - TextureAlpha.Min(0.5f).Max(0)) * 2), BackgroundPattern, new DX.RectangleF(0, 0, SwapChain.Width / BackgroundPattern.Width, SwapChain.Height / BackgroundPattern.Height)); if (IsAnimating) { RenderRect(imageRegion, new GorgonColor(GorgonColor.White, TextureAlpha * 2), BackgroundPattern, new DX.RectangleF(0, 0, (imageRegion.Width * ZoomScaleValue) / BackgroundPattern.Width, (imageRegion.Height * ZoomScaleValue) / BackgroundPattern.Height)); } RenderRect(spriteRegion, GorgonColor.White, BackgroundPattern, new DX.RectangleF(0, 0, (spriteRegion.Width * ZoomScaleValue) / BackgroundPattern.Width, (spriteRegion.Height * ZoomScaleValue) / BackgroundPattern.Height)); if (IsAnimating) { Renderer.DrawFilledRectangle(new DX.RectangleF(0, 0, SwapChain.Width, SwapChain.Height), new GorgonColor(GorgonColor.White, TextureAlpha), ImageBufferTexture, new DX.RectangleF(0, 0, 1, 1)); } // Draw the sprite layer. RenderRect(new DX.RectangleF(spriteRegion.Left, spriteRegion.Top, _rtv.Width, _rtv.Height), GorgonColor.White, _srv, new DX.RectangleF(-1.0f, -1.0f, 3.0f, 3.0f), sampler: _current); Renderer.End(); return(1); }
/// <summary>Function called to render the sprite data.</summary> /// <returns>The presentation interval to use when rendering.</returns> protected override int OnRender() { var spriteRegion = SpriteContent.Texture.ToPixel(SpriteContent.TextureCoordinates).ToRectangleF(); var imageRegion = new DX.RectangleF(0, 0, SpriteContent.Texture.Width, SpriteContent.Texture.Height); RenderSpriteTextureWithoutSprite(imageRegion, spriteRegion); SwapChain.RenderTargetView.Clear(BackgroundColor); Renderer.Begin(); // Draw the pattern layer. Renderer.DrawFilledRectangle(new DX.RectangleF(0, 0, SwapChain.Width, SwapChain.Height), new GorgonColor(GorgonColor.White, (0.5f - TextureAlpha.Min(0.5f).Max(0)) * 2), BackgroundPattern, new DX.RectangleF(0, 0, SwapChain.Width / BackgroundPattern.Width, SwapChain.Height / BackgroundPattern.Height)); if (IsAnimating) { RenderRect(imageRegion, new GorgonColor(GorgonColor.White, TextureAlpha * 2), BackgroundPattern, new DX.RectangleF(0, 0, (imageRegion.Width * ZoomScaleValue) / BackgroundPattern.Width, (imageRegion.Height * ZoomScaleValue) / BackgroundPattern.Height)); Renderer.DrawFilledRectangle(new DX.RectangleF(0, 0, SwapChain.Width, SwapChain.Height), new GorgonColor(GorgonColor.White, TextureAlpha), ImageBufferTexture, new DX.RectangleF(0, 0, 1, 1)); } if ((SpriteContent.ManualVertexEditor != null) && (SpriteContent.ManualVertexEditor.IsActive) && (SpriteContent.ManualVertexEditor.IsMoving)) { DrawDockRect(); } Renderer.End(); // TODO: We have warping due to affine texture mapping. We need a perspective correct camera to do this properly, but currently the only // perspective camera in Gorgon's 2D renderer is not really meant for this purpose. Renderer.Begin(camera: _camera); // Draw the sprite layer. Renderer.DrawSprite(_workingSprite); Renderer.End(); Renderer.Begin(); _vertexEditor.Render(); Renderer.End(); return(_vertexEditor.IsDragging ? 0 : 1); }
/// <summary>Function called to render the sprite data.</summary> /// <returns>The presentation interval to use when rendering.</returns> protected override int OnRender() { var spriteRegion = SpriteContent.Texture.ToPixel(SpriteContent.TextureCoordinates).ToRectangleF(); var imageRegion = new DX.RectangleF(0, 0, SpriteContent.Texture.Width, SpriteContent.Texture.Height); RenderSpriteTextureWithoutSprite(imageRegion, spriteRegion); SwapChain.RenderTargetView.Clear(BackgroundColor); Renderer.Begin(); if (IsAnimating) { // Draw the pattern layer. Renderer.DrawFilledRectangle(new DX.RectangleF(0, 0, SwapChain.Width, SwapChain.Height), new GorgonColor(GorgonColor.White, (0.5f - TextureAlpha.Min(0.5f).Max(0)) * 2), BackgroundPattern, new DX.RectangleF(0, 0, SwapChain.Width / BackgroundPattern.Width, SwapChain.Height / BackgroundPattern.Height)); RenderRect(imageRegion, new GorgonColor(GorgonColor.White, TextureAlpha * 2), BackgroundPattern, new DX.RectangleF(0, 0, (imageRegion.Width * ZoomScaleValue) / BackgroundPattern.Width, (imageRegion.Height * ZoomScaleValue) / BackgroundPattern.Height)); RenderRect(spriteRegion, GorgonColor.White, BackgroundPattern, new DX.RectangleF(0, 0, (spriteRegion.Width * ZoomScaleValue) / BackgroundPattern.Width, (spriteRegion.Height * ZoomScaleValue) / BackgroundPattern.Height)); } else { // Draw the pattern layer. RenderRect(imageRegion, GorgonColor.White, BackgroundPattern, new DX.RectangleF(0, 0, (imageRegion.Width * ZoomScaleValue) / BackgroundPattern.Width, (imageRegion.Height * ZoomScaleValue) / BackgroundPattern.Height)); } // Draw the image buffer layer. Renderer.DrawFilledRectangle(new DX.RectangleF(0, 0, SwapChain.Width, SwapChain.Height), new GorgonColor(GorgonColor.White, TextureAlpha), ImageBufferTexture, new DX.RectangleF(0, 0, 1, 1)); // Draw the sprite layer. Renderer.DrawSprite(_workingSprite); // Draw an indicator for the anchor. DX.Vector2 anchorPos = ToClient(new DX.Vector2(SpriteContent.Anchor.X * spriteRegion.Width + spriteRegion.Left, SpriteContent.Anchor.Y * spriteRegion.Height + spriteRegion.Top)).Truncate(); Renderer.DrawEllipse(new DX.RectangleF(anchorPos.X - 4, anchorPos.Y - 4, 8, 8), GorgonColor.Black); Renderer.DrawEllipse(new DX.RectangleF(anchorPos.X - 3, anchorPos.Y - 3, 6, 6), GorgonColor.White); // We convert to integer first so we can clip the decimal places. _marchAnts.Draw(Renderer.MeasureSprite(_workingSprite).Truncate()); Renderer.End(); return(1); }