0

I have a class that extends CustomPainter, which helps me to draw an image on the canvas (with canvas.drawImage) and plot some points (with canvas.drawLine and canvas.drawPath) on top of the image. However, I have trouble figuring out how to scale or translate the image so that it fills / covers the canvas (about 60% of the image from the center should be displayed within the screen size of the device). The image can be bigger or smaller than the device's screen size, but they all have a fixed aspect ratio (4:3). I would like to fill the image on the canvas (following the 60% rule above) and scaling them according to their original aspect ratio.

A pseudocode or a general idea on how to do this would be appreciated.

yshean
  • 331
  • 3
  • 9
  • 1
    I assume you are using custom paint. The points you specify are baded on the size that you pass from the widget tree. So if you wish to have it at 60% make vecotr points based on that and send full screen width. – Kaushik Chandru Jul 19 '22 at 03:46
  • I'm afraid I don't understand your approach very much. Do you have a formula to calculate the vector points you mentioned? – yshean Jul 19 '22 at 03:55
  • Can you add an image of the path you are looking to create? There is no formula. Its similar to plotting points on graph. If you have an svg there are some online tools to create path too – Kaushik Chandru Jul 19 '22 at 04:04

0 Answers0