Skip to content

Instantly share code, notes, and snippets.

View bmoren's full-sized avatar

Ben Moren bmoren

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<title></title>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300' rel='stylesheet' type='text/css'>
<style>
#first{
@bmoren
bmoren / highlow.js
Created September 14, 2015 17:13
High/Low Game Shell
var randStorage = 0; //Store a random number here
var previous = 0; //Store the previous random number
var choice; //store our choice of higher or lower based on keystroke
var score = 0; // store the players high score
function setup() {
createCanvas(windowWidth, windowHeight); //create a canvas
}
function draw() {
@bmoren
bmoren / StorePrevious.js
Created September 11, 2015 14:44
High/Low Snippets
//how to store a previous value
var randStorage = 0;
var previousRandom = 0;
function setup() {
}
function draw() {
@bmoren
bmoren / ex1.js
Created September 6, 2015 20:33
p5 Color Examples
//Vary the red based on the hour
var h;
function setup() {
createCanvas(600, 600);
}
function draw() {
h = hour();
@bmoren
bmoren / gifcompiler.pde
Last active August 29, 2015 14:27
create GIF animations from a folder of images at any length of frames
import gifAnimation.*;
GifMaker gifExport;
static int FRAME_RATE = 30;
//Select a folder to process:, It must contain images with filename '1.jpg, 2.jpg,3.jpg,etc.
String PATH = "/Users/bmoren/Desktop/GifFrames/"; //make sure there is a "/" at the end of the filepath
//how many files to process?
int IMAGE_NB = 1; // first in sequence (or where to start?)
int TOTAL = 1644 ; //how many in forlder (or to go up to?)
@bmoren
bmoren / fence.js
Created July 1, 2015 21:55
HTML5 geolocation geofence location detection (without geofence API)
window.onload = function() {
var startPos;
var startPosLat;
var startPosLong;
var distance;
if (navigator.geolocation) {
startPosLat = 44.95716993150707;
startPosLong = -93.28439280496818;
@bmoren
bmoren / tableflip
Created May 14, 2015 22:42
Console.log table flip
console.log('%c', 'padding: 100px 250px; background:url("http://media.giphy.com/media/IboGSjkXaOre0/giphy.gif") no-repeat 0 0; line-height:250px;')
@bmoren
bmoren / keypress.js
Created March 2, 2015 23:56
Jquery Keypress Event
$(function(){ //jq do some work! - when ever the DOM is ready, do the stuff in here!
$(document).keypress(function(e) { // look at the keypressed
if(e.which == 97) { // use some logic to see what key was pressed
alert('You pressed "A"!'); //do something when that key was pressed
}
});
///////USE BELOW TO FIGURE OUT KEY NUMBERS!
$(document).keypress(function(e) {
@bmoren
bmoren / image_layer_2.pde
Created January 5, 2015 16:12
Image Layer #2
String PATH = "/Users/bmoren/Desktop/Aspens_test/JPG/";
int IMAGE_NB = 0001; // first in sequence
int imageAlpha = 100;
PImage composition;
PImage workingImage;
boolean firstImage = true;
void setup()
@bmoren
bmoren / image_layer_1.pde
Created January 5, 2015 16:11
Image Layer #1
//path to image files (list) filenames as the following: 0001.jpg, 0002.jpg, 0003.jpg etc.
String PATH = "/Users/bmoren/Desktop/Aspens_test/JPG/";
int IMAGE_NB = 0001; // first in sequence
void setup()
{
//change to what you want your output to be
size(5184,3456);
background(255);
tint(255,10); // this setting will stick
}