This site requires JavaScript, please enable it in your browser!
Greenfoot back
amber_757
amber_757 wrote ...

2015/3/17

Triangles in the corners of the screen

amber_757 amber_757

2015/3/17

#
hey so I'm having trouble getting triangles in all four corners of the screen and this is what i have for the top left corner of the screen (the x for the picture is 1024 and the y is 1280)
for (int x = 0; x<=90 ; x++)
        {
            for (int y=0 ;y<=90-x ; y++)
            {

                bg.setColorAt(x,y,Color.RED);
            }
        }
danpost danpost

2015/3/17

#
Easier would be to use the 'fillPolygon' method:
bg.setColor(Color.RED);
bg.fillPolygon(new int[] { 0, 90, 0 }, new int[] { 0, 0, 90 }, 3);
The first set of integers are the x-coordinates of the three points of the triangle (polygon) and the second set are the y-coordinates. The coordinates of each point are at the same index within the two arrays. So, here the points are ( 0, 0 ), ( 90, 0 ) and ( 0, 90 ). Do the same using the coordinates of the 3 points for each corner.
You need to login to post a reply.