Skip to content

Instantly share code, notes, and snippets.

@nataliefreed
nataliefreed / scaleUpExample.pde
Created October 14, 2014 22:07
Scale your shapes up without them moving all over the place!
//Scale your shapes up without them moving all over the place!
float scalingFactor = 1;
float x = 100;
float y = 200;
float w = 40;
float h = 30;
void setup()
{
@nataliefreed
nataliefreed / computationaldesigntemplate.pde
Last active August 29, 2015 14:07
Computational Design Project Template
/*
Computational Design!
Title:
Imagined, Designed, and Programmed by:
Date:
Description: <(example, replace text in <>s)This app enables you to create your very own custom pompom makers and export them
to make on a lasercutter! Use the sliders to change the size and inside-to-outside ratio
of the pompom makers.>
@nataliefreed
nataliefreed / fractal_trees.pde
Last active August 29, 2015 14:08
Fractal tree activity
/******************
Activity: Exploring a Fractal Tree!
Ported to Processing from a BJC Snap activity: http://bjc.berkeley.edu/bjc-r/cur/programming/recursion/tree/recursive-tree-part-1.html
Finish as many of these as you can. They are in approximate order of difficulty, but you can do them in any order, at your own pace.
1. Change the left tree to a different color (of your choice). Look for setPenColor for turtle1.
2. Change the parameters of the tree function to make the left tree have 1 level (modify the line of code marked with ***2***).
3. Change the parameters of the tree function to make the left tree have 0 levels.
/******************
Activity: Exploring a Fractal Tree!
Ported to Processing from a BJC Snap activity: http://bjc.berkeley.edu/bjc-r/cur/programming/recursion/tree/recursive-tree-part-1.html
Finish as many of these as you can. They are in approximate order of difficulty, but you can do them in any order, at your own pace.
1. Change the left tree to a different color (of your choice). Look for setPenColor for turtle1.
2. Change the parameters of the tree function to make the left tree have 1 levels (modify the line of code marked with ***2***).
3. Change the parameters of the tree function to make the left tree have 0 level (modify the line of code marked with ***2***).
@nataliefreed
nataliefreed / spiroVector.pde
Created November 9, 2014 04:37
Make and export a hypotrochoid as a vector (PDF)
//Make and export a hypotrochoid as a vector (PDF)
import processing.pdf.*;
import java.util.Date;
float R = 200; //the outer gear number of teeth
float r = 96; //the inner gear number of teeth
float d = 60; //the pen distance as a percentage of the radius
Date date = new Date();
@nataliefreed
nataliefreed / class_generator.pde
Last active August 29, 2015 14:09
Code generator for Processing classes
/*
Hi there!! You should probably not read this code for learning because it is not a good example
in a variety of ways! It was written in a hurry. Also Processing/Java, while being
great for many reasons, is a really terrible language to write code-that-generates-code in (IMHO).
But! You should /run/ this code for learning. :)
-Natalie Freed, Nov 2013
*/
@nataliefreed
nataliefreed / classes_practice.pde
Last active August 29, 2015 14:09
Classes and Objects exercise for Processing
/*
Use the program at https://gist.github.com/nataliefreed/871cd281839a2408f008
to create a CometLander class and add it to make this program work
The class should have these attributes:
-chassisColor (an int)
-speed (how many pixels to add per frame as it moves) (a float)
-location (where it is on the screen) (a PVector)
The class should have these functions:
-descend() (returns void)
/*
Exhibit Invention
Title:
Imagined, Designed, and Programmed by:
Date:
Description:
@nataliefreed
nataliefreed / pages_processing.pde
Created November 24, 2014 04:43
Move between pages example for Exhibit Invention
//Use buttons to move from page to page in Processing
//Natalie Freed Nov 2014 for Art & Science of Computing
import controlP5.*;
ControlP5 cp5;
String currentPage = "intro";
void setup()
@nataliefreed
nataliefreed / password_match_text_input.pde
Created December 2, 2014 22:31
Matching input text against a "correct" text using keyboard input (password match check!)
//Matching input text against a "correct" text using keyboard input
//N Freed for Art and Science of Computing Dec 2014
String inputString = ""; //empty string to begin with
String correctString = "candy is delicious"; //the word we are trying to match
int index = 0;
int fillColor = color(0, 255, 0);
String errorMessage = ""; //start with no error message
void setup()