Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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;
            }
        }
Exemplo n.º 8
0
 public ClippedPolygon(Color color, double thick, List <DrawingRectangle> Clips, DrawingPoint p0, params DrawingPoint[] list) :
     base(color, p0, list)
 {
     this.Clips = Clips;
     InitializeEdges(thick);
 }
Exemplo n.º 9
0
 public FilledCircle(DrawingPoint pos, double rad, Color color) : base(pos, rad, color)
 {
 }
Exemplo n.º 10
0
 public FloodFill(Vector p, Color c)
 {
     point = new DrawingPoint(p);
     color = c;
 }
Exemplo n.º 11
0
 public FloodFill(DrawingPoint p, Color c)
 {
     point = p;
     color = c;
 }
Exemplo n.º 12
0
        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++;
            }
        }
Exemplo n.º 13
0
 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);
 }
Exemplo n.º 14
0
 public MidpointLine(DrawingPoint p1, DrawingPoint p2, Color color)
 {
     this.Point1 = p1;
     this.Point2 = p2;
     this.color  = color;
 }
Exemplo n.º 15
0
 public MidpointLine(Vector p1, Vector p2, Color color)
 {
     this.Point1 = new DrawingPoint(p1);
     this.Point2 = new DrawingPoint(p2);
     this.color  = color;
 }