void Render() { if (resized) { Resize(); resized = false; } d2dDeviceContext.BeginDraw(); d2dDeviceContext.Clear(Color4.White); d2dDeviceContext.PushAxisAlignedClip(new RectangleF(5, 5, Child.Width - 10, Child.Height - 10), AntialiasMode.Aliased); d2dDeviceContext.Transform = Matrix3x2.Translation(Child.Width / 2f / Scale + Translation.X, Child.Height / 2f / Scale + Translation.Y) * Matrix3x2.Scaling(Scale); d2dDeviceContext.AntialiasMode = AntialiasMode.Aliased; d2dDeviceContext.DrawLine(new Vector2(0, int.MinValue), new Vector2(0, int.MaxValue), RasterDrawBrush, 1 / Scale); d2dDeviceContext.DrawLine(new Vector2(int.MinValue, 0), new Vector2(int.MaxValue, 0), RasterDrawBrush, 1 / Scale); d2dDeviceContext.AntialiasMode = AntialiasMode.PerPrimitive; RenderGeometry(); d2dDeviceContext.Transform = Matrix3x2.Identity; d2dDeviceContext.PopAxisAlignedClip(); d2dDeviceContext.EndDraw(); swapChain.Present(0, PresentFlags.None); }
public void Render(DeviceContext dc) { using (SolidColorBrush BorderBrush = new SolidColorBrush(dc, Border), FillerBrush = new SolidColorBrush(dc, Filler)) { for (int i = 0; i < Path.Length - 1; i++) { var area = new Mesh(dc, new Triangle[] { new Triangle() { Point1 = new RawVector2(Path[0].X, Path[0].Y), Point2 = new RawVector2(Path[i].X, Path[i].Y), Point3 = new RawVector2(Path[i + 1].X, Path[i + 1].Y) } }); dc.FillMesh(area, FillerBrush); dc.DrawLine(new RawVector2(Path[i].X, Path[i].Y), new RawVector2(Path[i + 1].X, Path[i + 1].Y), BorderBrush, Thickness); area.Dispose(); } dc.DrawLine(new RawVector2(Path[Path.Length - 1].X, Path[Path.Length - 1].Y), new RawVector2(Path[0].X, Path[0].Y), BorderBrush, Thickness); } }
public override void Draw(Direct2D.DeviceContext renderTarget, Direct2D.Brush brush) { var lines = new[] { new [] { Points[0], Points[1] }, new [] { Points[1], Points[2] }, new [] { Points[2], Points[3] }, new [] { Points[3], Points[0] }, }; foreach (var line in lines) { renderTarget.DrawLine(line[0], line[1], brush, 2.0f); } }
public override void Draw(Direct2D.DeviceContext renderTarget, Direct2D.Brush brush) { renderTarget.DrawLine(P1, P2, brush); }
public void DrawLine(Line line, Brush brush, float strokeThickness = 1.0f) { deviceContext.DrawLine(line.P0 + line.Position.XY(), line.P1 + line.Position.XY(), brush, strokeThickness); }