fractalkitty looking for math? fractalkitty.com

100 days of code

picWeave_Day25

#image#animation

let cnt = 100,t=0.01;
function preload() {
  bg = loadImage('/assets/IMG_2230.JPG');
  bw = loadImage('/assets/IMG_2230.JPG');//load image
}
function setup() {
  cnv = createCanvas(bg.width/5, bg.height/5);//canvas creation
  bg.filter(GRAY)
}
function draw() {
  if(t!=0){t = frameCount*2-width;}
  for (let i=0;i<40;i++){
    dy = i*width/40;
    dw = height
    dh = width/40
    sy=+i*bg.width/40
    image(bg,dy,0,dh,dw,sy,0,bg.width/40,bg.height)
}
  for (let i=0;i<40;i++){
    dy = i*height/40;
    dw = width
    dh = height/40
    sy=i*bg.height/40
    image(bw,t,dy,dw,dh,0,sy,bg.width,bg.height/40)
}
  for(let k=0;k<40;k=k+2){
    for (let i=0;i<40;i=i+2){
      dy = k*height/40
      dx = i*width/40;
      dw = height/40
      dh = width/40
      sx= i*bg.width/40
      sy=bg.height/40
      image(bg,dx,dy,dh,dw,sx,k*sy,bg.width/40,bg.height/40)
    }
  }
  for(let k=0;k<40;k=k+2){
    for (let i=0;i<40;i=i+2){
      dy = k*height/40+height/40;
      dx = i*width/40+width/40;
      dw = height/40
      dh = width/40
      sx= i*bg.width/40+bg.width/40
      sy=bg.height/40
      image(bg,dx,dy,dh,dw,sx,k*sy+sy,bg.width/40,bg.height/40)
    }
  }
  
  if(frameCount*2-width > 0){
    t=0;
    if (frameCount*2-width >20){
      background(bw)
    }
    if (frameCount*2-width >60){
      t = 0.01;
      frameCount = 0;
    }
    
    
  }
}