Skip to content

Instantly share code, notes, and snippets.

View ofZach's full-sized avatar

ofZach

View GitHub Profile
// this code takes a src string,
// tries to fine multiline strings that are
// of the form
// var fs = ` .... ` or let vs = `....`
// and tries to compress them via
// glslx
// I found renaming hard to manage so this is set to not rename. (my approach is to rename myself to something small)
function compressShaders(src) {
// written by Golan Levin
// for example, huntForBlendFunc(1, -1, -1);
void huntForBlendFunc(float period, int defaultSid, int defaultDid){
// sets all possible (24) combinations of blend functions,
// changing modes every period seconds.
int sfact[] = {
GL_ZERO,
@ofZach
ofZach / gist:d67d2ab2a0aa183b7d34f72263d5c5bd
Created November 27, 2017 07:44
looping 1d noise (tiling)
ofPolyline temp;
float ff = ofGetElapsedTimef();
for (int i = 0; i < 100; i++){
float angle = ofMap(i, 0, 100, 0, TWO_PI);
ofPoint pt= ofPoint(400,400);
float radius = 200 + ofSignedNoise(ff*0.1, cos(angle)*0.3, sin(angle)*0.3) * 100;
pt += radius * ofPoint(cos(angle), sin(angle));
temp.addVertex(pt);
}
temp.setClosed(true);
@ofZach
ofZach / gist:e602efb4fbd43858aa01aff6d015ef32
Last active September 15, 2020 15:22
how to make an openframeworks dylib
@ofZach
ofZach / gitignore OF
Created September 12, 2012 14:41
good gitignore for OF
# Some general ignore patterns
build/
obj/
*.o
Debug*/
Release*/
*.mode*
*.app/
*.pyc
.svn/
@ofZach
ofZach / download_flickr_image.py
Last active June 28, 2020 16:48 — forked from yunjey/download_flickr_image.py
downloading images from flickr using python-flickr
# First, you should install flickrapi
# pip install flickrapi
import flickrapi
import urllib
from PIL import Image
from urlparse import urlparse
# Flickr api access key
flickr=flickrapi.FlickrAPI('c6a2c45591d4973ff525042472446ca2', '202ffe6f387ce29b', cache=True)
@ofZach
ofZach / gist:5082043
Created March 4, 2013 12:48
median filter for arduino, uses bubble sort
// medianFilter filter;
// filter.addValue(5);
// filter.addValue(3);
// filter.addValue(2);
// filter.addValue(100);
// filter.addValue(9);
// Serial.println(filter.getMedian());
//
// filter.addValue(100);
// Serial.println(filter.getMedian());
@ofZach
ofZach / gist:8829491
Created February 5, 2014 17:53
smooth line drawing input for openframeworks
#include "testApp.h"
// this can go in your h file;
ofPoint pts[5];
uint ctr;
ofPath path;
ofPolyline lineOrig;
@ofZach
ofZach / gist:787439f86753b7c6a8c6
Created November 26, 2014 05:09
singleton template
#include <stddef.h> // defines NULL
template <class T>
class Singleton{
public:
static T* Instance() {
if(!m_pInstance) m_pInstance = new T;
assert(m_pInstance != NULL);
return m_pInstance;
}
protected:
@ofZach
ofZach / all OF addons
Created October 16, 2012 02:30
all openframeworks addons from ofxAddons
#!/bin/bash
git clone git://github.com/armadillu/ofxAnimatable.git;
git clone git://github.com/yuichi1004/ofxAnimationKit.git;
git clone git://github.com/alinakipoglu/ofxAssimpNISync.git;
git clone git://github.com/alinakipoglu/ofxAssimpOpenNISkeletonSync.git;
git clone git://github.com/after12am/ofxBoids.git;
git clone git://github.com/diasbruno/ofxCompositeMotion.git;
git clone git://github.com/paulobarcelos/ofxDisplayStackObject.git;
git clone git://github.com/satoruhiga/ofxEasingFunc.git;