This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Grid { | |
constructor(tileSize) { | |
this.tileSize = tileSize; | |
} | |
createCanvas() { | |
this.canvas = document.createElement('canvas'); | |
this.ctx = this.canvas.getContext('2d'); | |
this.canvas.width = this.width; | |
this.canvas.height = this.height; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Grid { | |
constructor(w,h,cellSize) { | |
this.grid = []; | |
this.cellSize = cellSize; | |
// | |
this.createGrid(w,h); | |
} | |
createGrid(w,h) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.pickRand = function () { | |
return this[Math.floor(Math.random()*this.length)]; | |
}; | |
// grammar from Daniel Howe | |
// http://rednoise.org/rita/examples/p5js/HaikuGrammar/#source2 | |
let grammar = { | |
"start": "<5L> <7L> <5L>", | |
"<5L>": "<1> <4>|<1> <3> <1>|<1> <1> <3>|<1> <2> <2>|<1> <2> <1> <1>|<1> <1> <2> <1>|<1> <1> <1> <2>|<1> <1> <1> <1> <1>|<2> <3>|<2> <2> <1>|<2> <1> <2>|<2> <1> <1> <1>|<3> <2>|<3> <1> <1>|<4> <1>|<5>", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn my-last [a] | |
"P01 - find the last box of a list" | |
((fn my-last-recur [b c] | |
(if (empty? c) | |
b | |
(my-last-recur (first c) (rest c)) | |
)) | |
(first a) | |
(rest a)) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.findHalf = function () { | |
return Math.floor(this.length/2); | |
}; | |
Array.prototype.isEmpty = function () { | |
return this.length === 0; | |
}; | |
Array.prototype.first = function () { | |
return this[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let setSize = function (w,h=w) { | |
this.width = w; | |
this.height = h; | |
}; | |
let createCanvas = (w,h) => { | |
let canvas = document.createElement('canvas'); | |
if (w) { | |
setSize.call(canvas,w,h); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Vector { | |
constructor(x,y) { | |
this.x = x; | |
this.y = y; | |
} | |
static add (v1,v2) { | |
return new Vector(v1.xv2.x,v1.y+v2.y); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
[].slice.call(document.querySelectorAll('span.read-more')) | |
.forEach(function (el, i) { | |
el.onclick = function (e) { | |
if (e.target.classList.contains('read-less')) { return; } | |
var content = this.querySelector('span.read-more-content'); | |
var text = this.childNodes[0]; | |
text.textContent = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let debounce = function (eventName, time, fn) { | |
// locker | |
let locker = function () { | |
let isLocked = false; | |
let unlock = function (boolLock, fn) { | |
setTimeout(function () { | |
isLocked = false; | |
fn(); | |
},time); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
let ratios = []; | |
let resizeIframes = function (iframes, ratio) { | |
let winW = window.innerWidth; | |
iframes.forEach( (iframe,i) => { | |
let [w, h] = [iframe.clientWidth, iframe.clientHeight], | |
_ratio = ratio && ratio[i] || h/w; | |
// set iframe size | |
iframe.style.height = winW*_ratio+'px'; |
NewerOlder