Processing
Here are some of my experiments with Processing.
Changing Circles
With this one the group of circles follows your cursor and there is also a counter part that follow the opposite axis of the mouse, the colours also change depending on the x and y co-ordinates of the mouse, there is also a line being drawn from 0,0 to where the mouse is.
Screenshot of the Program.
Code
void setup(){
// runs once
size(1000, 600);
background(0, 0, 0);
}
void draw(){
// runs repeatedly
fill(mouseX,0,mouseY);
stroke(mouseX,mouseY,255);
line(20,20,mouseY,mouseX);
stroke(mouseX,mouseY,255);
line(10,10,mouseX,mouseY);
stroke(255,255,255);
line(0,0,mouseX,mouseY);
noStroke();
ellipse(mouseY,mouseX,20,20);
ellipse(10+mouseX,10+mouseY,20,20);
ellipse(20+mouseX,20+mouseY,20,20);
ellipse(30+mouseX,30+mouseY,20,20);
ellipse(40+mouseX,40+mouseY,20,20);
ellipse(mouseX-10,mouseY-10,20,20);
ellipse(mouseX-20,mouseY-20,20,20);
ellipse(mouseX-30,mouseY-30,20,20);
ellipse(mouseX-40,mouseY-40,20,20);
fill(mouseY,mouseX,10);
ellipse(mouseX,mouseY,20,20);
ellipse(10+mouseY,10+mouseX,20,20);
ellipse(20+mouseY,20+mouseX,20,20);
ellipse(30+mouseY,30+mouseX,20,20);
ellipse(40+mouseY,40+mouseX,20,20);
ellipse(mouseY-10,mouseX-10,20,20);
ellipse(mouseY-20,mouseX-20,20,20);
ellipse(mouseY-30,mouseX-30,20,20);
ellipse(mouseY-40,mouseX-40,20,20);
}
Painter
This tool i made is a simple painting program where you can select a colour for your brush by putting your mouse over the rectangle of colour you want and pressing any of the letter keys, you can then paint with that brush using the mouse click. The screen will also clear if you press a keyboard button that isn't a letter key.
This is a screenshot of something i made using this program.
Code
void setup(){
size(1000,600);
background(10,10,10);
fill(0,0,125);
rect(0,0,50,50);
fill(255,0,125);
rect(950,0,50,50);
fill(0,255,125);
rect(0,550,50,50);
fill(255,255,125);
rect(950,550,50,50);
noStroke();
}
void draw(){
if (mousePressed == true)
rect(mouseX,mouseY,5,5);
if (mousePressed == true)
rect(mouseX+6,mouseY,5,5);
if (mousePressed == true)
rect(mouseX-6,mouseY,5,5);
if (mousePressed == true)
rect(mouseX,mouseY+6,5,5);
if (mousePressed == true)
rect(mouseX,mouseY-6,5,5);
if (mousePressed == true)
rect(mouseX-6,mouseY-6,5,5);
if (mousePressed == true)
rect(mouseX+6,mouseY-6,5,5);
if (mousePressed == true)
rect(mouseX-6,mouseY+6,5,5);
if (mousePressed == true)
rect(mouseX+6,mouseY+6,5,5);
}
void keyPressed() {
int keyIndex = -1;
if (key >= 'A' && key <= 'Z') {
keyIndex = key - 'A';
} else if (key >= 'a' && key <= 'z') {
keyIndex = key - 'a';
}
if (keyIndex == -1) {
background(0);
} else {
fill(mouseX,mouseY,125);
rect(mouseX,mouseY,40,40);
}
}
Colour Change Snake
For this one i had the draw function float behind the mouse so that you would get a smooth line behind the snake, I also had the colours change on the snake depending of the position of the mouse in the window. You can press the space bar to clear the screen.
Screenshot from the program.
Code
float x;
float y;
float easing = 0.015;
void setup() {
size(1000,600);
background(10,10,10);
noStroke();
}
void draw(){
fill(mouseX-500,mouseY-300,mouseX-mouseY);
float targetX = mouseX;
float dx = targetX - x;
if(abs(dx) > 1) {
x += dx * easing;
}
float targetY = mouseY;
float dy = targetY - y;
if(abs(dy) > 1) {
y += dy * easing;
}
rect(x ,y ,50,50);rect(x +50,y +50, 10,10);rect(x -10,y -10, 10,10);rect(x -10,y +50, 10,10);rect(x +50,y -10, 10,10);fill(mouseY-500,mouseX-300,mouseY-mouseX);rect(x+20 ,y+20 ,10,10);rect(x +40,y +40, 10,10);rect(x ,y , 10,10);rect(x ,y +40, 10,10);rect(x +40,y , 10,10);
}
void keyPressed() {
int keyIndex = -1;
if (key == 'p') {
keyIndex = key - 'A';
} else if (key == 'o') {
keyIndex = key - 'a';
}
if (keyIndex == -1) {
background(0);
} else {
fill(mouseX,mouseY,125);
}
}


