drawFilledPath2 method

void drawFilledPath2(
  1. Canvas c,
  2. Path filledPath,
  3. int fillColor,
  4. int fillAlpha,
)

Draws the provided path in filled mode with the provided drawable.

@param c @param filledPath @param drawable Draws the provided path in filled mode with the provided color and alpha. Special thanks to Angelo Suzuki (https://github.com/tinsukE) for this.

@param c @param filledPath @param fillColor @param fillAlpha

Implementation

//  void drawFilledPath1(Canvas c, Path filledPath, ui.Image drawable) {
//    if (clipPathSupported()) {
//      c.save();
//      c.clipPath(filledPath);
//      drawable.setBounds((int) mViewPortHandler.contentLeft(),
//    (int) mViewPortHandler.contentTop(),
//    (int) mViewPortHandler.contentRight(),
//    (int) mViewPortHandler.contentBottom());
//    drawable.draw(c);
//      c.drawImage(drawable, Offset(0, 0), drawPaint);
//
//      c.restore();
//    }
//    else {
//    throw Exception("Fill-drawables not (yet) supported below API level 18, " +
//    "this code was run on API level " + Utils.getSDKInt() + ".");
//    }
//  }

/// Draws the provided path in filled mode with the provided color and alpha.
/// Special thanks to Angelo Suzuki (https://github.com/tinsukE) for this.
///
/// @param c
/// @param filledPath
/// @param fillColor
/// @param fillAlpha
void drawFilledPath2(
    Canvas c, Path filledPath, int fillColor, int fillAlpha) {
  int color = (fillAlpha << 24) | (fillColor & 0xffffff);

//    if (clipPathSupported()) {
//      c.save();
//      c.clipPath(filledPath);
//      c.drawColor(Color(color), BlendMode.srcOver);
//      c.restore();
//    } else {
  // save
  var previous = renderPaint!.style;
  Color previousColor = renderPaint!.color;

  // set
  renderPaint
    ?..style = PaintingStyle.fill
    ..color = Color(color);

  c.drawPath(filledPath, renderPaint!);

  // restore
  renderPaint
    ?..style = previous
    ..color = previousColor;
//    }
}