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
// title : OpenJSCAD Pumpkin | |
// author : Natalie Freed | |
function getParameterDefinitions() { | |
return [ | |
{ name: 'numSegments', type: 'int', initial: 10, caption: "Number of segments:" }, | |
{ name: 'proportions', type: 'choice', caption: 'Proportions:', values: ["tall", "wide", "medium"], captions: ["tall", "wide", "medium"], initial: "medium" } | |
]; | |
} |
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
var rainbow; //global variable | |
function setup() { | |
createCanvas(600, 600); | |
//make the list (array) of rainbow colors | |
rainbow = [color('#c0392b'), color('#e67e22'), color('#f1c40f'), color('#2ecc71'), color('#3498db'), color('#8e44ad')]; | |
//shift to the center and down a bit | |
translate(width / 2, height / 3); |
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 setup() { | |
createCanvas(600, 600); | |
noFill(); | |
strokeWeight(3); | |
//example: draw something, unscaled | |
yourFunctionThatDrawsAThing(100, 200); | |
//example: make a half scale version | |
var scaledByHalf = autoScale(yourFunctionThatDrawsAThing, 0.5); |
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
//Scale your shapes up without them moving all over the place! | |
var scalingFactor = 1; | |
var x = 100; | |
var y = 200; | |
var w = 40; | |
var h = 30; | |
function setup() | |
{ |
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
//Click to add a new point | |
//Drag points to see their coordinates change | |
//Natalie Freed Oct. 2014 | |
DraggableHandler points; | |
void setup() | |
{ | |
size(600, 600); | |
points = new DraggableHandler(this); |
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
//Art and Science of Computing Fall 14 | |
//Star decreases in size over time | |
//Click mouse to save a "screenshot" of its current state | |
int[] xPositions = { 90, 251, 51, 213, 151, 90 }; | |
int[] yPositions = { 230, 112, 112, 229, 39, 230 }; | |
float scaleSize = 1; | |
void setup() |
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
//draw gridlines in Processing (first way) | |
//this version intentionally does not use loops. It can be made much more concise with loops. | |
//Natalie Freed August 2014 for Art and Science of Computing | |
size(1000, 700); | |
line(0, 0, 1000, 0); | |
line(0, 100, 1000, 100); | |
line(0, 200, 1000, 200); | |
line(0, 300, 1000, 300); |
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
/* | |
Classes and objects with arrays example | |
Natalie Freed for Art and Science of Computing May 16, 2016 | |
Whale function by Courtney Peterson, March 9, 2016 | |
From: Whales in Love https://gist.github.com/anonymous/5d5b9bdef5243e8c2973 | |
*/ | |
Whale orangeWhale; | |
Whale greenWhale; |
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
#include <Servo.h> | |
//TODO: Change these variable names to the correct notes | |
Servo a; | |
Servo b; | |
Servo c; | |
Servo d; | |
Servo e; | |
Servo f; | |
Servo g; |
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
/* Starting point for sorting algorithm implementation */ | |
int[] array = new int[100000]; | |
void setup() | |
{ | |
//fill the array with random numbers | |
for(int i=0;i<array.length;i++) | |
{ | |
array[i] = round(random(-1000, 1000)); |