Processing – part 2

simple shapes drawn on screen

A variety of shapes

Time for another look at Processing.  I now have the book Getting Started with Processing, and it seems straightforward so far.  The language is described as a dialect of Java, with custom features for graphic drawing.  The code I’ve used so far can be built up one line at a time, making it feel a little like building up a sketch.  Commands include ellipse, rect, triangle, quad, arc etc, plus beginShape/endShape which draws a shape vertex by vertex.  The stroke, stroke colour, fill colour and transparency can all be set with parameters.

listing for drawing shapes

listing to draw shapes

The code is straightforward, simply the name of the shape followed by parameters which either refer to the on-screen co-ordinates or the dimensions of the shape.  I used a for loop to draw the series of lines – any regular drawing can reuse code in this way, and of course the use of variables can simplify the drawing process as well.

robot drawn with Processing

Simple robot

To draw arcs, the measurement is given in radians, but there is an easy way to convert degrees to radians if you prefer to measure that way.

So far so good; the fun will be learning how to animate the shapes and interact with them.

 

Advertisements

About emmyleigh
Writer/editor/proofreader who loves technology

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: