Skip to content

Instantly share code, notes, and snippets.

/* Starting point for sorting algorithm implementation */
int[] array = new int[8];
void setup()
{
//fill the array with random numbers
for(int i=0;i<array.length;i++)
{
array[i] = round(random(-1000, 1000));
@nataliefreed
nataliefreed / sortingScale.pde
Last active April 19, 2016 03:20
sorting scale
/*
Scale for sorting algorithms activity
Natalie Freed, July 2014
*/
import java.util.Collections;
DraggableHandler circles;
Scale scale;
Button resetButton, checkButton, moreButton, lessButton;
//Tiny composition book cover generator
//Natalie Freed 2014
//Learned about using Perlin noise to make 2D textures from
//Daniel Shiffman's Nature of Code: http://natureofcode.com/book/introduction/
int labelCenterX, labelCenterY, labelWidth, labelHeight;
int labelMargin = 16;
int outlineMargin = 24;
int labelCorner = 10;
int lineMargin = 20;
@nataliefreed
nataliefreed / movement_with_math_function.pde
Created March 30, 2016 21:41
Example of using a mathematical function to animate a shape's movement (includes classes)
/*
Natalie Freed for Art and Science of Computing Spring 16
Example of using a mathematical function to animate a shape's movement (includes classes)
*/
Shape slowShape, fastShape, superFastShape;
void setup() {
size(500, 500);
/*
Classes and objects with arrays example
Natalie Freed for Art and Science of Computing March 28, 2016
Whale function by Courtney Peterson, March 9, 2016
From: Whales in Love https://gist.github.com/anonymous/5d5b9bdef5243e8c2973
*/
Whale orangeWhale;
Whale greenWhale;
/*
Things to do:
1. Change the shape of the zigzagging object.
2. Change the speed of the zigzagging object.
4. Add another zigzagging object with a different starting x.
5. Add another zigzagging object with the same starting x but a different speed.
6. Change the movement function to something other than a zigzag
7. Save your results to your shared folder.
8. If you are done with both exercises, add a whole bunch of zigzagging shapes with
randomized starting locations and speeds.
/*
Things to do:
1. Change the shape of the moving object.
2. Change the velocity and observe what happens.
3. Change the velocity so that the object moves horizontally.
4. Change the velocity so the object moves vertically.
5. Add a second shape that starts in a different location than the first but moves with the same velocity.
6. Add a third shape that moves at a different velocity from the other two.
7. Add another PVector variable called acceleration. Add it to velocity every frame. What changes?
8. Turn your results in to your shared folder.
/*
Adapted from Sound Library -> Keyboard Example
Sound library reference: https://processing.org/reference/libraries/sound/
Sounds from:
Pack: Good Creation of Drums and Sounds by datwilightz http://freesound.org/people/datwilightz/packs/12262/
Pack: Ukelele single notes, close-mic by stomachache http://freesound.org/people/stomachache/packs/8545/
*/
/*
Functions with outputs demo
Natalie Freed for Art and Science of Computing Spring 16
drawHeartAt function by Frances Gregor February 2016
*/
void setup() {
size(500, 500);
@nataliefreed
nataliefreed / Processing on CodePen.markdown
Created February 22, 2016 23:26
Processing on CodePen