Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.

Commit

Permalink
Port of CC123_2 to Processing (#866)
Browse files Browse the repository at this point in the history
* Port of CC123 to Processing

* Port of CC123_2 to Processing

* Revert "Port of CC123 to Processing"

This reverts commit 76bedaf.

* Update CC_123_ChaosGame_2.pde

* Removed comments belonged to js

* Update CodingChallenges/CC_123_ChaosGame_2/Processing/CC_123_ChaosGame_2/CC_123_ChaosGame_2.pde

Co-Authored-By: gruselhaus <nico@gruselhaus.com>

* Update CodingChallenges/CC_123_ChaosGame_2/Processing/CC_123_ChaosGame_2/CC_123_ChaosGame_2.pde

Co-Authored-By: gruselhaus <nico@gruselhaus.com>

* Update CodingChallenges/CC_123_ChaosGame_2/Processing/CC_123_ChaosGame_2/CC_123_ChaosGame_2.pde

Co-Authored-By: gruselhaus <nico@gruselhaus.com>

* Update CodingChallenges/CC_123_ChaosGame_2/Processing/CC_123_ChaosGame_2/CC_123_ChaosGame_2.pde

Co-Authored-By: gruselhaus <nico@gruselhaus.com>

* Update CodingChallenges/CC_123_ChaosGame_2/Processing/CC_123_ChaosGame_2/CC_123_ChaosGame_2.pde

Co-Authored-By: gruselhaus <nico@gruselhaus.com>

* Update CodingChallenges/CC_123_ChaosGame_2/Processing/CC_123_ChaosGame_2/CC_123_ChaosGame_2.pde

Co-Authored-By: gruselhaus <nico@gruselhaus.com>

* Update CC_123_ChaosGame_2.pde
  • Loading branch information
gruselhaus authored and shiffman committed Dec 2, 2018
1 parent 1fb2cd0 commit 44c783b
Showing 1 changed file with 56 additions and 0 deletions.
@@ -0,0 +1,56 @@
// The Chaos Game
// Daniel Shiffman
// Part 1: https://youtu.be/7gNzMtYo9n4
// https://thecodingtrain.com/CodingChallenges/123.1-chaos-game
// Part 2: https://youtu.be/A0NHGTggoOQ
// https://thecodingtrain.com/CodingChallenges/123.2-chaos-game

PVector[] points;
PVector current;
float percent = 0.5;
PVector previous;

void setup() {
fullScreen();
int n = 5;
points = new PVector[n];

for (int i = 0; i < n; i++) {
float angle = i * TWO_PI / n;
PVector v = PVector.fromAngle(angle);
v.mult(width / 2);
v.add(width / 2, height / 2);
points[i] = v;
}
reset();
}

void reset() {
current = new PVector(random(width), random(height));
background(0);
stroke(255);
strokeWeight(8);
for (PVector p : points) {
point(p.x, p.y);
}

}

void draw() {

if (frameCount % 100 == 0) {
//reset();
}

for (int i = 0; i < 1000; i++) {
strokeWeight(1);
stroke(255);
PVector next = points[floor(random(points.length))];
if (next != previous) {
current.x = lerp(current.x, next.x, percent);
current.y = lerp(current.y, next.y, percent);
point(current.x, current.y);
}
previous = next;
}
}

0 comments on commit 44c783b

Please sign in to comment.