Embedding Processing sketches

This is my first attempt at embedding a processing sketch into a webpage (many thanks to Paul Green for showing me how)

Here’s what to do;

PressĀ left mouse button to generate a shape

Press right mouse button to darken the image

Press any key to start over

//Info: http://processingjs.org/reference

void setup() {
size (600, 440);
background(10, 15, 15);

void draw() {

void mousePressed() {
if (mousePressed &&(mouseButton == RIGHT)) { // subtle eraser
stroke (random(10,20),random(10,20),random(10,20),(random(17,23)));
int x1 = ((int)random(1, width));
int y1 = ((int)random(1, height));
for (int count = 0; count < 30000; count ++) {

if (mousePressed &&(mouseButton == LEFT)) {

int xx1 = (mouseX);
int yy1 = (mouseY);

int wwidth = ((int)random(10, 110)); // adjust rectangle size
int xright = xx1+wwidth;
int xleft = xx1-wwidth;
int hheight = ((int)random(10, 70)); // adjust rectangle size
int ydown = yy1+hheight;
int yup = yy1-hheight;

colourpick(); // pick random colour for lines
scale = (hheight*wwidth); // makes larger rectangles denser
if(scale 7000) {loop=30000;}

for (int count = 0; count =xright) { // keeps line inside box
xx2 = xx2-((int)random(15, 20));
if (xx2=ydown) {
yy2 = yy2 -((int)random(15, 20));
if (yy2=width) { // keeps line inside box
x2 = x2-((int)random(15, 20));
if (x2=height) {
y2 = y2 -((int)random(15, 20));
if (y2<=0) {
y2 = y2 +((int)random(15, 20));

line (x1, y1, x2, y2);


3 thoughts on “Embedding Processing sketches”

  1. Dominic, i love them all, i wish i could save the images to print after!!!
    ill have a think about other artists that might be suitable but im sure youll think of them yourself, what about in the book, sol le witt a retrospective what about doing a sol la witt

    1. Thanks Michelle,
      Sol would be a good fit all right, will look into it in a bit. Windows has a little app under accessories called snipping tool, which lets you draw a box around anything on the screen and save it easily. Maybe iMacs have something similar?

Leave a Reply

Your email address will not be published. Required fields are marked *