Coding in the Office

We talk constantly in the classroom with how useful coding is. Not only do future software developers need to learn coding skills (obviously…), but almost anyone who works in any kind of job can benefit from understanding some basic tools of the trade.

We have tons of little bits of code in use to help us keep the Academy of Code running smoothly. These include spreadsheet formulas and macros for student lists (including tracking attendances and scores across multiple venues) and cashflow forecasting, Python scripts for generating class lists from the output of our booking system, custom bits of code to make our website do exactly what we want, and lots else besides.

Today we needed to send off some certificates for a course we’re running for the Life Skills Academy in Blackrock College. We had some lovely certs from last year’s UCD event (see below), but a designer working on some other projects for us had thrown together the background texture and we didn’t have a copy in the office. We could have reached out to get access to a copy, but that could take a few hours if not a few days, and the certs are needed now!

(Not everything is always so last minute, we hasten to add. Although when you’re moving the speed we’re moving, sometimes just-in-time is actually a pretty decent bar to be clearing!)

Template.png

Luckily enough, drawing patterns of circles is something Processing is very good at, and Processing just so happens to be our main teaching language.

We weren’t shooting for an exact replica, but figured that we should be able to get something very servicable in a dozen or so lines of code. There was a bit of trial and error involved in getting a pattern we were happy with, but broadly speaking what we came up with after ~15 minutes of fiddling with parameters was a cert we were ready to take to the printers.

Clockwise from top left: original without background texture; first background texture attempt (circles shrink too quickly); happy with the size but the circles only fade horizontally; bottom left is what we were after!

Clockwise from top left: original without background texture; first background texture attempt (circles shrink too quickly); happy with the size but the circles only fade horizontally; bottom left is what we were after!

The code for this involves nested for loops, which are introduced around in grade 6 of our curriculum:

size(2970, 2100);
background(255);
noStroke();
for (int i = 29; i > 0; i --) {
  float k = 90;
  for (int j = 20; j > 0; j--) {
    fill(255, 120, 36, i * j / 5);
    ellipse(i * 100, j * 100, k, k);
    k -= 2.5;
  }
}
saveFrame();

There’s nothing revolutionary in this, and we certainly could have done something similar in Paint given enough time, but we figured it was a good example of where coding can provide a shortcut to those in the know. Even for those with no intention of being full time software developers, a little knowledge can go a long way. And honestly, if you enjoy puzzles, it’s incredibly satisfying to be able to puzzle your way through a few lines of code in service of your day job.

Happy coding!