Skip to content

Instantly share code, notes, and snippets.

@nataliefreed
nataliefreed / curveBetween.js
Last active December 20, 2018 15:42
curveBetween example in P5.js: function that draws symmetrical bezier curves between two points
/*
CurveBetween function by Natalie Freed, 9/22/16
Draws symmetrical bezier curves between two points,
includes example of use
*/
function setup() {
createCanvas(600, 600);
/*
/*
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;
#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;
/* 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));
/* 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));
//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.