Orbits
//changing RGB colors
var R = 0;
var G = 0;
var B = 0;
//assigned in mousePressed to print and save color to rect
var tempR = 255;
var tempG = 255;
var tempB = 255;
function setup() {
createCanvas(450, 640);
background(255);
}
function mousePressed() {
print('------------------')
print('R: ' + R.toString())
print('G: ' + G.toString())
print('B: ' + B.toString())
//stores current RGB untill mousePressed again
tempR = R;
tempG = G;
tempB = B;
}
function draw() {
var lim = 140; //map(mouseX, 0, width, 0, 255);
var diff = 255-lim;
var index = 0;
background(R, G, B);
//color save
noStroke();
fill(tempR, tempG, tempB);
square(10, 10, 100);
//color fader
if (mouseY < height/6) {
index = map(mouseY, 0, height/6, lim, 255)
R = 255;
G = lim;
B = index;
} else if ((mouseY >= height/6) & (mouseY < 2*height/6)) {
index = map(mouseY, height/6, 2*height/6, 0, diff)
R = 255 - index;
G = lim;
B = 255;
} else if ((mouseY >= 2*height/6) & (mouseY < 3*height/6)) {
index = map(mouseY, 2*height/6, 3*height/6, lim, 255)
R = lim;
G = index;
B = 255;
} else if ((mouseY >= 3*height/6) & (mouseY < 4*height/6)) {
index = map(mouseY, 3*height/6, 4*height/6, 0, diff)
R = lim;
G = 255;
B = 255 - index;
} else if ((mouseY >= 4*height/6) & (mouseY < 5*height/6)) {
index = map(mouseY, 4*height/6, 5*height/6, lim, 255)
R = index;
G = 255;
B = lim;
} else {
index = map(mouseY, 5*height/6, 6*height/6, 0, diff)
R = 255;
G = 255-index;
B = lim;
}
//orbits
var deg = map(mouseY, 0, width, 0, 360);
var cirSize = 10;
var cirX = mouseX/2 //x dist from mouse
var cirY = mouseY/2 //y dist from mouse
var sunY = map(mouseY, 0, height, -0.4*height, 1.4*height);
fill(255, 113, 124);
ellipse(width/2, sunY, 700);
fill(255-R, 255-G, 255-B);
translate(mouseX, mouseY);
ellipse(cirX, cirY, cirSize);
rotate(radians(deg));
ellipse(cirX, cirY, cirSize);
rotate(radians(deg));
ellipse(cirX, cirY, cirSize);
rotate(radians(deg));
ellipse(cirX, cirY, cirSize);
rotate(radians(deg));
ellipse(cirX, cirY, cirSize);
rotate(radians(deg));
ellipse(cirX, cirY, cirSize);
scale(mouseY/height);
ellipse(cirX, cirY, cirSize);
rotate(radians(deg));
ellipse(cirX, cirY, cirSize);
rotate(radians(deg));
ellipse(cirX, cirY, cirSize);
rotate(radians(deg));
ellipse(cirX, cirY, cirSize);
rotate(radians(deg));
ellipse(cirX, cirY, cirSize);
rotate(radians(deg));
ellipse(cirX, cirY, cirSize);
scale(mouseY/height);
ellipse(cirX, cirY, cirSize);
rotate(radians(deg));
ellipse(cirX, cirY, cirSize);
rotate(radians(deg));
ellipse(cirX, cirY, cirSize);
rotate(radians(deg));
ellipse(cirX, cirY, cirSize);
rotate(radians(deg));
ellipse(cirX, cirY, cirSize);
rotate(radians(deg));
ellipse(cirX, cirY, cirSize);
}