Skip to content

Instantly share code, notes, and snippets.

/* Basic Digital Read and Rotary Phone Dial Reader
* ------------------
* This code reads whether the phone is on the hook by treating that hook like a button that is either open or depressed
AND it reads out the number dialed on a rotary phone dial by counting the pulses made by the spinning dial wheel.
*/
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));
}
@lizzybrooks
lizzybrooks / template.js
Last active October 23, 2018 17:04 — forked from nataliefreed/template.pde
project template
/*
Title:
Imagined, Designed, and Programmed by:
Date:
Description:
function setup() {
}
function draw() {
drawMouseCoordinates();
}
function drawMouseCoordinates() {
push();
@lizzybrooks
lizzybrooks / moduloExample.js
Created September 18, 2017 18:59
introduces the modulus operator and an if statement.
/*The Modulus operator! Remember in math when you didn't know how to use decimals, and you used to divide things
like 5%4= 1, remainder 1? Modulus is that, the remainder.
*/
var a = 5 % 4; // Sets 'a' to 1
var b = 125 % 100; // Sets 'b' to 25
var c = 285.5 % 140.0; // Sets 'c' to 5.5
var d = 30.0 % 33.0; // Sets 'd' to 30.0
@lizzybrooks
lizzybrooks / everyColorFromArray.js
Last active February 26, 2018 20:43 — forked from nataliefreed/randomColorFromArray.js
Pick a random color from an array in P5
function setup() {
createCanvas(700, 400);
var listOfColors = [color('#aabf12'), color('#33ab12'), color('#165512'), color('#fe3fa2'), color('#a345cd')];
strokeWeight(100);
for(var i=0;i<listOfColors.length;i++) {
stroke(listOfColors[i]);
//This sketch draws a row of pink donuts.
//lots of variables up here.
var x = 70;
var y = 200;
var diameter = 100;
var hole = 40;
var r = 200;
//This sketch draws a row of pink donuts.
//donut object
var donut = {
x:70,
y:200,
diameter:100,
hole:40
};
/* Flower array by Jeannie Moreno, LWHS Computing 2017
*/
function setup() {
createCanvas(900, 400);
rectMode(CENTER);
noStroke()
var flowerColors = [color(159,12,233), color(240,24,175),color(17,67,16), color(212,200,31) ];
//Im typing something here