GSDP:GAM100/CProcessing/noiseSeed()

From Inside
Jump to: navigation, search

noiseSeed()

Description

Lets you set a specific seed for noise to produce the same results each time the program is run. By default, the program will produce different results every time it is run.

Parameters

noiseSeed(int seed)

  • seed - (int) The value you want to use to seed the noise generator.

Example

void init()
{
    // Set draw mode
    rectMode(CORNER);
    noStroke();

    // Set noise seed
    // This will make you see the same pattern every time you run the program
    noiseSeed(5);
}

void update() 
{
    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);
    }
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>