dynamic drawing

I wanted to explore the spinning of an object and see if I could control it or alter it in some way by using the location of the mouse.

sketch
function setup() {
    createCanvas(400, 400);
    rectMode(CENTER);
}

var g = 5;
var angle = 0;

function draw() {
    background(0);
    var r = g + mouseX
    fill(r, 255, 0);
    // restrict mouseX to 0-400
    var m = max(min(mouseX, 400), 0);
    var size = m * 350.0 / 400.0;
    circle(10 + m * 190.0 / 400.0, 200.0,
         size);
    fill(255, 0, r);
    size = 350 - size;
    circle(200 + m * 190.0 / 400.0, 200.0,
         size);
    //heres some confetti yay
    
    var confettiDimention1 = 100;
    var confettiDimension2 = 150;
    var confettiDimension3 = 120;
    var confettiDimension4 = 142;
    var angleSpangle = map(mouseX,0,width,3,300);
    push();
    fill('magenta');
    translate(m / 2,200 + size);
    rotate(radians(angle));
    square(confettiDimention1,confettiDimention1,50);
    fill('green');
    square(confettiDimention1,confettiDimention1,50);
    fill('cyan');
    square(confettiDimension2,confettiDimention1,10);
    square(confettiDimension3,confettiDimension4,30);
    pop();
    angle += angleSpangle;
    //if not then square probably

}

Leave a Reply