Reamde sketch now successfully switches from readme to reamde depending on mousePressed.

A preliminary sketch referencing the novel Reamde by Neal Stephenson. This sketch takes the definition of a readme and switches every “readme” to “reamde”.

 

So I’ve been fooling around with some line stuff. This tutorial serves to teach you how to make a sketch that draws lines in response to mouse movement.

 

First step, as always, is to set the window size.

void setup() {
size (500,500);
background(255);

}

 

Next, we have to write the draw function to create the lines. This function will continuously execute, generating a new line each time.

void draw() {

stroke(0);
fill(0);
line(250,250,mouseX,mouseY);

}

 

Finally, you can add a bit of code that creates a series of lines at each click of the mouse.

void mousePressed() {

stroke(0);
fill(0);
line(mouseX,mouseY,0,0);
line(mouseX,mouseY,500,500);
line(mouseX,mouseY,0,500);
line(mouseX,mouseY,500,0);

}

It’s a pretty simple piece of code, but the results are interesting!