Exemple #1
0
 public Circle(Pixel center, Pixel anyDotOnCircle, Color color)
     : this(center, center.Distance(anyDotOnCircle), color)
 {
 }
Exemple #2
0
 public Circle(Pixel center, int radius, Color color)
     : this(center, radius)
 {
     pen = new Pen(color);
 }
Exemple #3
0
 public Circle(Pixel center, int radius)
 {
     leftUpCorner = new Pixel(center.x - radius, center.y - radius);
     width        = radius * 2;
     height       = radius * 2;
 }
Exemple #4
0
 public Circle(Pixel center, Pixel anyDotOnCircle)
     : this(center, center.Distance(anyDotOnCircle))
 {
 }
Exemple #5
0
 virtual public void Move(Pixel position)
 {
     this.position = position;
 }
        public void grow(int[,] filter)
        {
            int filterWidth  = filter.GetLength(0);
            int filterHeight = filter.GetLength(1);

            int halfWidth  = filterWidth / 2;
            int halfHeight = filterHeight / 2;

            Pixel[] newPixels = new Pixel[pixels.Length];

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    Pixel current = this[x, y];

                    if (current.r < 10 && current.g < 10 && current.b < 10)
                    {
                        int weight = 0;
                        int newR   = 0;
                        int newG   = 0;
                        int newB   = 0;

                        for (int filterX = 0; filterX < filterWidth; filterX++)
                        {
                            for (int filterY = 0; filterY < filterHeight; filterY++)
                            {
                                int curX = x - halfWidth + filterX;
                                int curY = y - halfHeight + filterY;
                                if ((curX >= 0 && curX < width) && (curY >= 0 && curY < height))
                                {
                                    Pixel next = this[curX, curY];
                                    if (next.a > 0 || next.g > 0 || next.b > 0)
                                    {
                                        newR += filter[filterX, filterY] * next.r;
                                        newG += filter[filterX, filterY] * next.g;
                                        newB += filter[filterX, filterY] * next.b;

                                        weight += filter[filterX, filterY];
                                    }
                                }
                            }
                        }
                        if (weight != 0)
                        {
                            newPixels[y * width + x] = new Pixel((byte)(newB / weight), (byte)(newG / weight), (byte)(newR / weight));
                        }
                        else
                        {
                            newPixels[y * width + x] = this[x, y];
                        }
                    }
                    else
                    {
                        newPixels[y * width + x] = this[x, y];
                    }
                }
            }

            pixels = newPixels;
        }