Skip to content

Instantly share code, notes, and snippets.


Kyle McDonald kylemcdonald

View GitHub Profile
kylemcdonald / thin.h
Created Nov 1, 2011
morphological thinning for openFrameworks
View thin.h
#pragma once
#include "ofMain.h"
inline void thin(ofPixels& img) {
int w = img.getWidth(), h = img.getHeight();
int ia1=-w-1,ia2=-w-0,ia3=-w+1,ib1=-0-1,ib3=-0+1,ic1=+w-1,ic2=+w-0,ic3=+w+1;
unsigned char* p = img.getPixels();
vector<unsigned int> q;
for(int y = 1; y + 1 < h; y++) {
for(int x = 1; x + 1 < w; x++) {
int i = y * w + x;
kylemcdonald / lineart.h
Created Nov 4, 2011
lineart rendering for openFrameworks
View lineart.h
#pragma once
#include "ofMain.h"
void drawModel(ofMesh& mesh) {
glVertexPointer(3, GL_FLOAT, sizeof(ofVec3f), &mesh.getVerticesPointer()->x);
glNormalPointer(GL_FLOAT, sizeof(ofVec3f), &mesh.getNormalsPointer()->x);
glDrawElements(ofGetGLPrimitiveMode(mesh.getMode()), mesh.getNumIndices(), GL_UNSIGNED_INT, mesh.getIndexPointer());
View oneliner.fs
GLSL fragment shader implementing the one line synthesis pattern.
#extension GL_EXT_gpu_shader4 : enable
const int width = 512; // assumes you're drawing at 512x512
void main() {
int t = int(gl_FragCoord.y) * width + int(gl_FragCoord.x);
int c = t*5&(t>>7)|t*3&(t*4>>10);// miiro
View ArduinoTemperatureFlashlight.ino
#include <i2cmaster.h>
#include "Wire.h"
#include "BlinkM_funcs.h"
const float lowReading = 75;
const float highReading = 110;
const int blinkm_addr = 0;
const unsigned char separatorCharacter = 255;
void setup(){
kylemcdonald /
Created Jan 5, 2012
Combine all static libraries in the current directory into a single static library.
read -p "Enter the name for the combined library: " name
for f in *.a
/usr/bin/ar x $f
/usr/bin/ar rcs $name *.o
rm *.o
kylemcdonald /
Created Jan 12, 2012
Rhino/Python script the randomly jitters mesh vertices along their normals, scaled by the face size.
import rhinoscriptsyntax as rs
import math, random
obj = rs.GetObject("Select mesh", rs.filter.mesh, True)
sigma = rs.GetReal("Gaussian sigma", .1)
vertices = rs.MeshVertices(obj)
faces = rs.MeshFaceVertices(obj)
normals = rs.MeshVertexNormals(obj)
if vertices and faces:
modified = []
View sketchup_downloader.rb
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'httparty'
unless ARGV[0] && ARGV[1]
puts "Usage: ruby sketchup_downloader.rb path/to/terms.csv path/to/folder"
exit 1
kylemcdonald / scratchml.xml
Created Jan 22, 2012 — forked from jamiew/scratchml.xml
ScratchML draft spec v3
View scratchml.xml
* version -- minor versions for small changes, major for incompatibilities
* info -- general file metadata: author info, client info etc.
* turntable - hardware metadata
* mixer -- hardware metadata
kylemcdonald /
Last active Jan 17, 2022
A short story about lists.


By T. Q. McReilly-Wigglesworth

I stumbled onto this short story, written by a fictional author, embedded within a novel, after searching for a "list of unlistable things". It originally appeared in "FOOL THE GUESSER: A Novel Written in Two Weeks", which was written as part of the Iowa City Poetry Marathon in 2010. I believe the author is Dave Morice, and the Marathon was his solo attempt. The original text was available at the Marathon website but has been edited to correct for what appear to be OCR errors. - Kyle McDonald

I have a habit of making up lists. My very first list, which I wrote in first grade, was a list of all lists I wanted to make in the future. That list began with my second list, which was called "a list of my very first list." My third list came next, but I lost it soon after I made it. My fourth list was a list of lists I'd lost. My fif

kylemcdonald / ofxGlobalUtils.h
Created Jun 22, 2012
openFrameworks utilities for working with the mouse and screen even when an app does not have focus
View ofxGlobalUtils.h
#pragma once
#include "ofGraphics.h"
#include "ofImage.h"
class ofGlobalListener {
virtual void globalMouseDown(float x, float y) = 0;