Please Login First
×
Create a new article
Write your page title here:
We currently have 193 articles on Inside. Type your article name above or click on one of the titles below and start writing!



    Inside

    GSDP:GAM100/CProcessing/noise()

    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);
        }
    }
    

    Related