protected override void DrawInternal(IRenderContext2D context, IEnumerable<Point> centers, IPen2D pen, IBrush2D brush) { double halfWidth = Width / 2; double halfHeight = Height / 2; foreach (var center in centers) { double top = center.Y - halfHeight; double bottom = center.Y + halfHeight; double left = center.X - halfWidth; double right = center.X + halfWidth; // x0 // //x1 x2 var points = new[] { new Point(right,top), new Point(right,bottom), new Point(left,bottom), new Point(right,top) }; context.FillPolygon(brush, points); context.DrawLines(pen, points); } }
private void DrawDiamond(IRenderContext2D context, Point center, double width, double height, IPen2D stroke, IBrush2D fill) { double top = center.Y - height; double bottom = center.Y + height; double left = center.X - width; double right = center.X + width; var diamondPoints = new[] { // Points drawn like this: // // x0 (x4 in same location as x0) // // x3 x1 // // x2 new Point(center.X, top), new Point(right, center.Y), new Point(center.X, bottom), new Point(left, center.Y), new Point(center.X, top), }; context.FillPolygon(fill, diamondPoints); context.DrawLines(stroke, diamondPoints); }
protected override void DrawInternal(IRenderContext2D context, IEnumerable<Point> centers, IPen2D pen, IBrush2D brush) { float width2 = (float)(Width * 0.5); float height2 = (float)(Height * 0.5); foreach (var center in centers) { double top = center.Y - height2; double bottom = center.Y + height2; double left = center.X - width2; double right = center.X + width2; var diamondPoints = new[] { // Points drawn like this: // // x0 (x4 in same location as x0) // // x3 x1 // // x2 new Point(center.X, top), // x0 new Point(right, center.Y), // x1 new Point(center.X, bottom), // x2 new Point(left, center.Y), // x3 new Point(center.X, top), // x4 == x0 }; context.FillPolygon(brush, diamondPoints); context.DrawLines(pen, diamondPoints); } }
protected override void RenderToCache(IRenderContext2D context, IPen2D strokePen, IBrush2D fillBrush) { var offset = 2d; var polygon = new Point[] { new Point(Width / 2, 0), new Point(Width / 2 + offset, Height / 2 - offset), new Point(Width, Height / 2), new Point(Width / 2 + offset, Height / 2 + offset), new Point(Width / 2, Height), new Point(Width / 2 - offset, Height / 2 + offset), new Point(0, Height / 2), new Point(Width / 2 - offset, Height / 2 - offset), new Point(Width / 2, 0) }; context.FillPolygon(fillBrush, polygon); context.DrawLines(strokePen, polygon); }
public override void Draw(IRenderContext2D context, IEnumerable <Point> centers) { var fill = context.CreateBrush(Fill); var stroke = context.CreatePen(Stroke, AntiAliasing, (float)StrokeThickness); float width2 = (float)(Width * 0.5); float height2 = (float)(Height * 0.5); foreach (var center in centers) { double top = center.Y - height2; double bottom = center.Y + height2; double left = center.X - width2; double right = center.X + width2; var diamondPoints = new[] { // Points drawn like this: // // x0 (x4 in same location as x0) // // x3 x1 // // x2 new Point(center.X, top), // x0 new Point(right, center.Y), // x1 new Point(center.X, bottom), // x2 new Point(left, center.Y), // x3 new Point(center.X, top), // x4 == x0 }; context.FillPolygon(fill, diamondPoints); context.DrawLines(stroke, diamondPoints); } }