0

I'm trying to draw a polygon using a CustomPainter, this is working fine. Then I would like to draw a 2nd polygon identical to the first underneath it but X times the size. Currently I am transforming the path like:

polygon1 = new Path();
polygon1.addPolygon(polygonPoints, true);

double scale = 1.5;
Matrix4 matrix4 = Matrix4.identity()
    ..scale(scale,scale,0);
Path polygon2 = Path.from(polygon1)
    ..transform(matrix4.storage);

However, it seems that polygon2 is also translated which is undesired. I would like it to be perfectly behind the polygon1.

How do I achieve this?

Pictures for reference:

Polygon 1 (green) and Polygon 2 (orange) far away from (0,0) and NOT aligned

enter image description here

Polygon 1 (green) and Polygon 2 (orange) at ~ (0,0) and aligned

enter image description here

1 Answers1

0

I managed to centre the scaled polygon2 by normalizing polygon1 w.r.t. point 0, then scaling the path as above, and finally shifting both paths using the Offset from point 0. Furthermore, the polygon2 needs to be shifted w.r.t to the polygon1 and for this I used polygon1's Rect parameter bottomCenter.