xxxxxxxxxx
var img;
var balls = [];
var radiusLow = 10;
var radiusHigh = 20;
var rangeLow = 0.5;
var rangeHigh = 1;
function preload(){
img = loadImage("slushlogo_comp.jpg");
//bgimg = loadImage("typobw_sharp.jpg");
//transimg = loadImage("typotrans2.png");
}
function setup() {
//createCanvas(img.width, img.height);
createCanvas(windowWidth, windowHeight);
//background(bgimg);
background(16,16,16);
//background(222,223,225);
img.resize(windowWidth, windowHeight);
textAlign(CENTER);
// text("Click and hold here!!", width/2, height/2);
for (var i = 0; i < 10; i++){
balls.push(new Ball(windowWidth/2, windowHeight/2, color(img.get(windowWidth/2, windowHeight/2))));
}
}
function draw(){
//var c = color(img.get(current.location.x, current.location.y));
//var greyscale = round(red(c) * 0.222 + green(c) * 0.707 + blue(c) * 0.071);
for (var i = 0; i < balls.length; i++){
balls[i].draw();
balls[i].update();
balls[i].changeColour();
}
for (var i = 0; i < balls.length; i++){
if (balls[i].radius < 0){
balls.splice(i, 1);
}
}
if (mouseIsPressed){
for (var i = 0; i < 5; i++){
balls.push(new Ball(mouseX, mouseY, color(img.get(mouseX+random(2), mouseY+random(2)))));
}
}
//image(transimg, 0, 0);
}
class Ball{
//start where the user clicks
//move up from where the user has clicked
//become smaller as it moves up
//be drawn to the screem
constructor(mX, mY, c){
this.location = createVector(mX, mY);
//this.radius = random(.01);
this.radius = random(0.3); //change ball size
this.r = red(c);
this.g = green(c);
this.b = blue(c);
this.xOff = 0.0;
this.yOff = 0.0;
this.radiusLow;
this.radiusHigh;
this.rangeLow;
this.rangeHigh
}
update(){
//this.radius -= random(0.0001);
this.radius -= random(0.001);
this.xOff = this.xOff + random(-0.7, 0.7);
this.nX = noise(this.location.x) * this.xOff;
this.yOff = this.yOff + random(-0.7, 0.7);
this.nY = noise(this.location.y) * this.yOff;
this.location.x += this.nX;
this.location.y += this.nY;
}
changeColour(){
this.c = color(img.get(this.location.x, this.location.y));
this.r = red(this.c);
this.g = green(this.c);
this.b = blue(this.c);
}
draw(){
noStroke();
//stroke(255);
//stroke(this.r, this.g, this.b);
//strokeWeight(3);
//fill(255);
fill(this.r, this.g, this.b);
//line(this.location.x-(this.location.x*this.radius), this.location.y, this.location.x+(this.location.x*this.radius), this.location.y)
ellipse(this.location.x, this.location.y, this.radius * 50, this.radius * 50);
}
}
function keyTyped() {
if (key == 's') {
saveCanvas('paths', 'png');
}
}
/*function windowResized() {
resizeCanvas(windowWidth, windowHeight);
//background(16, 16, 16);
}*/