MCPcopy Create free account
hub / github.com/expo/examples / harom

Function harom

with-processing/App.js:8–31  ·  view source on GitHub ↗
(ax, ay, bx, by, level, ratio)

Source from the content-addressed store, hash-verified

6 };
7
8 const harom = (ax, ay, bx, by, level, ratio) => {
9 if (level <= 0) {
10 return;
11 }
12
13 const vx = bx - ax;
14 const vy = by - ay;
15 const nx = p.cos(p.PI / 3) * vx - p.sin(p.PI / 3) * vy;
16 const ny = p.sin(p.PI / 3) * vx + p.cos(p.PI / 3) * vy;
17 const cx = ax + nx;
18 const cy = ay + ny;
19 p.line(ax, ay, bx, by);
20 p.line(ax, ay, cx, cy);
21 p.line(cx, cy, bx, by);
22
23 harom(
24 ax * ratio + cx * (1 - ratio),
25 ay * ratio + cy * (1 - ratio),
26 ax * (1 - ratio) + bx * ratio,
27 ay * (1 - ratio) + by * ratio,
28 level - 1,
29 ratio
30 );
31 };
32
33 p.draw = () => {
34 p.background(240);

Callers 1

sketchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected