Cedric wrote on Jul 28th, 2009, 1:30am:i was replying to his
solution and wondering what he did there...
But thanks for explaining!
Let me explain, i wanted to use img.get(x,y) but my x and y when converted to a whole number were 0 because i was rounding the number with an int before it was multiplied so it would always make the result be 0! that's what NoChinDeluxe explained! so i figured that if i made my x and y a noise float and then make 2 other(x2 and y2) variables equal to x and y respectively and making them int x2 = (int)x; so the number was rounded i could use the get() method. And it worked!
ill post my code and class here
if you want you can see the results in http://www.flickr.com/photos/brt-design/
here's the code
Code:import processing.pdf.*;
Bolas[] Bolases = new Bolas[100];
PImage img;
void setup(){
size(2480,3508,PDF,"Love5.pdf");
//size(800,600);
smooth();
img = loadImage("LOVE.jpg");
for (int i = 0; i < Bolases.length; i++) {
float x= random(width);
float y= random(height);
Bolases[i] = new Bolas();
}
background(255);
}
void draw(){
for (int i = 0; i < Bolases.length; i++) {
Bolases[i].desenhar();
}
if(frameCount == 300){
endRecord();
exit();
}
}
and here's the class
Code: class Bolas{
float xplus = 0.02;
float yplus = 0.02;
float xinc = random(100,200);
float yinc = random(100,200);
float xx = random(width)*xinc;
float yy = random(height)*yinc;
void desenhar(){
stroke(255);
//noStroke();
float x3 = random(xx);
//float y3 = noise(yy);
float x = noise(xx)*width;
float y = noise(yy)*height;
xx += xplus;
yy += yplus;
int x2 = (int)x;
int y2 = (int)y;
color col = img.get(x2,y2);
fill(col);
float prop = random(90,100);
//float prop = random(9,20);
ellipse(x, y, prop, prop);
println(x3);
}
}
thanks again for all the help! i wouldn't do these simple thing without it!