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
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
    • 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
      • P5js Motion Reactor
      • P5js Multiple Reactor Points
      • P5js Programming Basics: Parametric and Generative Graphic Design 2016
      • P5js End Exercise 2014
      • P5js End Exercise 2015
      • P5js Ext. Lektion 1 (Force Fields)
      • P5js Ext.Lektionen 2 (Rekursive Funktionen / Fraktale)
      • P5js How Computers Think
      • P5js End Exercise 2016 - Asteroids
      • P5js High Scores
      • P5js Artificial Neural Network
      • P5js Gesture Interactions
      • P5js Lesson 4.2 – Sine function
      • P5js Lesson 4.5 - Exercises
  • Programming in Processing (java)

    Two hearts overlapped with each other
    Welcome back
    Catch up on the top discussions and highlights from your team.
    /
    P5js Ext.Lektionen 2 (Rekursive Funktionen / Fraktale)
    Published Jul 30, 2021

    P5js Ext.Lektionen 2 (Rekursive Funktionen / Fraktale)

    Jul 30, 2021

    Rekursive Funktionen / Fraktale

    In diesem Bespiel nutzen wir Rekursive-Funktionen und Zufallszahlen.
    Eine Rekursive-Funktion ist eine Funktion die sich selbst wieder aufruft. Die Nutzung von Rekursion kann für verschiedene Probleme verwendet werden, wie z.B.

    • Suchen von Files durch die File-Hierarchie

    • Zeichnen von fraktalen Objekten

    Bei Rekursionen muss man speziell auf die Abbruchbedingung achten, sonst führt dies schnell zu Endlosschleifen.

    void setup() { size(600,600); // def. fenstergroesse randomSeed(millis()); // seed random smooth(); // aktiviere antialiasing strokeWeight(5); // linienbreite stroke(0,0,0,150); noLoop(); } void draw() { background(255); pushMatrix(); translate(width *.5,height - 20); wurzel(7); popMatrix(); } void mousePressed() { redraw(); } // funktion void wurzel(int tiefe) { if(tiefe <= 0) // teste ob das ende erreicht worden ist { // zeichen blueten pushStyle(); int clr = (int)random(100,255); stroke(clr,0,0,190); fill(clr,0,0,190); ellipse(0,0,50,50); popStyle(); return; } // zeichne zweige int x; int y; int count = (int)random(1,8); for(int i = 0; i < count;i++) { x = (int)random(-100,100); y = -(int)random(10,150); line(0,0,x,y); pushMatrix(); translate(x,y); scale(random(.3,.95)); wurzel(tiefe-1); popMatrix(); } }

    Aufgabe:

    • Verändere das Beispiel, mach andere Äste, Blüten, etc…

     

     

    {"serverDuration": 15, "requestCorrelationId": "09627556309747c3b3cf6e4cb1df955d"}