public override DrawingPoint AddPoint(DrawingPoint p) { Points.Add(p); Edges.Last().Point2 = p; Edges.Add(new ClippedLine(p, Points[0], Thickness, color, Clips)); return(p); }
public MidpointCircle(Vector pos, Vector point2, Color color) { this.color = color; this.Position = new DrawingPoint(pos); this.radiusUtilityPoint = new DrawingPoint(point2); updateRadius(); this.Position.PropertyChanged += Position_PropertyChanged; }
public MidpointCircle(DrawingPoint pos, double rad, Color color) { this.color = color; this.Position = pos; radiusUtilityPoint = new DrawingPoint(new Vector()); this.Radius = rad; this.Position.PropertyChanged += Position_PropertyChanged; }
public Capsule(Vector p1, Vector p2, Vector rad, Color color) { this.Point1 = new DrawingPoint(p1); this.Point2 = new DrawingPoint(p2); radiusUtilityPoint = new DrawingPoint(rad); updateRadius(); this.color = color; this.Point1.PropertyChanged += Position_PropertyChanged; this.Point2.PropertyChanged += Position_PropertyChanged; }
public Capsule(DrawingPoint p1, DrawingPoint p2, double radi, Color color) { this.Point1 = p1; this.Point2 = p2; radiusUtilityPoint = new DrawingPoint(new Vector()); this.Radius = radi; this.color = color; this.Point1.PropertyChanged += Position_PropertyChanged; this.Point2.PropertyChanged += Position_PropertyChanged; }
public DrawingRectangle(Color color, double thick, DrawingPoint p0, DrawingPoint p1) { this.color = color; Points.Add(p0); Points.Add(new DrawingPoint(new Vector(p0.X, p1.Y))); Points.Add(p1); Points.Add(new DrawingPoint(new Vector(p1.X, p0.Y))); foreach (var p in Points) { p.PropertyChanged += Position_PropertyChanged; } InitializeEdges(thick); }
private void Position_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (!(sender is DrawingPoint)) { throw new ArgumentException("Sender should be drawing point"); } DrawingPoint p = sender as DrawingPoint; int index = Points.IndexOf(p); int d = index % 2 == 0 ? 1 : -1; if (Points[(index + d + Points.Count) % Points.Count].X != p.X) { Points[(index + d + Points.Count) % Points.Count].X = p.X; } if (Points[(index - d + Points.Count) % Points.Count].Y != p.Y) { Points[(index - d + Points.Count) % Points.Count].Y = p.Y; } }
public ClippedPolygon(Color color, double thick, List <DrawingRectangle> Clips, DrawingPoint p0, params DrawingPoint[] list) : base(color, p0, list) { this.Clips = Clips; InitializeEdges(thick); }
public FilledCircle(DrawingPoint pos, double rad, Color color) : base(pos, rad, color) { }
public FloodFill(Vector p, Color c) { point = new DrawingPoint(p); color = c; }
public FloodFill(DrawingPoint p, Color c) { point = p; color = c; }
public override void Draw(byte[] RgbValues, BitmapData bmpData, bool Antialiesing) { base.Draw(RgbValues, bmpData, Antialiesing); if (!Fill) { return; } ClippedLine.Clip clip; if (Clips == null || Clips.Count() == 0) { clip = new ClippedLine.Clip() { down = int.MinValue, up = int.MaxValue, left = int.MinValue, right = int.MaxValue } } ; else { clip = Clips.Select(rec => new ClippedLine.Clip(rec)).Aggregate((a, b) => a * b); } int Ymax = (int)Math.Round(Points.Select(p => p.Y).Max()); int Ymin = (int)Math.Round(Points.Select(p => p.Y).Min()); List <LinkedList <aetElem> > et = new List <LinkedList <aetElem> >(new LinkedList <aetElem> [Ymax - Ymin + 1]); for (int i = 0; i < et.Count; i++) { et[i] = new LinkedList <aetElem>(); } for (int i = 0; i < Points.Count; i++) { DrawingPoint p1 = Points[i], p2 = Points[(i + 1) % Points.Count]; aetElem elem = new aetElem(p1, p2); et[(int)Math.Round(Math.Min(p1.Y, p2.Y)) - Ymin].AddLast(elem); } LinkedList <aetElem> aet = new LinkedList <aetElem>(); int y = Ymin; while (y <= Ymax && y <= clip.up) { foreach (var e in et[y - Ymin]) { aet.AddLast(e); } for (var i = aet.First; i != null;) { bool rm = i.Value.Ymax == y; var k = i; i = i.Next; if (rm) { aet.Remove(k); } } if (y >= clip.down) { for (var i = aet.OrderBy(e => e.x).GetEnumerator(); i.MoveNext();) { var i1 = i.Current; i.MoveNext(); var i2 = i.Current; for (int x = Math.Max((int)Math.Ceiling(i1.x), (int)Math.Ceiling(clip.left)); x <= Math.Min((int)i2.x, (int)clip.right); x++) { PutPixel(x, y, RgbValues, bmpData); } } } foreach (var e in aet) { e.x += e.mi; } y++; } }
public aetElem(DrawingPoint p1, DrawingPoint p2) { Ymax = (int)Math.Round(Math.Max(p1.Y, p2.Y)); x = p1.Y < p2.Y ? p1.X : p2.X; mi = (p2.X - p1.X) / (p2.Y - p1.Y); }
public MidpointLine(DrawingPoint p1, DrawingPoint p2, Color color) { this.Point1 = p1; this.Point2 = p2; this.color = color; }
public MidpointLine(Vector p1, Vector p2, Color color) { this.Point1 = new DrawingPoint(p1); this.Point2 = new DrawingPoint(p2); this.color = color; }