Inside() public method

Determine if a point is within this PixelMap.
public Inside ( Point p ) : bool
p Point
return bool
Beispiel #1
0
        public void Fill(SampleTri t, PixelMap map)
        {
            Point center = t.CenterPoint;

            int radius = (int)t.Samples.Max(s => dist(s.Point, center));

            for (int x = center.X - radius; x < center.X + radius; x++)
            {
                for (int y = center.Y - radius; y < center.Y + radius; y++)
                {
                    Point fillPoint = new Point(x, y);
                    double theta = Math.PI+Math.Atan2(fillPoint.Y - center.Y,fillPoint.X - center.X);
                    double distance = dist(fillPoint, center);

                    if (map.Inside(fillPoint) && distance < ShapeFunction(theta)*radius)
                    {
                        map[fillPoint] = t.CenterColor;

                        //map[fillPoint] = new Pixel(theta*180/Math.PI,0.5,0.5);
                    }

                    if (distance > 1000)
                    {
                        Console.WriteLine("wat");
                    }
                }
            }
        }
Beispiel #2
0
        private double[,] sobelPass(PixelMap map, double[,] kernel)
        {
            double[,] output = new double[map.Width, map.Height];

            for (int x = 0; x < map.Width; x++)
            {
                for (int y = 0; y < map.Height; y++)
                {
                    double sum = 0;
                    for (int u = 0; u < 3; u++)
                    {
                        for (int v = 0; v < 3; v++)
                        {
                            Point samplePoint = new Point(x - 1 + u, y - 1 + v);

                            if (map.Inside(samplePoint))
                            {
                                double kVal = kernel[u, v];
                                double imgVal = map[samplePoint].Lightness;

                                sum += kVal * imgVal;
                            }
                            else
                            {
                                sum += 0.5;
                            }
                        }
                    }
                    output[x, y] = sum;
                }
            }
            return output;
        }