xxxxxxxxxx
47
function rot(t, u) {
return (t + u) / (1 - t*u)
}
function param(t, s) {
return { x: (1 - t*t) / (1 + t*t) * s,
y: 2*t / (1 + t*t) * s }
}
function rand_v3() {
return {
a: random( 0, 11/14),
b: random( 5/3, 14/11),
c: random(-5/3, -1/5),
s: random( 1/2, 1),
r: random(-1/100, 1/100)
}
}
let trigons = []
function setup() {
createCanvas(400, 400)
for(let t = 0; t < 25; ++t) {
trigons[t] = rand_v3()
}
}
function draw() {
background(220)
let i = 0
for(let x = 40; x <= 360; x += 80) {
for(let y = 40; y <= 360; y += 80) {
let t = trigons[i++]
let a = param(t.a, t.s)
t.a = rot(t.a, t.r)
let b = param(t.b, t.s)
t.b = rot(t.b, t.r)
let c = param(t.c, t.s)
t.c = rot(t.c, t.r)
triangle(x + 40*a.x, y - 40*a.y,
x + 40*b.x, y - 40*b.y,
x + 40*c.x, y - 40*c.y)
}
}
}