Skip to content

Instantly share code, notes, and snippets.

@indefinit
indefinit / Ball.h
Created February 21, 2018 21:40
Example of a custom cpp class Ball with boolean methods
#include "ofApp.h" //include ofApp so you can use OF defined functions and vars
class Ball {
public:
Ball();//constructor
~Ball();//destructor
//current ball position, you'll need to initialize
//this somewhere in your constructor or another method
ofVec2f mBallPos;
bool checkIntersects(const ofVec2f &positionToCheck);
Sailboat.prototype = {
constructor: Sailboat,
sail : function(){
if(this.xpos > width)
{
this.xpos = -200;
this.ypos = random(height);
}
this.xpos = this.xpos + this.speed;
}
var particles = [];
function draw(){
for (var i = 0; i < particles.length; i++) {
//render your elipse with particle properties as x and y values
ellipse(particles[i].positionX, ...);
};
}
@indefinit
indefinit / antarctica_weather_averages.csv
Created April 15, 2016 20:55
table.getColumn() error repro
ANNUAL JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC YEARS # CITIES
Average Temperature (F) 7 24.5 18.3 10 3.4 -0.8 -4.3 -6.7 -7.1 -3.5 4.6 15.7 23.7 23 48
Average High Temperature (F) 5.7 25.9 18.2 7.4 0.2 -3.1 -6.3 -8.6 -9.2 -5.4 3.7 16.4 25.2 16 28
Average Low Temperature (F) -6.7 15.9 7.4 -3.9 -11.6 -15.6 -19.4 -22.5 -23.4 -19.7 -10.3 4.2 14.9 16 28
Average Precipitation (in) 16.4 1.1 1.3 1.6 1.7 1.5 1.3 1.5 1.4 1.6 1.4 1.1 1.1 17 26
@indefinit
indefinit / loadTable.js
Created April 15, 2016 19:35
loadTable suggested changes
p5.prototype.loadTable = function (path) {
var callback = null;
var options = [];
var header = false;
var sep = ',';
var decrementPreload = p5._getDecrementPreload.apply(this, arguments);
var args = new Array(arguments.length);
for (var i = 0; i < args.length; ++i) {
args[i] = arguments[i];
}
@indefinit
indefinit / image_magick_cheatsheet.sh
Created January 20, 2016 17:03
A cheat sheet for working with imagemagick
#description: convert an image sequence to an animated gif, and resize to 500px x 500px, preserving aspect ratio
convert -delay 0 -loop 0 resize 500x500 defaultCanvas0-000000*.png animated-500.gif
@indefinit
indefinit / ffmpeg_cheat_sheet.sh
Last active May 29, 2022 12:45
A working cheat sheet for ffmpeg
#use case: converting image sequence to .mp4 video
#official documentation: https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images
#description:
# An image sequence follows the pattern, defaultCanvas0-000000000.png (9 zeros)
# video codec is libx264
# pixel format yuv420p
# output file is named out.mp4
ffmpeg -i 'defaultCanvas0-%9d.png' -c:v libx264 -pix_fmt yuv420p out.mp4
#if you want your image sequence to start on a different number than index 0, use the -start_number parameter
@indefinit
indefinit / untar.sh
Created January 20, 2016 14:48
bash commands for unwrapping .tar archives
#on mac and linux
# xvf means [x]: extract, [v]: verbosely, [f]: following is filename
tar xvf [tar_name].tar #replace [tar_name] with name of tar
#on windows
#you could use cygwin or the 7-zip utility: http://www.7-zip.org/
@indefinit
indefinit / sketch.js
Created November 24, 2015 19:51
Tall-short-example
//code by:
// https://github.com/Jared-Sprague
var spriteSheet;
var tall = 220;;
var short = 260;
var plantPosX = tall;//our plant position defaults to our tall position
function setup() {
createCanvas(600, 600);
background(200);
spriteSheet = loadImage('image/sprite_sheet.jpg');
@indefinit
indefinit / timing-list.js
Last active October 15, 2015 15:07
An example of using an object literal to schedule timing.
//define an object that holds lyrics and time codes
//key = time in millis
//val = "lyrics"
var timecodes = {
100 : "One, two, three! My baby don't mess around Because she loves me so This I know fo sho!",
5000 : "But does she really wanna But can't stand to see me walk out the door Don't try to fight the feeling Because the thought alone is killin' me right now Thank God for Mom and Dad For sticking to together Like we don't know how"
};
//function to process and schedule lyrics.
//we pass an object as parameter to this function