GSDP:GAM100/CProcessing/randomRangeFloat()

From Inside
Jump to: navigation, search

randomRangeFloat()

Description

Gives a random float in the range from the input minimum to maximum.

Parameters

randomRangeFloat(float min, float max)

  • min - (float) The minimum value of the random range.
  • max - (float) The maximum value of the random range.

Example

void update() 
{
    // If double clicked clears the screen with a random color
    if (doubleClicked())
    {
        fill(color(randomRangeInt(180, 220), randomRangeInt(0, 220), randomRangeInt(100, 220), 255));
        rect(0, 0, (float)canvasWidth, (float)canvasHeight);
    }

    // While mouse is being dragged draws circles randomly on the screen with random colors
    if (mouseDragged(MOUSE_BUTTON_1))
    {
        fill(color(randomRangeInt(0, 250), randomRangeInt(0, 250), randomRangeInt(0, 250), 255));
        ellipse(randomRangeFloat(0, (float)canvasWidth), randomRangeFloat(0, (float)canvasHeight), 50, 50);
    }
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>