paint method

  1. @override
void paint(
  1. Canvas canvas,
  2. Size size
)
override

Called whenever the object needs to paint. The given Canvas has its coordinate space configured such that the origin is at the top left of the box. The area of the box is the size of the size argument.

Paint operations should remain inside the given area. Graphical operations outside the bounds may be silently ignored, clipped, or not clipped. It may sometimes be difficult to guarantee that a certain operation is inside the bounds (e.g., drawing a rectangle whose size is determined by user inputs). In that case, consider calling Canvas.clipRect at the beginning of paint so everything that follows will be guaranteed to only draw within the clipped area.

Implementations should be wary of correctly pairing any calls to Canvas.save/Canvas.saveLayer and Canvas.restore, otherwise all subsequent painting on this canvas may be affected, with potentially hilarious but confusing results.

To paint text on a Canvas, use a TextPainter.

To paint an image on a Canvas:

  1. Obtain an ImageStream, for example by calling ImageProvider.resolve on an AssetImage or NetworkImage object.

  2. Whenever the ImageStream's underlying ImageInfo object changes (see ImageStream.addListener), create a new instance of your custom paint delegate, giving it the new ImageInfo object.

  3. In your delegate's paint method, call the Canvas.drawImage, Canvas.drawImageRect, or Canvas.drawImageNine methods to paint the ImageInfo.image object, applying the ImageInfo.scale value to obtain the correct rendering size.

Implementation

@override
void paint(Canvas canvas, Size size) {
  final scaleX = size.width / 17.810000534355638;
  final scaleY = size.height / 20.0016780773857;
  final scale = math.min(scaleX, scaleY);

  final translationX = (size.width - 17.810000534355638 * scale) / 2 - 3.119999999999999 * scale;
  final translationY = (size.height - 20.0016780773857 * scale) / 2 - 1.9999999700893056 * scale;

  final path = Path();
  final paint = Paint()..color = color;

  path.moveTo(
    13.07 * scale + translationX,
    12.0 * scale + translationY,
  );

  path.lineTo(
    8.07 * scale + translationX,
    12.0 * scale + translationY,
  );

  path.cubicTo(
    7.517715250169207 * scale + translationX,
    12.0 * scale + translationY,
    7.07 * scale + translationX,
    12.447715250169207 * scale + translationY,
    7.07 * scale + translationX,
    13.0 * scale + translationY,
  );

  path.cubicTo(
    7.07 * scale + translationX,
    13.552284749830793 * scale + translationY,
    7.517715250169207 * scale + translationX,
    14.0 * scale + translationY,
    8.07 * scale + translationX,
    14.0 * scale + translationY,
  );

  path.lineTo(
    13.07 * scale + translationX,
    14.0 * scale + translationY,
  );

  path.cubicTo(
    13.622284749830794 * scale + translationX,
    14.0 * scale + translationY,
    14.07 * scale + translationX,
    13.552284749830793 * scale + translationY,
    14.07 * scale + translationX,
    13.0 * scale + translationY,
  );

  path.cubicTo(
    14.07 * scale + translationX,
    12.447715250169207 * scale + translationY,
    13.622284749830794 * scale + translationX,
    12.0 * scale + translationY,
    13.07 * scale + translationX,
    12.0 * scale + translationY,
  );

  path.close();

  path.moveTo(
    14.07 * scale + translationX,
    20.0 * scale + translationY,
  );

  path.lineTo(
    6.07 * scale + translationX,
    20.0 * scale + translationY,
  );

  path.cubicTo(
    5.517715250169207 * scale + translationX,
    20.0 * scale + translationY,
    5.07 * scale + translationX,
    19.552284749830793 * scale + translationY,
    5.07 * scale + translationX,
    19.0 * scale + translationY,
  );

  path.lineTo(
    5.07 * scale + translationX,
    5.0 * scale + translationY,
  );

  path.cubicTo(
    5.07 * scale + translationX,
    4.447715250169207 * scale + translationY,
    5.517715250169207 * scale + translationX,
    4.0 * scale + translationY,
    6.07 * scale + translationX,
    4.0 * scale + translationY,
  );

  path.lineTo(
    11.07 * scale + translationX,
    4.0 * scale + translationY,
  );

  path.lineTo(
    11.07 * scale + translationX,
    7.0 * scale + translationY,
  );

  path.cubicTo(
    11.0700002805336 * scale + translationX,
    8.656854527939824 * scale + translationY,
    12.41314609999511 * scale + translationX,
    10.000000347401333 * scale + translationY,
    14.07000041931868 * scale + translationX,
    10.000000298023224 * scale + translationY,
  );

  path.lineTo(
    17.07 * scale + translationX,
    10.0 * scale + translationY,
  );

  path.lineTo(
    17.07 * scale + translationX,
    11.0 * scale + translationY,
  );

  path.cubicTo(
    17.07 * scale + translationX,
    11.552284749830793 * scale + translationY,
    17.517715250169207 * scale + translationX,
    12.0 * scale + translationY,
    18.07 * scale + translationX,
    12.0 * scale + translationY,
  );

  path.cubicTo(
    18.622284749830794 * scale + translationX,
    12.0 * scale + translationY,
    19.07 * scale + translationX,
    11.552284749830793 * scale + translationY,
    19.07 * scale + translationX,
    11.0 * scale + translationY,
  );

  path.lineTo(
    19.07 * scale + translationX,
    9.0 * scale + translationY,
  );

  path.cubicTo(
    19.074335974843425 * scale + translationX,
    8.980234971979748 * scale + translationY,
    19.074335974843425 * scale + translationX,
    8.959764933310174 * scale + translationY,
    19.069999899324348 * scale + translationX,
    8.939999952803339 * scale + translationY,
  );

  path.cubicTo(
    19.06151398698795 * scale + translationX,
    8.846790349887181 * scale + translationY,
    19.03786974234464 * scale + translationX,
    8.755591120548695 * scale + translationY,
    18.99999963655027 * scale + translationX,
    8.66999983415215 * scale + translationY,
  );

  path.lineTo(
    19.0 * scale + translationX,
    8.58 * scale + translationY,
  );

  path.cubicTo(
    18.951919701029343 * scale + translationX,
    8.477180103356682 * scale + translationY,
    18.887784574264085 * scale + translationX,
    8.382665179702624 * scale + translationY,
    18.810000776327037 * scale + translationX,
    8.300000342557917 * scale + translationY,
  );

  path.lineTo(
    18.81 * scale + translationX,
    8.3 * scale + translationY,
  );

  path.lineTo(
    12.809999999999999 * scale + translationX,
    2.3000000000000007 * scale + translationY,
  );

  path.lineTo(
    12.809999999999999 * scale + translationX,
    2.3000000000000007 * scale + translationY,
  );

  path.cubicTo(
    12.725133196162615 * scale + translationX,
    2.220264824125627 * scale + translationY,
    12.626991871593598 * scale + translationX,
    2.1559653356148916 * scale + translationY,
    12.52 * scale + translationX,
    2.1100000000000003 * scale + translationY,
  );

  path.cubicTo(
    12.52 * scale + translationX,
    2.1100000000000008 * scale + translationY,
    12.469999999999999 * scale + translationX,
    2.1100000000000008 * scale + translationY,
    12.44 * scale + translationX,
    2.1100000000000008 * scale + translationY,
  );

  path.cubicTo(
    12.341453437508505 * scale + translationX,
    2.0529776656720053 * scale + translationY,
    12.232778053748403 * scale + translationX,
    2.0156205025044702 * scale + translationY,
    12.119999818741192 * scale + translationX,
    1.9999999700893056 * scale + translationY,
  );

  path.lineTo(
    6.119999999999999 * scale + translationX,
    2.0 * scale + translationY,
  );

  path.cubicTo(
    4.4631458630666465 * scale + translationX,
    2.000000010226537 * scale + translationY,
    3.1200000436051383 * scale + translationX,
    3.343145829688045 * scale + translationY,
    3.120000092983245 * scale + translationX,
    5.000000149011611 * scale + translationY,
  );

  path.lineTo(
    3.119999999999999 * scale + translationX,
    19.0 * scale + translationY,
  );

  path.cubicTo(
    3.1200000436051383 * scale + translationX,
    20.65685488556769 * scale + translationY,
    4.4631458630666465 * scale + translationX,
    22.0000007050292 * scale + translationY,
    6.120000182390211 * scale + translationX,
    22.000000655651093 * scale + translationY,
  );

  path.lineTo(
    14.12 * scale + translationX,
    22.0 * scale + translationY,
  );

  path.cubicTo(
    14.672284749830792 * scale + translationX,
    22.0 * scale + translationY,
    15.12 * scale + translationX,
    21.552284749830793 * scale + translationY,
    15.12 * scale + translationX,
    21.0 * scale + translationY,
  );

  path.cubicTo(
    15.12 * scale + translationX,
    20.447715250169207 * scale + translationY,
    14.672284749830792 * scale + translationX,
    20.0 * scale + translationY,
    14.12 * scale + translationX,
    20.0 * scale + translationY,
  );

  path.close();

  path.moveTo(
    13.07 * scale + translationX,
    5.41 * scale + translationY,
  );

  path.lineTo(
    15.65 * scale + translationX,
    8.0 * scale + translationY,
  );

  path.lineTo(
    14.07 * scale + translationX,
    8.0 * scale + translationY,
  );

  path.cubicTo(
    13.517715250169207 * scale + translationX,
    8.0 * scale + translationY,
    13.07 * scale + translationX,
    7.552284749830793 * scale + translationY,
    13.07 * scale + translationX,
    7.0 * scale + translationY,
  );

  path.close();

  path.moveTo(
    18.64 * scale + translationX,
    20.29 * scale + translationY,
  );

  path.cubicTo(
    18.592480354905323 * scale + translationX,
    20.246995035277447 * scale + translationY,
    18.542387800084718 * scale + translationX,
    20.206920991420965 * scale + translationY,
    18.490000259758396 * scale + translationX,
    20.170000283360018 * scale + translationY,
  );

  path.cubicTo(
    18.38009728598405 * scale + translationX,
    20.098568558256616 * scale + translationY,
    18.25810871649061 * scale + translationX,
    20.047739987634348 * scale + translationY,
    18.130000417844442 * scale + translationX,
    20.02000046140352 * scale + translationY,
  );

  path.cubicTo(
    17.80376404874211 * scale + translationX,
    19.954675627031264 * scale + translationY,
    17.466403754003156 * scale + translationX,
    20.05588371545295 * scale + translationY,
    17.230000000000004 * scale + translationX,
    20.29 * scale + translationY,
  );

  path.cubicTo(
    17.040687349176906 * scale + translationX,
    20.477766599905554 * scale + translationY,
    16.934201675658333 * scale + translationX,
    20.73336246362944 * scale + translationY,
    16.934201675658333 * scale + translationX,
    21.0 * scale + translationY,
  );

  path.cubicTo(
    16.934201675658333 * scale + translationX,
    21.26663753637056 * scale + translationY,
    17.040687349176906 * scale + translationX,
    21.522233400094443 * scale + translationY,
    17.230000000000004 * scale + translationX,
    21.71 * scale + translationY,
  );

  path.cubicTo(
    17.416260638525454 * scale + translationX,
    21.8947441636179 * scale + translationY,
    17.66766012261567 * scale + translationX,
    21.998895378455273 * scale + translationY,
    17.930000000000003 * scale + translationX,
    22.0 * scale + translationY,
  );

  path.cubicTo(
    18.26435562016535 * scale + translationX,
    22.001678047475007 * scale + translationY,
    18.57742696587705 * scale + translationX,
    21.83613943833811 * scale + translationY,
    18.76428511500357 * scale + translationX,
    21.558866055763275 * scale + translationY,
  );

  path.cubicTo(
    18.951143264130092 * scale + translationX,
    21.281592673188438 * scale + translationY,
    18.987060946600486 * scale + translationX,
    20.929276595345446 * scale + translationY,
    18.860000000000003 * scale + translationX,
    20.62 * scale + translationY,
  );

  path.cubicTo(
    18.8056438967546 * scale + translationX,
    20.498469146695456 * scale + translationY,
    18.73127793980233 * scale + translationX,
    20.386920211267046 * scale + translationY,
    18.6400011073894 * scale + translationX,
    20.290001205414743 * scale + translationY,
  );

  path.close();

  path.moveTo(
    13.07 * scale + translationX,
    16.0 * scale + translationY,
  );

  path.lineTo(
    8.07 * scale + translationX,
    16.0 * scale + translationY,
  );

  path.cubicTo(
    7.517715250169207 * scale + translationX,
    16.0 * scale + translationY,
    7.07 * scale + translationX,
    16.447715250169207 * scale + translationY,
    7.07 * scale + translationX,
    17.0 * scale + translationY,
  );

  path.cubicTo(
    7.07 * scale + translationX,
    17.552284749830793 * scale + translationY,
    7.517715250169207 * scale + translationX,
    18.0 * scale + translationY,
    8.07 * scale + translationX,
    18.0 * scale + translationY,
  );

  path.lineTo(
    13.07 * scale + translationX,
    18.0 * scale + translationY,
  );

  path.cubicTo(
    13.622284749830794 * scale + translationX,
    18.0 * scale + translationY,
    14.07 * scale + translationX,
    17.552284749830793 * scale + translationY,
    14.07 * scale + translationX,
    17.0 * scale + translationY,
  );

  path.cubicTo(
    14.07 * scale + translationX,
    16.447715250169207 * scale + translationY,
    13.622284749830794 * scale + translationX,
    16.0 * scale + translationY,
    13.07 * scale + translationX,
    16.0 * scale + translationY,
  );

  path.close();

  path.moveTo(
    17.93 * scale + translationX,
    13.0 * scale + translationY,
  );

  path.cubicTo(
    16.85751648790061 * scale + translationX,
    12.999312751876612 * scale + translationY,
    15.866242353894492 * scale + translationX,
    13.571201675341682 * scale + translationY,
    15.330000456869602 * scale + translationX,
    14.500000432133675 * scale + translationY,
  );

  path.cubicTo(
    15.053704233180415 * scale + translationX,
    14.980501846082186 * scale + translationY,
    15.219321710405989 * scale + translationX,
    15.594010192229884 * scale + translationY,
    15.699886415301068 * scale + translationX,
    15.87019680423855 * scale + translationY,
  );

  path.cubicTo(
    16.180451120196143 * scale + translationX,
    16.146383416247215 * scale + translationY,
    16.79392193194919 * scale + translationX,
    15.980626960317114 * scale + translationY,
    17.069999670703467 * scale + translationX,
    15.499999700990259 * scale + translationY,
  );

  path.cubicTo(
    17.31303280474799 * scale + translationX,
    15.079075140087895 * scale + translationY,
    17.82353238375804 * scale + translationX,
    14.893857906293228 * scale + translationY,
    18.279931572507884 * scale + translationX,
    15.061017896674247 * scale + translationY,
  );

  path.cubicTo(
    18.73633076125773 * scale + translationX,
    15.228177887055267 * scale + translationY,
    19.006440672063512 * scale + translationX,
    15.699299824507218 * scale + translationY,
    18.92011723096613 * scale + translationX,
    16.177620789333982 * scale + translationY,
  );

  path.cubicTo(
    18.83379378986875 * scale + translationX,
    16.655941754160747 * scale + translationY,
    18.416039231624495 * scale + translationX,
    17.002923559058548 * scale + translationY,
    17.93 * scale + translationX,
    17.0 * scale + translationY,
  );

  path.cubicTo(
    17.377715250169206 * scale + translationX,
    17.0 * scale + translationY,
    16.93 * scale + translationX,
    17.447715250169207 * scale + translationY,
    16.93 * scale + translationX,
    18.0 * scale + translationY,
  );

  path.cubicTo(
    16.93 * scale + translationX,
    18.552284749830793 * scale + translationY,
    17.377715250169206 * scale + translationX,
    19.0 * scale + translationY,
    17.93 * scale + translationX,
    19.0 * scale + translationY,
  );

  path.cubicTo(
    19.58685478384802 * scale + translationX,
    19.000000476837158 * scale + translationY,
    20.93000053435564 * scale + translationX,
    17.656854726329538 * scale + translationY,
    20.93000053435564 * scale + translationX,
    16.000000476837158 * scale + translationY,
  );

  path.cubicTo(
    20.93000053435564 * scale + translationX,
    14.343146227344779 * scale + translationY,
    19.58685478384802 * scale + translationX,
    13.000000476837158 * scale + translationY,
    17.93000053435564 * scale + translationX,
    13.000000476837158 * scale + translationY,
  );

  path.close();

  path.moveTo(
    8.07 * scale + translationX,
    10.0 * scale + translationY,
  );

  path.lineTo(
    9.07 * scale + translationX,
    10.0 * scale + translationY,
  );

  path.cubicTo(
    9.622284749830794 * scale + translationX,
    10.0 * scale + translationY,
    10.07 * scale + translationX,
    9.552284749830793 * scale + translationY,
    10.07 * scale + translationX,
    9.0 * scale + translationY,
  );

  path.cubicTo(
    10.07 * scale + translationX,
    8.447715250169207 * scale + translationY,
    9.622284749830794 * scale + translationX,
    8.0 * scale + translationY,
    9.07 * scale + translationX,
    8.0 * scale + translationY,
  );

  path.lineTo(
    8.07 * scale + translationX,
    8.0 * scale + translationY,
  );

  path.cubicTo(
    7.517715250169207 * scale + translationX,
    8.0 * scale + translationY,
    7.07 * scale + translationX,
    8.447715250169207 * scale + translationY,
    7.07 * scale + translationX,
    9.0 * scale + translationY,
  );

  path.cubicTo(
    7.07 * scale + translationX,
    9.552284749830793 * scale + translationY,
    7.517715250169207 * scale + translationX,
    10.0 * scale + translationY,
    8.07 * scale + translationX,
    10.0 * scale + translationY,
  );

  path.close();

  canvas.drawPath(path, paint);
}