public void DrawRoundedRectangle(Point start, double width, double height, double radius, bool strokeAndFill) { double x, y; x = start.X + LineWidth / 2; y = start.Y + LineWidth / 2; height -= LineWidth; width -= LineWidth; if ((radius > height / 2) || (radius > width / 2)) { radius = Math.Min(height / 2, width / 2); } CContext.MoveTo(x, y + radius); CContext.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2); CContext.LineTo(x + width - radius, y); CContext.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0); CContext.LineTo(x + width, y + height - radius); CContext.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2); CContext.LineTo(x + radius, y + height); CContext.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI); CContext.ClosePath(); if (strokeAndFill) { StrokeAndFill(); } }
public void DrawTriangle(Point corner, double width, double height, SelectionPosition position) { double x1, y1, x2, y2, x3, y3; x1 = corner.X; y1 = corner.Y; switch (position) { case SelectionPosition.Top: x2 = x1 + width / 2; y2 = y1 + height; x3 = x1 - width / 2; y3 = y1 + height; break; case SelectionPosition.Bottom: default: x2 = x1 + width / 2; y2 = y1 - height; x3 = x1 - width / 2; y3 = y1 - height; break; } SetColor(StrokeColor); CContext.MoveTo(x1, y1); CContext.LineTo(x2, y2); CContext.LineTo(x3, y3); CContext.ClosePath(); StrokeAndFill(); }
public void DrawArea(params Point [] vertices) { double x1, y1; Point initial_point = vertices [0]; CContext.MoveTo(initial_point.X, initial_point.Y); for (int i = 1; i < vertices.Length; i++) { x1 = vertices [i].X; y1 = vertices [i].Y; CContext.LineTo(x1, y1); } CContext.ClosePath(); StrokeAndFill(); }
public void DrawArea(params Point[] vertices) { for (int i = 0; i < vertices.Length - 1; i++) { double x1, y1, x2, y2; x1 = vertices [i].X; y1 = vertices [i].Y; x2 = vertices [i + 1].X; y2 = vertices [i + 1].Y; CContext.MoveTo(x1, y1); CContext.LineTo(x2, y2); } CContext.ClosePath(); StrokeAndFill(); }
public void ClipRoundRectangle(Point start, double width, double height, double radius) { double x, y; x = start.X; y = start.Y; if ((radius > height / 2) || (radius > width / 2)) { radius = Math.Min(height / 2, width / 2); } CContext.MoveTo(x, y + radius); CContext.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2); CContext.LineTo(x + width - radius, y); CContext.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0); CContext.LineTo(x + width, y + height - radius); CContext.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2); CContext.LineTo(x + radius, y + height); CContext.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI); CContext.ClosePath(); CContext.Clip(); }
public void DrawArrow(Point start, Point stop, int lenght, double radians, bool closed) { double vx1, vy1, vx2, vy2; double angle = Math.Atan2(stop.Y - start.Y, stop.X - start.X) + Math.PI; vx1 = stop.X + (lenght + LineWidth) * Math.Cos(angle - radians); vy1 = stop.Y + (lenght + LineWidth) * Math.Sin(angle - radians); vx2 = stop.X + (lenght + LineWidth) * Math.Cos(angle + radians); vy2 = stop.Y + (lenght + LineWidth) * Math.Sin(angle + radians); CContext.MoveTo(stop.X, stop.Y); CContext.LineTo(vx1, vy1); if (!closed) { CContext.MoveTo(stop.X, stop.Y); CContext.LineTo(vx2, vy2); } else { CContext.LineTo(vx2, vy2); CContext.ClosePath(); } StrokeAndFill(false); }