GSDP:GAM100/CProcessing/noise()
From Inside
< GSDP:GAM100 | CProcessing
noise()
Description
Returns a smooth random value from 0.0 to 1.0 based on a three dimensional coordinate.
Parameters
noise(double x, double y, double z)
- x - (double x) The x coordinate of the random value.
- y - (double y) The y coordinate of the random value.
- z - (double z) The z coordinate of the random value.
Example
void update()
{
rectMode(CORNER);
noStroke();
for (int y = 0; y < canvasHeight; y += canvasHeight / Rectangles)
{
for (int x = 0; x < canvasWidth; x += canvasWidth / Rectangles)
{
// get a value between 0 and 255 for our color
// (the smaller the x and the y, the smoother the noise will be)
int grayscale_val = (int)(noise(x*0.01f, y*0.01f, frameCount * 0.1) * 255);
// fill the color our noise generated
fill(color(grayscale_val, grayscale_val, grayscale_val, 255));
// draw the rectangle at the position
rect((float)x, (float)y + 1, (float)canvasWidth / (float)Rectangles, 1 + (float)canvasHeight / (float)Rectangles);
}
}