fillTopDownGradient method

  1. @override
void fillTopDownGradient(
  1. num x,
  2. num y,
  3. num width,
  4. num height,
  5. PColor colorFrom,
  6. PColor colorTo,
)
override

Fill a rectangle (x,y , width x height) with a top down linear gradient. See fillBottomUpGradient.

Implementation

@override
void fillTopDownGradient(
    num x, num y, num width, num height, PColor colorFrom, PColor colorTo) {
  x = transform.x(x);
  y = transform.y(y);

  var grd = _ctx.createLinearGradient(x, y, x, y + height);
  grd.addColorStop(0, colorFrom.toString());
  grd.addColorStop(1, colorTo.toString());

  _setFillStyleGradient(grd);
  _ctx.fillRect(x, y, x + width, y + height);
}