From 36d853c44a45709fd17bfd8d13253d2eae69811d Mon Sep 17 00:00:00 2001 From: Herbert Spencer Date: Sat, 9 Jul 2022 20:45:27 -0400 Subject: [PATCH] new sketch --- 001-noise-field/.DS_Store | Bin 0 -> 6148 bytes 023-differential-growth/index.html | 11 +++++ 023-differential-growth/sketch.js | 62 +++++++++++++++++++++++++++++ 023-differential-growth/style.css | 8 ++++ index.html | 1 + 5 files changed, 82 insertions(+) create mode 100644 001-noise-field/.DS_Store create mode 100644 023-differential-growth/index.html create mode 100644 023-differential-growth/sketch.js create mode 100644 023-differential-growth/style.css diff --git a/001-noise-field/.DS_Store b/001-noise-field/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 + + + + crecimiento differencial + + + + + + \ No newline at end of file diff --git a/023-differential-growth/sketch.js b/023-differential-growth/sketch.js new file mode 100644 index 0000000..dbf66c3 --- /dev/null +++ b/023-differential-growth/sketch.js @@ -0,0 +1,62 @@ +//////////////////////////////////////////////////////// +// Reference: https://inconvergent.net/generative/ +// https://openprocessing.org/sketch/871349 +//////////////////////////////////////////////////////// + +let nodes = [] +const r = 7 + +setup = () => { + createCanvas(windowWidth, windowHeight) + fill('lightgrey') + noStroke() + nodes.length = 0 + for (let i = 3; i--;) { + const r = random(TWO_PI) + nodes[i] = createVector(cos(r) * 20 + width / 2, sin(r) * 5 + height / 2) + } +} + +draw = () => { + background('white') + splits() + reject() + beginShape() + for (const p of nodes) curveVertex(p.x, p.y) + endShape(CLOSE) +} + +reject = () => { + for (const p of nodes) { + force = createVector(0) + for (const q of nodes) { + if (p === q) continue; + const d = distance(p, q) + if (d < 2 * r) { + delta = p5.Vector.sub(p, q) + force.add(delta.mult((2 * r - d) * .025)) + } + } + p.add(force.limit(1)) + p.x = constrain(p.x, 0, width) + p.y = constrain(p.y, 0, height) + } +} + +distance = (u, v) => sqrt((u.x - v.x) ** 2 + (u.y - v.y) ** 2) + +splits = () => { + let next = [] + for (let i = 0; i < nodes.length; i++) { + current = nodes[i] + next.push(current) + neighbor = nodes[(i + 1) % nodes.length] + const d = distance(current, neighbor) + if (d > 2 * r && nodes.length < 1000) { + next.push(p5.Vector.add(current, neighbor).mult(1 / 2)) + } + } + nodes = next +} + +mouseClicked = () => setup() \ No newline at end of file diff --git a/023-differential-growth/style.css b/023-differential-growth/style.css new file mode 100644 index 0000000..a4f5659 --- /dev/null +++ b/023-differential-growth/style.css @@ -0,0 +1,8 @@ +html, body { + margin: 0; + padding: 0; +} +canvas { + display: block; + margin: 0 auto; +} \ No newline at end of file diff --git a/index.html b/index.html index 91a64d6..2173ab8 100644 --- a/index.html +++ b/index.html @@ -30,6 +30,7 @@

Expo Casiopea

  • amereida fourier
  • dft xt
  • dft circle
  • +
  • crecimiento diferencial 2
  • \ No newline at end of file