Skip to main content

Need help generating random shapes

3 replies [Last post]
Vagenheart
Offline
Joined: 2006-02-17

Hello, I am having a problem with Java2D. I am trying to draw random triangles on a Frame. I can get the actual shapes to show up but not in a random order and a random size. I need them to show up randomly over the Frame and with different sizes. Is there a certain method that I am missing that controls size and location? Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mgrev
Offline
Joined: 2003-08-12

What "shape" are you trying to show? [code]Shape[/code] is a generic super class and is not showable. We need more info here...

Vagenheart
Offline
Joined: 2006-02-17

sorry, I am trying to display triangles.

Vagenheart
Offline
Joined: 2006-02-17

One more thing. I am using the code
g2d.rotate(Math.random());
This code is working great but rotate makes the triangles show up randomly but in a circle. I looked through the API docs and I can't find any methods that accept the parameters I am using. Is there another way around this? Also, for controlling size, I need the triangles to show up at random sizes. I am using an array but how do I set an array with three points to random? Thanks.