Reset initial image
in
Programming Questions
•
2 years ago
Below is a simple sketch I'm playing with - a visualization of the simstim switch in William Gibson's novel "Neuromancer". Can anyone please give me a hint as to how to end the loop and reset the initial image after a couple second delay? Seems simple enough, but after playing with delay(), endLoop, and recalling the initial image, i'm still stumped.
PImage img;
void setup() {
size(400, 400);
smooth();
img = loadImage("simstim switch off 2.jpg"); //load initial image
}
void draw() {
background(35);
image (img, 75, 25); //set image location (from upper left-hand corner)
if (mousePressed) {
img = loadImage("simstim switch on 2.jpg"); //load second image if mouse pressed
image (img, 145, 115);
background(random(255)); //keeps the background color changing each loop through the code - makes the flashing effect
stroke(255, 35);
for (int y = 20; y <= height - 20; y += 10) { //for loop to change y value
for (int x = 20; x <= width - 20; x += 10) { //same for x value
fill(255, 255, 0);
line(x, y, width/2, height/2); //draw a line to center of the screen. because of the for loops, the program will continue to
//draw multiple lines, completing the visualization
}
}
}
//
// delay(3000);
}
// void mouseReleased() {
// setup();
//}
1