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
# clouds animation based on: https://www.shadertoy.com/view/XsjSRt | |
THREE.SkyDomeShader = { | |
uniforms: | |
offset: { type: 'f', value: -100 } | |
exponent: { type: 'f', value: 0.64 } | |
top_color: { type: 'c', value: new THREE.Color(0x99ccff) } | |
bottom_color: { type: 'c', value: new THREE.Color(0x719cc8) } |
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
grayscale(pixels, contrast, brightness) { | |
const d = pixels.data; | |
for (let i = 0; i < d.length; i += 4) { | |
const r = d[i + 0]; | |
const g = d[i + 1]; | |
const b = d[i + 2]; | |
const a = d[i + 3]; | |
let v = 0.2126 * r + 0.7152 * g + 0.0722 * b; | |
if (contrast && brightness) { |
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
threshold(pixels, threshold) { | |
const d = pixels.data; | |
for (let i = 0; i < d.length; i += 4) { | |
const r = d[i + 0]; | |
const g = d[i + 1]; | |
const b = d[i + 2]; | |
let v = 0; | |
if ((r + g + b) > threshold) { | |
v = 255; | |
} |
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
correlation(curData, oldData, minCorrelation) { | |
const sampledDataWidth = 80; | |
const sampledDataHeight = 60; | |
let count = 0; | |
const total = curData.data.length; | |
for (let i = 0; i < total; i += 4) { | |
// sampling the R channel, since the images are grayscaled and threshold samplying any of the channels will give the same results. | |
if (curData.data[i] !== oldData.data[i]) { | |
count++; | |
} |
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 lastTime = Date.now(); | |
const N = 24; | |
update() { | |
requestAnimationFrame(update); | |
// refresh only N times per second | |
if (Date.now() - lastTime < 1000 / N) { | |
return; | |
} |
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
var pos = tracker.getCurrentPosition(); | |
var angleRadians = Math.atan2(pos[25][1] - pos[23][1], pos[25][0] - pos[23][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
find ~/Dropbox/ -name "node_modules" -type d -exec rm -rf '{}' + |
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
// list conflicted copies | |
find ~/Dropbox/ -path "*(*'s conflicted copy [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]*" -print | |
// remove conflicted copies | |
find ~/Dropbox/ -path "*(*'s conflicted copy [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]*" -exec rm -f {} \; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>gl-matrix Class and chaining </title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
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
var Box2D={}; | |
(function(F,G){function K(){}if(!(Object.prototype.defineProperty instanceof Function)&&Object.prototype.__defineGetter__ instanceof Function&&Object.prototype.__defineSetter__ instanceof Function)Object.defineProperty=function(y,w,A){A.get instanceof Function&&y.__defineGetter__(w,A.get);A.set instanceof Function&&y.__defineSetter__(w,A.set)};F.inherit=function(y,w){K.prototype=w.prototype;y.prototype=new K;y.prototype.constructor=y};F.generateCallback=function(y,w){return function(){w.apply(y,arguments)}}; | |
F.NVector=function(y){if(y===G)y=0;for(var w=Array(y||0),A=0;A<y;++A)w[A]=0;return w};F.is=function(y,w){if(y===null)return false;if(w instanceof Function&&y instanceof w)return true;if(y.constructor.__implements!=G&&y.constructor.__implements[w])return true;return false};F.parseUInt=function(y){return Math.abs(parseInt(y))}})(Box2D);var Vector=Array,Vector_a2j_Number=Box2D.NVector;if(typeof Box2D==="undefined")Box2D={};if(typeof Box2D.Collision==="undefined")Box2D.Collision={}; | |
if(typeof Bo |
OlderNewer