protected override void OnRender(DrawingContext ctx) { ctx.FillRectangle(Brushes.Green, new Rect(0, 0, Width, Height)); var rc = new Rect(0, 0, Width/3, Height/3); using (ctx.PushPostTransform( Perspex.Matrix.CreateTranslation(-Width/6, -Width/6)* Perspex.Matrix.CreateRotation(_radians)* Perspex.Matrix.CreateTranslation(Width/2, Height/2))) { ctx.FillRectangle(new LinearGradientBrush() { GradientStops = { new GradientStop() {Color = Colors.Blue}, new GradientStop(Colors.Red, 1) } }, rc, 5); } }
private void DrawRoundRect(DrawingContext ctx) { ctx.FillRectangle(new SolidColorBrush(Colors.White), new Rect(new Size(ClientSize.Width, ClientSize.Height))); var rc = new Rect(0, 0, 60, 60); var transform = GetTransform(); using (ctx.PushPostTransform(transform)) { ctx.FillRectangle(new SolidColorBrush(Colors.Aqua), rc, 20); ctx.DrawRectangle(new Pen(new SolidColorBrush(Colors.Magenta), 10), rc, 20); } }