Skip to content

Instantly share code, notes, and snippets.

@marcedwards
Created June 6, 2018 12:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcedwards/4973523b98e0c30d10351b58e96596a5 to your computer and use it in GitHub Desktop.
Save marcedwards/4973523b98e0c30d10351b58e96596a5 to your computer and use it in GitHub Desktop.
Processing source code for a counter that displays seconds and 100ths of a second.
// A counter that displays seconds and 100ths of a second.
// By @marcedwards from @bjango.
//
// You’ll need to use Tools › Create Font to convert a font file to a Processing .vlw file.
// Created using Processing 3.3.7.
PFont font;
float time = 0;
void draw() {
background(0);
fill(255);
time = float(frameCount) / 30;
text(nf(time, 2, 1), 10, 50);
//render(400);
}
void setup() {
size(200, 100, P2D);
frameRate(30);
smooth(8);
font = loadFont("Lato-Semibold-48.vlw");
textFont(font, 48);
textAlign(LEFT);
}
// Render the animation to PNGs in foldername, then exit.
//
// The number of frames and path are optional.
// Do not include a trailing / in the folder name.
void render(int frames, String foldername) {
saveFrame(foldername+"/frame####.png");
if (frameCount==frames) {
exit();
}
}
void render(int frames) {
render(frames, "render");
}
void render(String foldername) {
render(100, foldername);
}
void render() {
render(100, "render");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment