Skip to content

Instantly share code, notes, and snippets.

View bmoren's full-sized avatar

Ben Moren bmoren

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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() {
<!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 / app.js
Created October 1, 2015 23:04
jQuery demo
//init jQuery to do things once the DOM (page) is ready.
$(function(){ // fucntion aka. do something NOW //dont comment me out!
// alert("hi han solo") //a good way to check that everything is working properly at the start.
/*
//this is the first basic example, cool!
$("#juju").hide(); //hide juju at the beginning
@bmoren
bmoren / sketch.js
Last active October 14, 2015 05:14
Rectangle Rectangle Collision p5js
var posx,posy, size
var times = 0
function setup() {
createCanvas(windowWidth,windowHeight);
posx = width/2
posy = height/2
size = 100;
meSize = 100;
@bmoren
bmoren / idlestate.js
Created November 17, 2015 18:30
idle state for mouse movement in p5.js
//if the mouse is not moving for x time then do something.
mouseIsMoving = false;
function setup(){
createCanvas(windowWidth,windowHeight);
}
function draw() {