Skip to content

Instantly share code, notes, and snippets.

Avatar

Natalie Freed nataliefreed

View GitHub Profile
View loops example.js
function setup() {
createCanvas(800, 800);
for(var i=0;i<10;i++) {
if(i % 3 == 0) {
arrow(50, 50, 10, color(255, 0, 100));
}
else {
arrow(50, 50, 10, color(150, 0, 255));
}
View videoFilterStartingPoint.js
//Modified from P5 example at: https://p5js.org/examples/dom-video-capture.html
var capture;
function setup() {
createCanvas(320, 240);
capture = createCapture(VIDEO);
capture.size(320, 240);
capture.hide();
View imageFilterStartingPoint.js
//Cat photo used in class example by Nick Nunns on Flickr: https://www.flickr.com/photos/neeb/334265966/
var img;
//preload will load before setup runs
function preload() {
//this relative file path starts in the same folder as your sketch.
//In other words, in this example, make a folder called images in the same
//folder as your sketch file (sketch.js) and then put the image file ("kittens.jpg")
//inside of that.
img = loadImage("images/kittens.jpg");
View car_objects_demo.js
/*
Objects Demo
Adapted from Josi's Animation Practice
https://sites.google.com/a/lwhs.org/computational-design-fall-16/p5-animation-practice/josi-s-p5-animation-practice
*/
//initially, green light is on
var redlight = 160;
View marshmallow_game
var button;
var gameState = "start";
var numMarshmallows = 0;
var gameText = "";
function setup() {
createCanvas(400, 300);
button = createButton("Yes");
button.position(width/2-25, height + 50);
@nataliefreed
nataliefreed / stoplight_setInterval.js
Created Nov 18, 2016
Stoplight timer example using setInterval
View stoplight_setInterval.js
/* Timer example using setInterval */
var light_state = 0;
function setup() {
createCanvas(600, 600);
noStroke();
//change stoplight state every 1.5 seconds
setInterval(change_state, 1500);
@nataliefreed
nataliefreed / stoplight_millis.js
Created Nov 18, 2016
Stoplight timer example using millis()
View stoplight_millis.js
/* Timer example using millis() */
var timer;
var light_state = 0;
function setup() {
createCanvas(600, 600);
timer = millis();
noStroke();
}
@nataliefreed
nataliefreed / movement_with_math_function.js
Created Nov 18, 2016
Demo: movement with a mathematical function in P5
View movement_with_math_function.js
/* Demo: movement with a mathematical function in P5 */
var x = 0;
function setup() {
createCanvas(600, 600);
}
function draw() {
background(255);
@nataliefreed
nataliefreed / colorPicker.jscad
Created Oct 27, 2016
OpenJSCAD Color Picker example
View colorPicker.jscad
function getParameterDefinitions() {
return [{ name: 'color', type: 'color', initial: '#FFB431', caption: 'Color?' }];
}
function main(params) {
var box = cube();
box = box.setColor(hexToRGB(params.color));
return box;
}
You can’t perform that action at this time.