Brendan Dawes

Analogue + Digital


Boiler Plate Template for Processing

When I start a new Processing project I always start from the same base template. This template features some core things that I pretty much always need in any project such as saving out PNGs, exporting PDFs and exporting frames which can then be compiled into a video if need be.

Here's that template:

import dawesometoolkit.*;
import processing.pdf.*;

final String PROJECT = "project-x";
final int BACKGROUND_COLOR = #000000;
final int SECONDS_TO_CAPTURE = 60;
final int VIDEO_FRAME_RATE = 60;

int videoFramesCaptured = 0;
boolean recordVideo = false;
boolean recordPDF = false;

DawesomeToolkit dawesome; //

void setup(){
  dawesome  = new DawesomeToolkit(this);

void draw(){

  if (recordVideo){
    if (videoFramesCaptured > VIDEO_FRAME_RATE * SECONDS_TO_CAPTURE){
      recordVideo = false;
      videoFramesCaptured = 0;
    videoFramesCaptured ++;

  if (recordPDF){
    recordPDF = false;

void keyReleased() {
  if (key == 'p') {
    recordPDF = true;
  if (key == 'r') {
    recordVideo = true;


Auto Populating a pde file with that template using Vim

I picked this tip up from Harry Roberts which means whenever I start a new pde file the contents of that template are automatically populated — really handy!

To enable that, in your .vimrc add this line:

autocmd BufNewFile *.pde 0r ~/Dropbox/vim/Templates/processing.pde

This line says that whenever a new empty file is saved, populate with the contents at the following path.

You can see that I have stored my Processing starter template at ~/Dropbox/vim/Templates/processing.pde You can store it wherever you like but be sure to alter the path to the template at the end of the BufNewFile line.

Restart Vim and when you now make a new pde file you will get the contents of the starter template automatically inserted.