xxxxxxxxxx
73
let offset = {x:100,y:200}
let noiseamp = 10;
let noiseres = 0.008;
function setup() {
createCanvas(400, 400);
background(220);
slider = createSlider(0, 0.1,0.02,0.001);
slider.position(10, 410);
slider.size(380);
slider2 = createSlider(0, 100,6);
slider2.position(10, 430);
slider2.size(380);
growIt();
}
function growIt(){
background(255)
noiseamp = slider2.value();
noiseres = slider.value();
let coords = [{x:offset.x,y:offset.y}];
let xadjust = 0;
for(let t=1;t<20000;t++){
let sint = cos(0.02*t)
let dir;
if(t%(50*PI)>25*PI){
// stroke("red")
// line(coords[t-1].x,300,coords[t-1].x,100)
// stroke(0)
// temp = -1
xadjust = (t%(50*PI)-25*PI) * 0.02
dir = -1
}
else{
xadjust = 0
dir = 1
}
coords.push({
x:
coords[t-1].x + 0.01 +
dir*
abs(sin(0.02*t)) * noiseamp*(noise((coords[t-1].x - xadjust) *noiseres,coords[t-1].y*noiseres) - 0.5 ) ,
y:
coords[t-1].y + 3 * sint +
dir*
abs(sin(0.02*t)) * noiseamp*(noise((coords[t-1].x- xadjust)*noiseres+100,coords[t-1].y*noiseres) - 0.5 )
})
line(coords[t-1].x,coords[t-1].y,coords[t].x,coords[t].y);
}
line (50,height/2,350,height/2)
}
function mouseReleased(){
growIt();
print("noiseres " + slider.value())
print("noiseamp " + slider2.value())
}