Beispiel #1
0
 public void Scan(Scanner scanner, Rectangle clip)
 {
     Point2D center = (Point2D)Position.Round();
     scanner.yMin = center.Y - (int)Radii.Y;
     scanner.yMax = center.Y + (int)Radii.Y;
     //clip to clip, but with leeway
     if(scanner.yMin < clip.Min.Y - 1) scanner.yMin = clip.Min.Y - 1;
     if(scanner.yMax > clip.Max.Y + 1) scanner.yMax = clip.Max.Y + 1;
     for(int y = scanner.yMin; y <= scanner.yMax; y++)
     {
         double dy = center.Y - y;
         double dx = Math.Sqrt(1 - (dy * dy) / (Radii.Y * Radii.Y)) * Radii.X;
         scanner[y] = new Scanner.Scan{min = center.X - (float)dx, max = center.X + (float)dx};
     }
     //true clip
     if(scanner.yMin < clip.Min.Y)
     {
         scanner.yMin = clip.Min.Y;
         scanner.isYMinClipped = true;
     }
     if(scanner.yMax > clip.Max.Y)
     {
         scanner.yMax = clip.Max.Y;
         scanner.isYMaxClipped = true;
     }
 }
 public void Scan(Scanner scanner, Rectangle clip)
 {
     scanner.yMin = Rect.Min.Y;
     scanner.yMax = Rect.Max.Y;
     //clip to clip, but with leeway
     if(scanner.yMin < clip.Min.Y - 1) scanner.yMin = clip.Min.Y - 1;
     if(scanner.yMax > clip.Max.Y + 1) scanner.yMax = clip.Max.Y + 1;
     for(int y = scanner.yMin; y <= scanner.yMax; y++)
     {
         if(y < Rect.Min.Y + Radii.Y)
         {
             double dy = (Rect.Min.Y + Radii.Y) - y;
             double dx = Math.Sqrt(1 - (dy * dy) / (Radii.Y * Radii.Y)) * Radii.X;
             dx -= Radii.X;
             scanner[y] = new Scanner.Scan{min = Rect.Min.X - (float)dx, max = Rect.Max.X + (float)dx};
         }else
         if(y > Rect.Max.Y - Radii.Y)
         {
             double dy = y - (Rect.Max.Y - Radii.Y);
             double dx = Math.Sqrt(1 - (dy * dy) / (Radii.Y * Radii.Y)) * Radii.X;
             dx -= Radii.X;
             scanner[y] = new Scanner.Scan{min = Rect.Min.X - (float)dx, max = Rect.Max.X + (float)dx};
         }else
         {
             scanner[y] = new Scanner.Scan{min = Rect.Min.X, max = Rect.Max.X};
         }
     }
     //true clip
     if(scanner.yMin < clip.Min.Y)
     {
         scanner.yMin = clip.Min.Y;
         scanner.isYMinClipped = true;
     }
     if(scanner.yMax > clip.Max.Y)
     {
         scanner.yMax = clip.Max.Y;
         scanner.isYMaxClipped = true;
     }
 }
Beispiel #3
0
 public void Scan(Scanner scanner, Rectangle clip)
 {
     scanner.yMin = int.MaxValue;
     scanner.yMax = int.MinValue;
     for(int i = 0; i < Vertices.Length; i++)
     {
         scanner.yMin = Math.Min(scanner.yMin, (int)Vertices[i].Y);
         scanner.yMax = Math.Max(scanner.yMax, (int)Vertices[i].Y);
     }
     //clip to clip, but with leeway
     if(scanner.yMin < clip.Min.Y - 1) scanner.yMin = clip.Min.Y - 1;
     if(scanner.yMax > clip.Max.Y + 1) scanner.yMax = clip.Max.Y + 1;
     for(int y = scanner.yMin; y <= scanner.yMax; y++)
     {
         scanner[y] = new Scanner.Scan{min = float.PositiveInfinity, max = float.NegativeInfinity};
     }
     for(int i = 0; i < Vertices.Length; i++)
     {
         ScanLine(scanner, Vertices[i], Vertices[(i + 1) % Vertices.Length]);
     }
     //true clip
     if(scanner.yMin < clip.Min.Y)
     {
         scanner.yMin = clip.Min.Y;
         scanner.isYMinClipped = true;
     }
     if(scanner.yMax > clip.Max.Y)
     {
         scanner.yMax = clip.Max.Y;
         scanner.isYMaxClipped = true;
     }
 }