The following code draws an image in a certain way. I looked at trying to change that image. Although this doesn't seem directly related to the type of coding I will be doing for Project One, I still found the exercise useful in terms of getting to know coding better :)
int num = 2;
PImage flower;
void setup(){
size(600,400);
flower = loadImage("http://static.zooomr.com/images/2714989_714f130ae2.jpg");
background(0);
smooth();
frameRate(100);
}
void draw(){
int x = int (random(flower.width));
int y = int (random(flower.height));
int Pixels = x + y*flower.width;
loadPixels();
float r= red(flower.pixels[Pixels]);
float g= green(flower.pixels[Pixels]);
float b= blue(flower.pixels[Pixels]);
noStroke();
fill(r,g,b);
rect(x,y, num, num);
}
The result was an image being drawn at random with dots, to reveal the image. See below.
No comments:
Post a Comment