xxxxxxxxxx
// by Metamere
// 1-12-2023
// Genuary day 19: Black and white
var looping = true
var t = 0
let slant = 45
function setup() {
createCanvas(W = windowWidth, H = windowHeight);
S = min(W,H)
s = S/2
w = W/2
h = H/2
rectMode(CENTER)
angleMode(DEGREES)
noStroke()
fill(0,100)
noSmooth()
frameRate(24)
}
function rand_uniform(value1,value2=null){
if(value2==null){
return value1*(2 * Math.random() - 1)
}
else{
return value1 + (value2-value1) * Math.random()
}
}
function draw() {
if(!looping) return
// slant = 10 + mouseX/W*70
background(255,10);
translate(w,h)
let I = 2
let angle_divisions = 9
let scale_factor = 10/angle_divisions
for(let i=0; i < I; i++){
let hatching_angle = -slant + 2 * slant*i/(I-1)
let theta_step = 360/angle_divisions
let theta = 0 //+ i/I*theta_step
push()
rotate(theta)
while(theta < 360){
rotate(theta_step)
let y = 0
let count = 0
let N = 0.5*(2*noise((theta + t)*0.01 + 1e4) - 1)
let end_y = (0.8 + N)*s
while(y < end_y && count < 9999){
push()
let y_ratio = y/end_y
let scale_y = rand_uniform(0.11, 0.2) + scale_factor*0.3
let scale_x = rand_uniform(1.25,1.75) + scale_factor*1.2
let N = 0.5*s*(2*noise((y + 10 * t)*0.001 + 1e4) - 1)
translate(N + rand_uniform(scale_y*3), y + scale_y)
rotate(hatching_angle + rand_uniform(10))
scale(scale_x, scale_y)
rotate(rand_uniform(1, 5))
let y_step = S*(rand_uniform(0.01,0.02)) + y_ratio*y*0.3
let stroke_count = int(rand_uniform(3,9))
// let D = y_step*(0.8 + Math.random() * 0.6)
let D = y_step*(1.35-y_ratio)
let stroke_x = -D*0.5
let stroke_step = D/stroke_count
let count2 = 0
push()
if(Math.random() < 0.05){
rotate(rand_uniform(10))
fill(255,80)
}
while(count2 < stroke_count){
if(Math.random() < 0.5){
push()
translate(stroke_x,0)
// rotate(45+90*int(2*Math.random()))
rotate(rand_uniform(1))
scale(0.75/stroke_count-0.2*Math.random(),0.5+2*Math.random())
rect(0,0, D)
pop()
}
stroke_x += stroke_step
count2++
}
pop()
pop()
count++
y+= 1.5*y_step*scale_y
}
theta += theta_step
}
pop()
}
t++
}
function mousePressed(){
looping = !looping
}