We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Made this little program as I am learning processing and I am wondering if I can make the stroke that is moving all over the screen opaque at times like intervals or every few seconds.
int windowX = 500; // Should work if window dimensions change
int windowY = 400;
float lineStartX = windowX * 0.5; // Start in the middle of the window
float lineStartY = windowY * 0.5;
float endX = 0; // Remember where line segment ended
float endY = 0;
float maxDev = 5; // Max deviation for both x and y
float bias = 1; // Bias the deviation in positive direction
void setup()
{
size(windowX, windowY);
//frameRate(10); // Slow it down to see movement better
background(255);
strokeWeight(1);
//noSmooth(); // Turn on to demonstrate that smooth is on by default
}
void draw()
{
stroke(0);
endX = random(lineStartX - maxDev, lineStartX + maxDev + bias) % width;
endY = random(lineStartY - maxDev, lineStartY + maxDev + bias) % height;
line(lineStartX, lineStartY, endX, endY); // Draw line from start to end
lineStartX = endX; // Remember where we ended up so we can start there
lineStartY = endY; // next time
}
Answers
Simply have the stroke depend on the time:
or: