Skip to content

Instantly share code, notes, and snippets.

View spite's full-sized avatar
📦
i'm a smaller box

Jaume Sanchez spite

📦
i'm a smaller box
View GitHub Profile
// if an invalidate mechanism is in place
// easings based on expressions might have
// a bit of zeno's paradox, in which the
// value infinitesimally converges to the
// target value
var value = 0;
var nValue = 1;
function animate() {
@spite
spite / gist:00b3f17734810168093eb92a12815df3
Created May 13, 2016 14:16
Standard UV map (equirectangular 2:1) to mercator (1:1)
var geometry = new THREE.IcosahedronGeometry( 2, 5 );
for ( var i = 0, l = geometry.faceVertexUvs[ 0 ].length; i < l; i ++ ) {
for ( var j = 0, jl = geometry.faceVertexUvs[ 0 ][ i ].length; j < jl; j ++ ) {
var uv = geometry.faceVertexUvs[ 0 ][ i ][ j ];
var a = uv.y * Math.PI - Math.PI / 2;
a = Math.sin(a);
<html>
<head>
<title>Page Title</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="CCapture.all.min.js">
</script>
</head>
<body>
<div id="elementToShare" class="elementToShare">
var canvas = document.createElement( 'canvas' );
!! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );
@spite
spite / gist:90e3dbf8e117660f6788a5748ae06cad
Last active December 30, 2016 09:20
Go to https://lines.chromeexperiments.com/drag/, start the experience and run this code in the console
document.getElementById( 'loading' ).style.display = 'none';
var speed = .001; // changes the rate of rotation
var distance = 4; // changes the distance the point travels
function _update() {
bAmDrawing = true;
lastMouseX = 0; lastMouseY = 0;
var a = speed * performance.now();
var x = distance * Math.cos( a );
var y = distance * Math.sin( a );
stage.mousemove( { data: { global : { x: x, y: y } } } )
@spite
spite / Grid
Created January 17, 2017 02:12
function Block( x, y, w, h, d ) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.d = d;
this.children = [];
document.body.addEventListener('click', async e => {
if(e.srcElement && e.srcElement.classList.contains('irc_mi')) {
const downloadBtn = document.createElement( 'a' );
downloadBtn.setAttribute( 'target', '_blank' );
downloadBtn.setAttribute( 'href', e.srcElement.src );
downloadBtn.click();
e.preventDefault();
@spite
spite / gist:12e458ea49be527e0691ed32bdc6d2b9
Created March 1, 2018 18:18
Capture canvas and download as WebP with quality
canvas.toBlob( e => {
const url = URL.createObjectURL(e);
const link = document.createElement('a');
link.setAttribute('href',url);
link.setAttribute('download','image.webp');
link.click();
console.log(url);},
'image/webp',
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<style>
.Easter {
egg: #17;
}
html, body {
background:#cccccc url(/wallpapers/cn.jpg) repeat left top;
background-size: 100%;
font: normal 12px tahoma, arial, verdana, sans-serif;
margin: 0;
function r() {
let mediaRecorder;
let recordedBlobs;
let startTime = 0;
function handleDataAvailable(event) {
console.log('on data available')
if (event.data && event.data.size > 0) {
recordedBlobs.push(event.data);