glassPoly function

void glassPoly(
  1. Painter p,
  2. List<(double, double)> pts,
  3. int c,
  4. double a,
)

Fill a polygon with translucent color (true blending, no dither): glass, ice, light.

Implementation

void glassPoly(Painter p, List<(double, double)> pts, int c, double a) {
  var x0 = double.infinity;
  var y0 = double.infinity;
  var x1 = double.negativeInfinity;
  var y1 = double.negativeInfinity;
  for (final (x, y) in pts) {
    if (x < x0) x0 = x;
    if (x > x1) x1 = x;
    if (y < y0) y0 = y;
    if (y > y1) y1 = y;
  }
  for (var y = y0.floor(); y <= y1.ceil(); y++) {
    for (var x = x0.floor(); x <= x1.ceil(); x++) {
      if (inPoly(pts, x + 0.5, y + 0.5)) p.blend(x, y, c, a);
    }
  }
}