Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Confluence
/
P5js Random numbers (de)

P5js Random numbers (de)

Jul 30, 2021

Zufallszahlen werden in der Programmierung häufig genutzt, sei es nun für das verschlüsseln von Daten oder halt für generative Gestaltung. Processing bietet hier einfache Funktionen:

random([unteres Limit],[oberes Limit])  oder random([0 - oberes Limit])


void setup()
{
  size(500,500);
  background(255);
  fill(255);
  stroke(0);
}
   
void draw()
{
  //fill(random(100,150),random(0,100),random(150,255));
  float size = random(10,100);
  ellipse(random(0,width),random(0,height),size,size);
}


Aufgabe

Erweitere das Beispiel so, dass die Füllfarbe der Ellipse abhängig von der Grösse der Ellipse ist(Durchmesser). Je grösser desto rötlicher soll die Ellipse sein.

, multiple selections available,
For you

Programming
Results will update as you type.
  • Tiling and Repetition
  • Reactors
  • Programming Basics: Parametric and Generative Graphic Design 2016
  • Archive
  • High Scores
  • Artificial Neural Network
  • Alternatives to the Processing IDE
  • p5.js Programming
    • p5.js Introduction
    • p5.js Variables
    • p5.js Random Numbers
      • P5js Random numbers (de)
    • p5.js SVG + Images
    • p5.js WebGL
    • p5.js Classes and Objects
    • p5.js Events and Functions
    • p5.js Loops
    • p5.js Coordinates
    • P5js Nested Loops
    • p5.js Animation Exercise 1
    • p5.js Animation Exercise 2
    • p5.js Conditionals
    • p5.js Arrays and Lists
    • p5.js Simple Collision Detection
    • p5.js Reactors
    • p5.js Tiling and Repetition
    • p5.js Vectors
    • p5.js Animation Solution with Objects
    • p5.js Easing
    • p5.js Perlin Noise
    • p5.js Particle System
    • p5.js Sound
    • p5j.s Typography
    • P5js Archive
  • Programming in Processing (java)

{"serverDuration": 17, "requestCorrelationId": "e349c8db2fd9447eaae2bbdb2b9f8b5a"}