Processing Month, Day 12 - Painting, Part 3

Posted by Jan Vantomme on 12 May 2011.
Tags: ,

For the last sketch in this painting series, we are going to take a similar approach as the sketch from yesterday, but we’ll create an autonomous painting system. We’ll create a Brush class so we can create multiple brushes, and let them do the painting for us.

In the Brush class, we’ll need a PVector for the location of the brush, a float for the size and the rotation of the brush and a color. In the constructor, we’ll set the coordinates for the PVector, the size of the brush and the rotation of the brush to a random value.

= new PVectorrandom(width), random(height) );
r   random(515);
rot randomTWO_PI );

To move the brush, we are going to use Brownian motion. We’ll add a random value between -2 and 2 to the x and y coordinates of the brush. We also need to constrain the values of those coordinates so our brush doesn’t go off-screen never to return.

void update()
.+= random(-22);
loc.+= random(-22);       
loc.constrainloc.x0width );
loc.constrainloc.y0height );
getTransparentColorimg.getfloor(loc.x), floor(loc.y) ), 64);
rot += 0.01;

I’ve used a rectangle for the brush in this sketch because that will work better with rotation. The code for drawing the brush to the screen looks like this:

void render()
rotaterot );
stroke064 );

To draw the brushes to the screen, you’ll need to use a similar technique as we did on day 8, Animating Bubbles.


Make your painting a little more interesting by using the star we’ve drawn on day 4 as a brush.


The original image

A digital painting made with our autonomous painting system.

A digital painting made with our autonomous painting system.



Download the example for Procesing Day 12.

Tweet this article

Oldskool Comments (2)

Gravatar for bin

From: bin
Date: 09.06.2011

this is really helpful stuff for beginners! Thanks for the great work

Top · Permanent link to this comment

Gravatar for Justin Lincoln

From: Justin Lincoln
Date: 09.06.2011

Lovely code. I like watching it in action. Posted a video here of that process. Thanks.

Top · Permanent link to this comment