Collecting common patterns, code snippets, solutions used in processing programs


There are many common solutions or code snippets and patterns used in processing programs. It would be useful for all of us if they could be collected to a one place. I’ve found some of them, but I’m sure there are tens or hundreds I’ve never heard of.

Such a resource would be very useful for beginners. It would lead them to well tried and working solutions. It would ease learning processing and promote good solutions and style. It would be useful for a programming veteran like me, because there’s a lot I don’t yet know about processing.

I was think it would be like a cookbook. Recipes how to do things in processing way. And as in recipe there is condensed step by step instructions - that would be code - and a more verbose description that explains things.

To make this possible we would need to

  • Identify recurring and processing like program structures
  • analyze them
  • write code and make sure it works
  • write description of code. What is the idea, what makes it tick, how and when should it be used

There should be a pedagogical aspect, practical aspect and artistic aspect in these “recipes”.

So is somebody else interested? I assume this would be beneficial to processing in general and perhaps foundation would support this in some way.


The deadline for this year has passed, but you might look into Google’s Summer of Code. This would have been an interesting proposal for that.

Also note that there are many existing resources, so you might start by looking into what’s already out there.

1 Like

Hi @SomeOne,

Great ideas. I’m familiar with some explicit “recipe book” / “cookbook” resources – for example, The Twine Cookbook, or for Inform Recipe Book.

Are these the kind of things that you have in mind?

I like initiatives like this – a lot! I would want to think more about how specifically this would be different from the way that, for example, the Examples page is already a kind of recipe book, or some of the books are.

For everything all gathered in one place, you also might be interested in contributing to Rosetta Examples, which is published to PDE Contributions Manager: Examples.

It is built on the structure of Rosetta Code, which currently has 1000+ discrete “tasks”.

Now, Rosetta isn’t a native survey of common patterns in processing – most tasks are defined in terms of general computing, not organized around (primarily visual) creative computing. But the example set could grow in that direction, including by defining new tasks that are common for Processing users.

So, I guess what I’m wondering is – what do you have in mind, specifically? Share more details – and maybe throw in some concrete examples for potential recipe titles. For example, right now Rosetta has a thread going for “reverse a string”: Rosetta Challenge! -- Reverse a String


You are right that processing reference is already like a cookbook. And format could be close to it, but scope of the recipes would be wider. Instead of presenting a one command and its use a larger structure or a concept would be presented.

  • One example is widely used 1) clear background 2) draw all the graphical elements 3) repeat to infinite.
  • A visual effect of shapes coming from center of draw area 1) copy(x,y,width-x*2,height-y*2, 0,0,width,height) 2) draw something in the center
  • Or how to get numerical values in certain range. Possible choices are for example 1) map() 2) sin() gives values in range [-1,1]
  • Using randomness 1) random() 2) noise() 3) sin(millis()) and list goes on

What would or could be unique is lack of linearity. A book contains linear chapters and the whole book can be linear. In this case and like in regular cookbooks recipes are grouped by ingredients. Grouping could be done with tags. This is a rough idea still. So tags could be like visual (for creating a visual effect) or number (anything related to working with numbers). In the end this depends on what kind of recipes are found and included.

Most natural way of presenting would be website, because recipes form a web of connections. A book might work and PDF with internal links and indexes should contain internal connections nicely.

Some of these ideas are still very rough as they would be since this is yet just a wild idea that’s been nagging me for a while.

This has also pervaded my thoughts…
I am writing and cataloging a lot of snippets, examples and functional modules for my personal use.
I keep them simple so they can be easily used in larger projects.
Cleaning these up just for my personal use is a lofty goal; for sharing or publication a monumental effort.
If only I had the time!

The web version of these is not compete and several (5 of them) of the “Topics” are missing:

They are (did not check them all) available with the Processing IDE installation.

The processing references can definitely be cleaned up; since this is a community project I have to find time to submit these as issues. These could also be complemented with community contributions; on the website or even in the forums. A separate category in the forums perhaps for the “Processing references”? As long as it stays on point…
I remember referencing examples and being stuck adding fonts as an example.

I do appreciate that they exist and the personal efforts of a stalwart team at the Processing Foundation and all the community contributions.

Sometimes we just need to be pointed in the right direction and I have been sharing these (below) to get our visitors started:

One of the best tools in a programmers tool chest is knowing the resources available to you and learning to navigate and use them.

This is a very short list:

Resources < Click here to expand !

I encourage you to review the resources available here:

As I stated it is a very short list… and my cup spilleth over with links to resources and bookmarks.

Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime

Less is more and can apply to this topic. I find the best examples to be the simple ones; especially for new programmers. Even I get carried away but am learning to bridle my enthusiasm with some restraint.

And so the journey continues…


I think short examples are good for beginners. And they would support reference nicely. For intermediate or advanced programmer reference doesn’t always contain enough information. Especially how to combine things. Then a bit longer examples with two or three elements would be good. And I think common patterns or recipes would help a lot. And it would be a good way to share best practices.



I am on board with much of what you are saying.

Simple (not necessarily short) means just the essential code to illustrate something.

Complex examples can also be simple and the sum of their parts.

I used this as an example to students to show communication between devices.

Each building block was simple to write and understand and then I integrated them all.

Later I joined the lines and added fading to look like a heart monitor or old analog scope.
That is an embellishment that I demonstrate “the possibilities” but did not show or share the code; this would have unnecessarily complicated the example.

Even joining the lines later spawned off in to a whole separate topic that could be integrated.
As well as saving the data for replaying.

Simple working functional modules and steps is something I emphasize when guiding coders that can be easily integrated into a larger project.