How do you scale up the size of a polygon?

364 Views Asked by At

I'm new to java and I want to change the size of my polygon while maintaining the aspect ratio. How do I scale up my shape without needing to change all the vertices manually 1 by 1? I would like to just say something like gc.scale(10); and it makes the polygon 10x better.

    public void draw(GraphicsContext gc) {


        double[] xVertices = {0.0,  0.0, 10.0,  10.0,  20.0, 20.0, 30.0,  30.0,  40.0, 40.0, 50.0,  50.0,  60.0, 60.0, 70.0, 70.0};
        double[] yVertices = {0.0, 10.0, 10.0, 100.0, 100.0, 90.0, 90.0, 100.0, 100.0, 90.0, 90.0, 100.0, 100.0, 10.0, 10.0,  0.0};


        gc.setFill(color);
        gc.translate(x, y);
        gc.rotate(180);
        gc.fillPolygon(xVertices, yVertices, 16);

    }
0

There are 0 best solutions below