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); } }
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); } }