Created
March 20, 2021 23:12
-
-
Save martijnkunstman/db9cd5eb4e9397d11fdfb8ba283efe6f to your computer and use it in GitHub Desktop.
Revisions
-
martijnkunstman created this gist
Mar 20, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ let width = 700; let height = 700; let points = [ { x: width / 2, y: 0 }, { x: 0, y: height }, { x: width, y: height } ]; let pointNow = { x: width / 2, y: height / 2 }; /* let points = [ { x: 0, y: 0 }, { x: width, y: 0 }, { x: 0, y: height }, { x: width, y: height }, {x: width/2, y:height/2} ]; */ function setup() { createCanvas(width, height); stroke('rgba(0,0,0,0.25)'); } function draw() { for (let i = 0; i < 1000; i++) { let pointNext = points[Math.floor(Math.random() * points.length)]; pointNow = { x: (pointNext.x + pointNow.x) / 2, y: (pointNext.y + pointNow.y) / 2 }; point(pointNow.x, pointNow.y); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.3.0/p5.min.js"></script> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ Sierpiński triangle - Chaos game -------------------------------- A [Pen](https://codepen.io/martijnkunstman/pen/yLVmPeg) by [Martijn Kunstman](https://codepen.io/martijnkunstman) on [CodePen](https://codepen.io). [License](https://codepen.io/martijnkunstman/pen/yLVmPeg/license).