Skip to content

Instantly share code, notes, and snippets.

/*
Export buttons and sliders template/example.
Requires the ControlP5 library http://www.sojamo.de/libraries/controlP5/
*/
import processing.pdf.*;
import java.util.Date;
import controlP5.*;
ControlP5 cp5;
//This example saves out two images of a star,
//a PNG (bitmap/raster) and a SVG (vector)
//SVG export: http://processing.org/reference/libraries/svg/
import processing.svg.*;
size(300, 300);
//begin creating the SVG
@nataliefreed
nataliefreed / turtle.js
Created January 24, 2019 13:49
P5.js version of turtle graphics program
// About turtle graphics: This program uses another way to think
// about moving through Processing's coordinate system. Instead of placing
// points on a grid, you can imagine yourself as being somewhere
// on the grid, facing a direction. You can move forward or turn.
// The drawn line follows behind you.
var loc; //current location
var orientation; //current orientation
var notch_height = 20;
var notch_width = 10;
var circles;
var currentDragged;
var clickRadius = 50;
function setup() {
createCanvas(500, 500);
imageMode(CENTER);
circles = [];
var circles;
var currentDragged;
var clickRadius = 50;
function setup() {
createCanvas(500, 500);
imageMode(CENTER);
circles = [];
/*
Exercises:
1. Change the nouns, verbs, adverbs to your own choice of words
2. Change the sentence structure (for example, add "and" and then a second clause)
3. Change the words to a different language (could be the one you are studying in
school right now). Change the sentence structure so that the sentences are grammatically
correct.
*/
var nouns, verbs, adverbs;
@nataliefreed
nataliefreed / gradient.js
Created February 10, 2017 18:54
Color gradient example using lerpColor
var color1, color2;
var gradientHeight = 300; //change this to change how far down the screen the gradient goes
function setup() {
createCanvas(800, 800);
color1 = color('#e67e22');
color2 = color('#2ecc71');
function setup() {
}
function draw() {
drawMouseCoordinates();
}
function drawMouseCoordinates() {
push();
var color1, color2;
var colorToSelect = 0;
function setup() {
createCanvas(800, 800);
color1 = color(0, 0, 0);
color2 = color(0, 0, 0);
//draw some random colors in a grid
push();
// title : Paste Paper Comb Generator
// author : Natalie Freed
// license : MIT License
function getParameterDefinitions() {
return [{ name: 'w', type: 'float', initial: 10, caption: "Width :" },
{ name: 'h', type: 'float', initial: 10, caption: "Height :" },
{ name: 'rows', type: 'int', initial: 5, caption: "Rows :" },
{ name: 'cols', type: 'int', initial: 5, caption: "Cols :" },
{ name: 'thickness', type: 'float', initial: 3, caption: "Extrusion Thickness (3D mode):"},