Spinny hexagon/hexagon-star tiling
Made for #TilingTuesday on Mastodon
let l1, l2
function setup() {
createCanvas(400, 400);
l1 = createGraphics(width, height)
l2 = createGraphics(width, height)
windowResized()
l1.fill(250, 245, 120)
l1.noStroke()
l2.stroke(0)
l2.noFill()
l1.background("#69AFE4")
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight)
l1.resizeCanvas(width, height)
l2.resizeCanvas(width, height)
l1.background("#69AFE4")
}
const sq3 = Math.sqrt(3)
function draw() {
let t = millis() / 1000
let t2 = t / 3 + 1.45
let t3 = t2 + 0.1
t += sin(t * PI) / PI * 1.2
t += sin(t * PI) / PI * 1.2
t += sin(t * PI) / PI * 1.2
t2 += sin(t2 * PI) / PI * 1.2
t2 += sin(t2 * PI) / PI * 1.2
t2 += sin(t2 * PI) / PI * 1.2
t3 += sin(t3 * PI) / PI * 1.2
t3 += sin(t3 * PI) / PI * 1.2
t3 += sin(t3 * PI) / PI * 1.2
// background(map(cos(t * PI), -1, 1, 220, 230));
l1.background("#69AFE433")
l2.clear()
let w = (sq3 + 3) * 20
let h = (sq3 * 3 + 3) * 10
for (let x = 0; x < width / w + 0.5; x ++) {
for (let y = 0; y < height / h + 0.5; y ++) {
for (let l of [l1, l2]) {
l.resetMatrix()
l.translate(x * w + (y % 2) * w / 2, y * h)
l.rotate((PI / 2 * ((x) % 2 ? t2 : t3) + PI / 2) * ((y) % 2 ? -1 : 1))
for (let i = 0; i < 3; i ++) {
l.rotate(PI * 2 / 3)
l.push()
l.translate(0, (sq3 + 1) * 10)
l.rotate(PI / 4 * t + PI / 4)
// if (l == l1) {
// let r = noise(x + cos(i * PI * 2 / 3) + 14143, y + sin(i * PI * 2 / 3), t / 30)
// let g = noise(x + cos(i * PI * 2 / 3), y + sin(i * PI * 2 / 3)+ 14143, t / 30)
// let b = noise(x + cos(i * PI * 2 / 3), y + sin(i * PI * 2 / 3), t / 30+ 14143)
// l1.fill(r**0.5 * 255, g**0.5 * 255, b**0.5 * 255)
// }
drawShape(l)
l.pop()
}
}
}
}
image(l1, 0, 0)
image(l2, 0, 0)
}
function drawShape(l = window) {
let s = 10
l.beginShape()
l.vertex(s * 0, s * (sq3 + 1))
l.vertex(s * sq3, s * sq3)
l.vertex(s * (sq3 - 1), s * 0)
l.vertex(s * sq3, - s * sq3)
l.vertex(s * 0, - s * (sq3 + 1))
l.vertex(- s * sq3, - s * sq3)
l.vertex(- s * (sq3 - 1), s * 0)
l.vertex(- s * sq3, s * sq3)
l.endShape(CLOSE)
}(Originally seen at https://editor.p5js.org/bojidar-bg/sketches/FwZTUH_yb)
Browse more articles?
← Circle wave Experiments tagged p5 (51/85) Koch snowflake with matrices →
← Spinning hexagon cubes Experiments tagged tiling (5/6) Dancing Cairo circles →
← Circle wave Experiments on this site (51/85) Koch snowflake with matrices →