Skip to content

Instantly share code, notes, and snippets.

View kylemcdonald's full-sized avatar

Kyle McDonald kylemcdonald

View GitHub Profile
@kylemcdonald
kylemcdonald / thin.h
Created November 1, 2011 02:24
morphological thinning for openFrameworks
#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
kylemcdonald / lineart.h
Created November 4, 2011 08:44
lineart rendering for openFrameworks
#pragma once
#include "ofMain.h"
void drawModel(ofMesh& mesh) {
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(ofVec3f), &mesh.getVerticesPointer()->x);
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, sizeof(ofVec3f), &mesh.getNormalsPointer()->x);
if(mesh.getNumIndices()){
glDrawElements(ofGetGLPrimitiveMode(mesh.getMode()), mesh.getNumIndices(), GL_UNSIGNED_INT, mesh.getIndexPointer());
}else{
@kylemcdonald
kylemcdonald / oneliner.fs
Created November 12, 2011 14:24
one liner
/*
GLSL fragment shader implementing the one line synthesis pattern.
http://countercomplex.blogspot.com/2011/10/algorithmic-symphonies-from-one-line-of.html
*/
#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
@kylemcdonald
kylemcdonald / ArduinoTemperatureFlashlight.ino
Created December 8, 2011 18:22 — forked from jywarren/blinkm-maxm-rgb-knob.ino
BlinkM MaxM RGB color from a knob
#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
kylemcdonald / combine.sh
Created January 5, 2012 16:51
Combine all static libraries in the current directory into a single static library.
#!/bin/bash
read -p "Enter the name for the combined library: " name
for f in *.a
do
/usr/bin/ar x $f
done
rm *SYMDEF*
/usr/bin/ar rcs $name *.o
rm *.o
@kylemcdonald
kylemcdonald / MeshJitter.py
Created January 12, 2012 00:02
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 = []
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
end
@kylemcdonald
kylemcdonald / scratchml.xml
Created January 22, 2012 23:19 — forked from jamiew/scratchml.xml
ScratchML draft spec v3
<sml>
<!--
# SCRATCH MARKUP LANGUAGE, WORKING DRAFT
http://scratchml.com
* 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
kylemcdonald / the-list-of-life.md
Last active January 17, 2022 05:14
A short story about lists.

THE LIST OF LIFE

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
kylemcdonald / ofxGlobalUtils.h
Created June 22, 2012 21:24
openFrameworks utilities for working with the mouse and screen even when an app does not have focus
#pragma once
#include "ofGraphics.h"
#include "ofImage.h"
class ofGlobalListener {
public:
ofGlobalListener();
virtual void globalMouseDown(float x, float y) = 0;
};