Skip to content

Instantly share code, notes, and snippets.

@jacobjoaquin
Created January 2, 2023 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacobjoaquin/115e079f7c0f7e348ed4bb75027789ac to your computer and use it in GitHub Desktop.
Save jacobjoaquin/115e079f7c0f7e348ed4bb75027789ac to your computer and use it in GitHub Desktop.
"Made in 10 Minutes". Built with p5js
// Made in 10 Minutes
// By Jacob Joaquin (@jacobjoaquin)
// For Genuary 2023
const nLines = Math.floor(Math.random() * 100) + 50
let v0, v1, p0, p1
let speed0 = Math.floor(Math.random() * 20) + 5
let speed1 = Math.floor(Math.random() * 20) + 5
function setup() {
createCanvas(500, 500)
v0 = p5.Vector.fromAngle(Math.random() * TAU).mult(speed0)
v1 = p5.Vector.fromAngle(Math.random() * TAU).mult(speed1)
p0 = createVector(Math.random() * 500, Math.random() * 500)
p1 = createVector(Math.random() * 500, Math.random() * 500)
background('#efe7cf')
}
function draw() {
// background(220)
noLoop()
const c = ['#c82b1e', '#000000', '#285d88', '#e9b840']
let c1 = c[Math.floor(Math.random() * c.length)]
for (let i = 0; i < nLines; i++) {
if (Math.random() < 0.125) c1 = c[Math.floor(Math.random() * c.length)]
strokeWeight(2)
stroke(c1)
line(p0.x, p0.y, p1.x, p1.y)
p0.add(v0)
p1.add(v1)
p0.x = p0.x % 500
p0.y = p0.y % 500
p1.x = p1.x % 500
p1.y = p1.y % 500
if (p0.x < 0) p0.x += 500
if (p0.y < 0) p0.y += 500
if (p1.x < 0) p0.x += 500
if (p1.y < 0) p0.y += 500
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment