qwerty colour,
in
Share your Work
•
1 year ago
I'm currently at a very rudimentary early level with Processing. I stuck this piece together with a cute little book and some of the examples as reference. It's pretty Frankenstein.
You hit the QWERTY keys to change the colour of the shape while dragging it around the screen, the movement of the cursor is tracked and looped.
Eventually I want to work sound in to it, so each key corresponds to a different sound, manipulated by the position of the cursor. This would just layer up and loop audio-visual chaos.
If anyone has any suggestions for improvement, please feel free to add, I'm sure there's a lot of work to be done.
You hit the QWERTY keys to change the colour of the shape while dragging it around the screen, the movement of the cursor is tracked and looped.
Eventually I want to work sound in to it, so each key corresponds to a different sound, manipulated by the position of the cursor. This would just layer up and loop audio-visual chaos.
If anyone has any suggestions for improvement, please feel free to add, I'm sure there's a lot of work to be done.
- int currentFrame = 0;
PImage[] frames = new PImage[24];
int lastTime = 0;
void setup() {
size(640, 360);
smooth();
background(255, 255, 255);
for (int i = 0; i < frames.length; i++) {
frames[i] = get(); // Create a blank frame
}
}
void draw()
{
int currentTime = millis();
if (currentTime > lastTime+30) {
nextFrame();
lastTime = currentTime;
}
if(keyPressed) {
if (key == 'q' || key == 'Q') {
fill(0, 0, 255);
}
} else {
fill(255);
}
rect(mouseX, mouseY, -10, 10);
if(keyPressed) {
if (key == 'w' || key == 'W') {
fill(0, 255, 0);
}
} else {
fill(255);
}
rect(mouseX, mouseY, 10, -10);
if(keyPressed) {
if (key == 'e' || key == 'E') {
fill(255, 0, 0);
}
} else {
fill(255);
}
rect(mouseX, mouseY, 10, 10);
if(keyPressed) {
if (key == 'r' || key == 'R') {
fill(0, 255, 255);
}
} else {
fill(255);
}
rect(mouseX, mouseY, 10, 10);
if(keyPressed) {
if (key == 't' || key == 'T') {
fill(255, 255, 0);
}
} else {
fill(255);
}
rect(mouseX, mouseY, 10, 10);
if(keyPressed) {
if (key == 'y' || key == 'Y') {
fill(255, 0, 255);
}
} else {
fill(255);
}
rect(mouseX, mouseY, 10, 10);
}
void nextFrame()
{
frames[currentFrame] = get(); // Get the display window
currentFrame++; // Increment to next frame
if (currentFrame >= frames.length) {
currentFrame = 0;
}
image(frames[currentFrame], 0, 0);
}
1