xxxxxxxxxx
120
let len =19
let m = [];
let n = []
let s,d
let c0,c1,c2
function setup(){
createCanvas (855,570)
background(0)
noStroke()
newColor()
createMarix()
}
function draw(){
drawPattern()
drawCircles()
drawText()
}
//-------------------------------------------------//
function mouseReleased(){
if (mouseButton == LEFT) {
newColor();
}
}
function preload(){
font = loadFont('Bold.ttf')
}
function drawText(){
noStroke()
fill(c2)
let noiseVal_1 = map(noise(45/320, 45/320, frameCount/100), 0.33, 0.66, -len/3, len)/3;
textSize(70+noiseVal_1)
textAlign(CENTER);
textFont(font)
push()
c2.setAlpha(150 + 128 * sin(millis() / 1000));
fill(c2)
rotate(0)
text('The world \n is filled with \n noise',width/2,height/2-70)
pop()
}
function createMarix(){
for(let x = 0;x < width;x +=len){
m[x] = []
for(let y = 0;y <height;y +=len){
m[x] [y]=int(random(2))
}
}
}
// function createMarix2 (){
// for(let i = 0;i < width;i++){
// n[i] = []
// for(let j = 0;j <height;j++){
// let dis = dist(width / 2, height / 2, i, j)
// let maxDistance = dist(width / 2, height / 2, width, height);
// n[i][j] = (dis / maxDistance) * 255;
// }
// }
// }
function drawCircles(){
for(let b = 0;b < width;b +=100){
let noiseVal_2 = map(noise(45/320, 45/320, frameCount/100), 0.33, 0.66, -len/3, len)/2;
push()
c3.setAlpha(50 + 128 * cos(millis() / 1000));
stroke(c3)
strokeWeight(1.9)
noFill()
ellipse(width/2,height/2,b+noiseVal_2 ,b+noiseVal_2 )
}
}
function newColor(){
c0 = color(random(255), random(255), random(255))
c1 = color(random(255), random(255), random(255))
c2 = color(random(255), random(255), random(255))
c3 = color(random(255), random(255), random(255))
}
function drawPattern(){
//squares
for(let x = 0;x < width;x +=len){
for(let y = 0;y <height;y +=len){
if(m[x][y] == 0) fill(c0)
else fill(c1)
rect(x,y,len,len)
}
}
//circles
for(let x = 0;x < width;x +=len){
for(let y = 0;y <height;y +=len){
let s=0
if((x+y)%2 == 0){
fill(c0)
s=-1
}else{
fill(c1)
s=1
}
let d = map(noise(x/320, y/320, frameCount/100), 0.33, 0.66, -len/3, len)/2;
ellipse(x,y,len+s*d,len+s*d)
}
}
}