Пример #1
0
        private void DoCompressed(UInt32 NumberOfPoints, BinaryReader _br, Pen p)
        {
            bool first = true;

            Point[] Points = new System.DrawingCore.Point[NumberOfPoints];
            for (int i = 0; i < NumberOfPoints; i++)
            {
                Points[i].X = _br.ReadInt16();
                Points[i].Y = _br.ReadInt16();
            }
            Point PointA = new Point();
            Point PointB = new Point();

            for (int i = 0; i < NumberOfPoints; i++)
            {
                if (first)
                {
                    PointA = Points[i];
                    first  = false;
                }
                else
                {
                    PointB = Points[i];
                    DoInstructions(PointA.X, PointB.X, PointA.Y, PointB.Y, p);
                    PointA = PointB;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Replaces the colors of a particular area:
        /// </summary>
        /// <param name="x">x</param>
        /// <param name="y">y</param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="newColor"></param>
        /// <returns></returns>
        public Rectangle FloodFill(int x, int y, Color newColor, int width = 0, int height = 0)
        {
            Color oldColor = GetPixel(x, y);

            if (ColorsEqual(oldColor, newColor))
            {
                return(Rectangle.Empty);
            }
            Rectangle editRegion = new Rectangle(x, y, width, height);

            Stack <Point> points = new Stack <Point>();

            points.Push(new Point(x, y));
            SetPixel(x, y, newColor);

            while (points.Count > 0)
            {
                Point pt = points.Pop();
                if (pt.X > 0)
                {
                    CheckFloodPoint(points, pt.X - 1, pt.Y, oldColor, newColor);
                }
                if (pt.Y > 0)
                {
                    CheckFloodPoint(points, pt.X, pt.Y - 1, oldColor, newColor);
                }
                if (pt.X < Width - 1)
                {
                    CheckFloodPoint(points, pt.X + 1, pt.Y, oldColor, newColor);
                }
                if (pt.Y < Height - 1)
                {
                    CheckFloodPoint(points, pt.X, pt.Y + 1, oldColor, newColor);
                }

                // grow the edit region:
                if (pt.X < editRegion.X)
                {
                    editRegion.Width += editRegion.X - pt.X;
                    editRegion.X      = pt.X;
                }
                else if (pt.X > editRegion.Right)
                {
                    editRegion.Width = pt.X - editRegion.X;
                }

                if (pt.Y < editRegion.Y)
                {
                    editRegion.Height += editRegion.Y - pt.Y;
                    editRegion.Y       = pt.Y;
                }
                else if (pt.Y > editRegion.Bottom)
                {
                    editRegion.Height = pt.Y - editRegion.Y;
                }
            }

            return(editRegion);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="XLinearGradientBrush"/> class.
 /// </summary>
 public XLinearGradientBrush(System.DrawingCore.Point point1, System.DrawingCore.Point point2, XColor color1, XColor color2)
     : this(new XPoint(point1), new XPoint(point2), color1, color2)
 {
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the XPoint class with the specified point.
 /// </summary>
 public XPoint(System.DrawingCore.Point point)
 {
     _x = point.X;
     _y = point.Y;
 }