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
// how to center the screen in processing. I have the hardest time remembering, much less intuiting, this: | |
size( 200, 200 ); | |
int l = 0; | |
int b = 70; | |
int r = 500; | |
int t = 700; | |
float xres = width/float(r-l); |
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
// I, Brandon Martin-Anderson, release this into the public domain. | |
// Do whatever you want with it. | |
// A simple app for learning how scale() and translate() work. | |
// Left click and drag to scale. | |
// Right click and drag to translate. | |
// Spacebar to switch to between translate-first, and scale-first. | |
float xscale=1; | |
float yscale=1; |
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
import java.awt.event.*; | |
class Path { | |
ArrayList points; | |
Path() { | |
points = new ArrayList(); | |
} | |
void add(float x, float y) { | |
this.points.add( new PVector( x, y ) ); |
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
class Landcover { | |
color DEVELOPED_HIGH = -5636096; | |
color DEVELOPED_MEDIUM = -917504; | |
color DEVELOPED_LOW = -2385534; | |
color DEVELOPED_OPEN = -2044724; | |
color SHRUB = -3032446; | |
color FOREST_EVERGREEN = -14916045; | |
color FOREST_MIXED = -4535151; | |
color FOREST_DECIDUOUS = -9721242; | |
color WETLAND_WOODY = -4531987; |
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
import urllib | |
import json | |
URL = "http://www.car2go.com/portal/sandiego/page/mybookings/mapEnlarged.faces" | |
KEY = "ptvMap.data = " | |
def grab_sandiego_vehicles(): | |
#get site HTML | |
fp = urllib.urlopen( URL ) | |
sitestr = fp.read() |
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
class PixelBuffer { | |
Color[][] colors; | |
int width; | |
int height; | |
PixelBuffer(int width, int height) { | |
this.colors = new Color[width][height]; | |
this.width=width; | |
this.height=height; | |
} |
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
//print biohazard symbol, at http://fab.cba.mit.edu/classes/S62.12/people/martinanderson.brandon/solver2.html | |
function makecircle(r){ | |
return function(x,y){ | |
return Math.pow(x,2) + Math.pow(y,2) < Math.pow(r,2); | |
} | |
} | |
function translate(tx, ty, func){ | |
return function(x,y){ |
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
function sqrt(a){ | |
return Math.pow(a,0.5); | |
} | |
function sq(a){ | |
return Math.pow(a,2); | |
} | |
function rotate(theta, func){ | |
return function(x,y){ |
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
function makerectangle(left,right,bottom,top){ | |
return function(x,y){ | |
return (x>left && x<right && y > bottom && y < top) | |
} | |
} | |
function makecircle(cx,cy,r){ | |
return function(x,y){ | |
return Math.pow(x-cx,2)+Math.pow(y-cy,2)<Math.pow(r,2) | |
} |
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
function translate(tx, ty, func){ | |
return function(x,y){ | |
var xprime = x-tx; | |
var yprime = y-ty; | |
return func(xprime,yprime); | |
} | |
} | |
function dist(x,y){ |