This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python -tt | |
""" Guardian of the function threshold""" | |
def check_this(x): | |
"""Returns None if value is anything other than a positive int""" | |
if not isinstance(x, int): | |
return None, x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void keyPressed() { | |
// different blend modes | |
if (key == '1') { | |
depthImageBlendMode = BLEND; | |
println("Blend mode: BLEND"); | |
} | |
else if (key == '2') { | |
depthImageBlendMode = ADD; | |
println("Blend mode: ADD"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Handle keypress to adjust parameters | |
void keyPressed() { | |
println("*** FRAMERATE: " + frameRate); | |
// up arrow to move kinect down | |
if (keyCode == UP) { | |
kinecter.kAngle++; | |
kinecter.kAngle = constrain(kinecter.kAngle, 0, 30); | |
kinecter.kinect.tilt(kinecter.kAngle); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* switch case example - unknown source: | |
When you want to create a simple menu or perhaps a program | |
that moves through different screens, the best way to do it | |
is by using a switch. This is clearer and faster than the | |
alternative if-else structure in these circumstances. | |
A switch will allow the user to easily move back and | |
forth through different screen, for example via keyboard | |
or mouse input. To keep things clearly readable, | |
my advise is to refer to seperate functions for each |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-env node, mocha */ | |
import "babel-core/external-helpers"; | |
let chai = require('chai'); | |
chai.should(); | |
chai.expect(); | |
import Point from '../src/oak-roots/Rect'; | |
// calls each test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////// | |
// Validate point & point-like objects | |
////////////////////////////// | |
static isPointLike(thing) { | |
// RETURNS true if exactly what we want | |
if (thing instanceof Point) return true; | |
////////////////////// | |
// RETURNS true if its kinda-like what we want, that is: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////SLIDERS////// | |
in setup() | |
slider = createSlider(min, max, initial); | |
slider.position(x,y); | |
slider.style('width', '80px'); | |
in draw() | |
var val = slider.value(); | |
background(val); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*thx shiffman! | |
http://shiffman.net/general/2011/12/23/night-4-sorting-the-vertices-of-a-polygon/ | |
One solution for solving this problem is to always | |
sort all of the vertices according to their relative angle from the center. | |
Let’s say you calculate the center of the polygon as the average location of all vertices. | |
void mousePressed() { | |
vertices.add(new PVector(mouseX,mouseY)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void draw() { | |
// If we are recording call saveFrame! | |
if (recording) { | |
saveFrame("output/frames####.png"); | |
} | |
} | |
void keyPressed() { | |
// If we press r, start or stop recording! | |
if (key == 'r' || key == 'R') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*trails with alpha rectangle - UPDATED with blendMode(SUBSTRACT); | |
There’s the quite well-known technique of painting a more or less transparent rectangle each frame (instead of a full background) | |
in order to get objects to create more or less long trails, | |
but if you set the alpha below a certain value, like 25, then you start getting smudgy ‘leftovers' | |
//shiffman's quick hack | |
fill(0,1); | |
rect(0,0,width, height); | |
//updated with blendMode |