Rotate a polygon?

I want to draw a triangle with the peak of the triangle centered over the center of the base of a triangle. The documentation for polygon doesn’t show how to rotate the polygon. Is it not possible? It’s important for creating a Christmas tree in Unit 4 lesson 1-4. Thanks, jr

The polygon does not have any ability to be rotated, but you could use drawShape with an array of point coordinates.

Got it. That’s what I figured, just checking. jr

Could you show me the syntax of the drawShape method? Would the array of points be two consecutive integers are a point?

drawShape({0,0,50,50,0,50},true) would draw at (0,0) (50,50) , (0,50)?

That is correct.

This code:

import org.code.theater.*;

public class MyTheater {
  public static void main(String[] args) {
    Scene myScene = new Scene();
    
    myScene.drawShape(new int[]{0,0,50,50,0,50},true);

    Theater.playScenes(myScene);
  }
}

Creates this picture:

1 Like