fractalkitty looking for math? fractalkitty.com

borbs

borbGlitch

#random#trig#3d#interactive#animation#polar#animals

glitchOnnBorbsglitchborbEyesborbBeakborbLegsWings


let r = 100;
let glitchOn = false;
let nBorbs = 1;
function setup() {
  createCanvas(windowWidth, windowHeight, WEBGL);
  noStroke();
  angleMode(DEGREES);
  smooth();
}
function draw() {
  orbitControl();
  background(50);
  ambientLight(255);
  rotateY(40 * sin(frameCount / 4));
  if (glitchOn) {
    t++;
    strokeWeight(0.2);
    stroke(255);
    glitch();
    if (frameCount % 200 === 0) {
      box(random(0, 1000), random(0, 1000), random(0, 100));
    }
    if (
      frameCount % 280 === 0 ||
      frameCount % 281 === 0 ||
      frameCount % 282 === 0
    ) {
      push();
      scale(3, 3);
      ambientMaterial(100 + (t % 155), 200, 255);
      sphere(r, 24, 24);
      push();
      scale(1 + 0.5 * sin(t), 1 + 0.5 * sin(t));
      borbEyes();
      pop();
      borbBeak();
      borbLegsWings();
      pop();
    }
  } else {
    t = 0;
    noStroke();
  }
  ambientMaterial(100 + (t % 155), 200, 255);
  sphere(r, 24, 24);
  push();
  scale(1 + 0.5 * sin(t), 1 + 0.5 * sin(t));
  borbEyes();
  pop();
  borbBeak();
  borbLegsWings();
}

function glitch() {
  ambientMaterial(255);
  push();
  translate(r * cos(90 + t) * sin(-20), r * sin(-20), r * cos(-20));
  sphere(r / 10, 12, 12);
  ambientMaterial(0);
  rotateX(270);
  rotateY(90);
  cone(5, 20, 12);
  pop();
  push();
  ambientMaterial(255, 126, 0);
  translate(r * cos(20) * sin(0 - ((t / 4) % 10)), 0, r);
  rotateX(90);
  cone(20, 55, 12);
  pop();
  push();
  translate(r - 40, 0, 0);
  ambientMaterial(0);
  rotateX(270 + t);
  rotateY(90);
  cylinder(60, 60, 22, 12);
  pop();
  push();
  translate(-60, 0, 0);
  ambientMaterial(0);
  rotateX(270 - t);
  rotateY(90);
  cylinder(60, 60, 22, 12);
  pop();
}

function keyPressed() {
  glitchOn = !glitchOn;
}

function borbEyes() {
  ambientMaterial(255, 255, 255);
  push();
  translate(r * cos(20) * sin(-20), r * sin(-20), r * cos(-20));
  sphere(r / 10, 12, 12);
  ambientMaterial(0);
  rotateX(270);
  rotateY(90);
  cone(5, 20, 12);
  pop();
  push();
  translate(r * cos(20 + t) * sin(20), r * sin(-20), r * cos(-20));
  sphere(r / 10, 12, 12);
  ambientMaterial(0);
  rotateX(270);
  rotateY(90);
  cone(5, 20, 12);
  pop();
}

function borbBeak() {
  push();
  ambientMaterial(255, 126, 0);
  translate(0, 0, r * abs(cos(0 - (t % 70))));
  rotateX(90);
  cone(20, 55, 12);
  pop();
}

function borbLegsWings() {
  push();
  ambientMaterial(120, 50, 0);
  translate(r * cos(40 + t / 10) * sin(40) - r / 10, r, 0);
  rotateX(0);
  cylinder(2, 50, 12);
  translate(0, 25, 0);
  rotateX(90);
  cylinder(2, 15, 12);
  rotateZ(30);
  cylinder(2, 15, 12);
  pop();
  push();
  ambientMaterial(120, 50, 0);
  translate(r * cos(40 - t / 10) * sin(40) - r / 1.15, r, 0);
  rotateX(0);
  cylinder(2, 50, 12);
  translate(0, 25, 0);
  rotateX(90);
  cylinder(2, 15, 12);
  rotateZ(30);
  cylinder(2, 15, 12);
  pop();
  push();
  translate(r - 40, 0, 0);
  ambientMaterial(0);
  rotateX(270);
  rotateY(90);
  cylinder(60, 60, 22, 12);
  pop();
  push();
  translate(-60, 0, 0);
  ambientMaterial(0);
  rotateX(270);
  rotateY(90);
  cylinder(60, 60, 22, 12);
  pop();
}