Archive of articles classified as' "processing"

Back home

Using stochastic processes to generate paint type effects in processing.org

15/06/2010
I very much like to play with processing.org when I’ve got some downtime. I’ve wrote a small particle engine a while back in the framework and this time I thought I’d try and do something a little more arty from the outset. My inspiration for this “sketch” was the many splatter paintings by Jackson Pollock. I can remember going to see some of his work at the Tate modern in London quite a long time ago. I had always thought it a bit poor as “art” when I was a kid but later on I developed an appreciation for the format. If you have no idea what I’m talking about, this is an example:
Now my sketches don’t look much like this but I did capture some of that splattering chaotic effect that I wanted. The basic process is very simple, a class called a Walker will randomly make its way across the canvas. As it moves the vector distance of each step is calculated. If the step is big enough it causes a burst of circles to be drawn, each with a slightly random position & varied alpha to give it some texture. To avoid it becoming a little too busy I’ve limited it to a set palette at runtime which can be regenerated as walkers are added.

I was quite happy with the random scatter effect as different pools of colour made their way through the canvas space. I thought it would be a nice addition to add in some basic boundary conditions so I added a quick polygon class and added in an array of those. A few functions later and I could click around the screen defining new polygons. Using the well known Jordan Curve theorem we can tell if the walker is currently within an arbitrary polygon (without holes of course). Here’s an example video of it in action. Heart’s seem pretty easy to draw compared to anything crazy complex and give a good idea of the effect:

I’ve added quite a few options to the code now allowing me to switch on & off the boundaries as well as add an arbitrary number of polygons. If the vertices overlap then the way the “point in polygon” algorithm works it will flag each “contained” area as a solid.
Finally here is a nicely captured heart shape. It gives a nice idea of the kind of effect when combined with a boundary. I think playing around with the way the walkers are coded could be fun, for example doing a neighbour check and tweaking the randomised movement accordingly could create a weak flocking style system with Brownian motion driving it.
If you’re interested in checking the code out you can find it over on github. It should run for you ok out of the box within your processing environment.
No Comments

Old school demo effects: #2 – the raster bar

9/02/2010

I have been using processing for a while now, mainly as a sort of relaxing digression from coding web apps & scripts all day. As a child of the 8-bit era I grew up looking at demos which tended to have a few recurring themes. One of these is the classic “plasma” which I’ve already coded and another was animated “scrollers” which typically consisted of a fuax-3d bar which would bouce up & down the screen.

I created this rough version last night before bed. A scroller class gives it a random start/end color and then a number of intermediate stages are interpolated between them. The brightness of the interpolated colors varies with time to give it a bit more life. Its not really finished yet. Code below the video.

Read the rest of this article »

No Comments

Beginnings of a particle system in processing

1/02/2010

I have been getting more & more into processing and who doesn’t love particles? I’ve started the basis of a little particle system, there are plenty of examples at openprocessing.org but I wanted to write my own as an exercise. It’s been quite some time since I properly used even pretty basic maths for physics so I’ve been enjoying revisting old uni notes & following through my old engineering books.

I have it colliding in a rough way with the walls. There’s no horizontal component to forces yet, it just drifts as time increases rather than falling straight down. It goes crazy as I’m changing the “gravity” throughout. Hopefully this will continue to grow as I add bits and (re)learn the concepts. So far this probably about 100-150 lines of code, not a lot.

No Comments

Processing – spiraly line draw thingy

31/01/2010

I’ve been reading through the vector section on the processing.org reference site and quickly played around with one of the examples showing locking to the center point whilst the mouse moves around to draw spirograph style patterns. Hitting spacebar will clear the screen whilst left/right will increase the size of the circular path the target point moves around. Up/Down adjust the line alpha. This is the sort of quick prototyping that makes processing so much fun. Yeah, fun. If I was a kid these days with a linux setup (or really just the opendisc on dvd) I would consider myself lucky. Then again I grew up playing around with assembly on a C64. I don’t think I’d give up those days, being around since the 8bit era (and old enough then to appreciate it) I’m always amazed when I sit down at my linux box at just how far we’ve come.

I’m even more amazed by the huge amount of great open source software. You really do not need to pay or pirate to make money with a computer these days. Especially as a coder. If you’re a .NET person by choice fair enough. I don’t think I could take a job now that side of the industry, I’m pretty much a FOSS and FOSS only sort of person now. I am of course, incredibly lucky to be in that position. A lot of dev’s can’t make those calls and have to work with whats given.

I seem to have gone off on a tangent there. Code follows after the jump. You can paste that into the processing editor and hit play.

Read the rest of this article »

No Comments

Old school demo effects: #1 – the plasma

31/01/2010

I have finally gotten around to playing with processing – a java based set of libraries and functions for visual programming. It’s really a lot of fun. It’s great for doing quick and easy interactive visualizations. With minimum code you can start drawing simple geometric shapes and when you start throwing around a few sine curves and mouse co-ordinates you’d be surprised what can come out.

One thing I’ve always promised myself I’d code was a plasma effect. A stalwart of the 8-bit demoscene I’m not sure why it’s taken so long for me to get round to actually coding one from scratch. As you can guess, processing made it pretty straightforward. Here’s the result:

This plasma harks back to one of the first group assignments I had at university where we were given an FPGA and we had to load in a picture of Lena and do something with it. The plasma never materialised, instead we ended up doing a convolution kernel. I can remember we had around 2 weeks to do it (teams of 4 or 5) and write a little report. I wrote this in the space of an hour or two.

If you’ve never used it before and have always wanted to do a bit of abstract graphical programming I’d highly recommend it. The core keywords/methods are all pretty sensible and once you’ve worked through a few basic “sketches” the whole thing begins to gel easily and you start thinking less about the code and more about what you want to do on screen.

Here are a few images I’ve created via scanning each sampled point and matching it with others in the image within a threshold. A bezier line then connects the points.

No Comments