We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Points to Array within shape
Page Index Toggle Pages: 1
Points to Array within shape (Read 386 times)
Points to Array within shape
Feb 23rd, 2009, 3:23pm
 
hey guys,
please bear with me for I am a little noob in a big processing world.

I have a bunch of points, which I got from finding pixels that are a certain color, so I can distinguish points within that shape.

Code:

for(int x = 0; x < width; x+=xspace) {
for(int y=0; y<height; y+=yspace) {
if(get(x,y) == pink) {
// draw my object on random points


this works to obtain the points, if I draw an ellipse on the x y points i get all the points I want within the shape.  However, my problem arrises when I try to draw my object on random points within that shape.  The only way I can think to do this is to place the points on a 2D array (for x and y) and then pick random spots in that array to draw the object.  But, Im not sure how to construct my array because I dont know my total x and y points, or how to add them exactly.

Thanks a whole lot for listening.
Re: Points to Array within shape
Reply #1 - Feb 23rd, 2009, 3:29pm
 
> But, Im not sure how to construct my array because I dont know my total x and y points, or how to add them exactly.

ArrayList.

http://java.sun.com/j2se/1.4.2/docs/api/java/util/ArrayList.html

basically it's an array you can add things to. so you don't need to know the initial size.
Re: Points to Array within shape
Reply #2 - Feb 25th, 2009, 5:02pm
 
Thats what I needed to hear

Thank you for your post koogs
Page Index Toggle Pages: 1