public Dot[] FillPolygon(PointF[] pts, RGB rgb) { PointF minPt, maxPt; minPt = getMin(pts); maxPt = getMax(pts); float width = maxPt.X - minPt.X; float height = maxPt.Y - minPt.Y; using (var bmp = createBitmap(width, height)) { using (var gc = craeteGraphics(bmp, SmoothingMode.AntiAlias)) { var brush = new SolidBrush(rgb.ToColor()); var newPts = new List <PointF>(); foreach (var pt in pts) { newPts.Add(new PointF(pt.X - minPt.X, pt.Y - minPt.Y)); } gc.FillPolygon(brush, newPts.ToArray()); } return(GetPixel(bmp, minPt)); } }
public Dot[] Circle(double x, double y, double w, double h, RGB rgb) { using (var bmp = createBitmap(w, h)) { using (var gc = craeteGraphics(bmp, SmoothingMode.HighSpeed)) { var pen = new Pen(rgb.ToColor(), 1f); gc.DrawEllipse(pen, 0f, 0f, (float)w, (float)h); } return(GetPixel(bmp, new PointF((float)x, (float)y))); } }
public Dot[] Rectangle(RectangleF rect, RGB rgb) { using (var bmp = createBitmap(rect.Width, rect.Height)) { using (var gc = craeteGraphics(bmp, SmoothingMode.None)) { var pen = new Pen(rgb.ToColor()); gc.DrawRectangle(pen, 0f, 0f, rect.Width, rect.Height); } return(GetPixel(bmp, new PointF(rect.X, rect.Y))); } }
public Dot[] CircleCenterAt(double x, double y, double w, double h, RGB rgb) { using (var bmp = createBitmap(w, h)) { using (var gc = craeteGraphics(bmp, SmoothingMode.AntiAlias)) { var pen = new Pen(rgb.ToColor(), 1f); gc.DrawEllipse(pen, 0f, 0f, (float)w, (float)h); // gc.DrawEllipse(pen, (float)(x - w/2), (float)(y - h/2), (float)w, (float)h); } return(GetPixel(bmp, new PointF((float)(x - w / 2), (float)(y - h / 2)))); } }
public Dot[] Line(PointF pt1, PointF pt2, RGB rgb, float penwidth) { float x, y, width, height; x = Math.Min(pt1.X, pt2.X); y = Math.Min(pt1.Y, pt2.Y); width = Math.Max(pt1.X, pt2.X) - x; height = Math.Max(pt1.Y, pt2.Y) - y; using (var bmp = createBitmap(width + penwidth, height + penwidth)) { using (var gc = craeteGraphics(bmp, SmoothingMode.AntiAlias)) { var pen = new Pen(rgb.ToColor(), penwidth); gc.DrawLine(pen, pt1.X - x + penwidth / 2, pt1.Y - y + penwidth / 2, pt2.X - x + penwidth / 2, pt2.Y - y + penwidth / 2); } return(GetPixel(bmp, new PointF(x + penwidth / 2, y + penwidth / 2))); } }