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));
}
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
//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;
//Im typing something here
//paste all your code
// make sure you don't forget the top or the bottom of your code. if you do that, it won't work.
//This sketch draws a row of pink donuts.
//donut object
var donut = {
x:70,
y:200,
diameter:100,
hole:40
};
//This sketch draws a row of pink donuts.
//donut object
var donut = {
x:70,
y:200,
diameter:100,
hole:40
};
//This sketch draws a pink donut that moves across the screen.
//donut object
var donut = {
x:70,
y:200,
diameter:100,
hole:40
};