Skip to content

Instantly share code, notes, and snippets.

View MAKIO135's full-sized avatar
💭
🎛

Lionel RADISSON MAKIO135

💭
🎛
View GitHub Profile
@MAKIO135
MAKIO135 / index.html
Last active August 22, 2019 22:53
Using canvas as ThreeJS texture
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body style="background:#fff;">
<script src="http://cdnjs.cloudflare.com/ajax/libs/three.js/r68/three.min.js"></script>
<canvas id="canvas"></canvas>
<script id="jsbin-javascript">
@MAKIO135
MAKIO135 / Math2.js
Last active April 26, 2016 15:13
Maths functions, mostly from Processing.js
// Pseudo-random generator
function Marsaglia(i1, i2) {
// from http://www.math.uni-bielefeld.de/~sillke/ALGORITHMS/random/marsaglia-c
var z = i1 || 362436069, w = i2 || 521288629;
var intGenerator = function() {
z = (36969 * (z & 65535) + (z >>> 16)) & 0xFFFFFFFF;
w = (18000 * (w & 65535) + (w >>> 16)) & 0xFFFFFFFF;
return (((z & 0xFFFF) << 16) | (w & 0xFFFF)) & 0xFFFFFFFF;
};
@MAKIO135
MAKIO135 / index.html
Last active June 14, 2016 20:18 — forked from anonymous/index.html
Using SparkJS (former Particle.io)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script type="text/javascript" src="http://cdn.jsdelivr.net/sparkjs/0.5.9/spark.min.js"> </script>
<style>
#led1{
width: 150px;
height: 150px;
@MAKIO135
MAKIO135 / gist:f7a5de1c90c6b7bd752b
Created October 31, 2015 12:02 — forked from anonymous/gist:10675250
Motion Blur + Chromatic Aberration
// by dave @ beesandbombs.tumblr.com >:)
void setup() {
setup_();
result = new int[width*height][3];
result_ = new int[width*height][3];
}
int[][] result, result_;
float time;
@MAKIO135
MAKIO135 / sortArrayByKey.js
Last active June 14, 2018 14:27
sortArrayByKey.js
function sortArrayByKey( arr, key ){
let keyPath = key.split( '.' );
return arr.map( ( e, i ) => {
let value = e[ keyPath[ 0 ] ];
for( let index = 1; index < keyPath.length; index ++ ){
value = value[ keyPath[ index ] ];
}
return {
index: i,
value: value
@MAKIO135
MAKIO135 / ease.js
Last active June 24, 2016 09:40
ease function
function ease( variable, target, easingVal, sensib ) {
var d = target - variable;
var sensib = sensib || 1;
if ( Math.abs( d ) > sensib ) variable += d * easingVal;
else variable = target;
return variable;
}
const hexToRgb = hex => {
hex = parseInt(hex[0] != '#' ? hex : hex.substring(1), 16)
return [
hex >> 16 & 255,
hex >> 8 & 255,
hex & 255
]
}
// Based on Fisher–Yates shuffle ( https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle )
// and Shuffling an Array in JavaScript ( https://www.kirupa.com/html5/shuffling_array_js.htm )
// returns a new array shuffled
Array.prototype.shuffle = function() {
let tmpArray = [ ... this ]; // create a copy of original array
for( let i = tmpArray.length - 1; i; i -- ) {
let randomIndex = ~~( Math.random() * ( i + 1 ) );
[ tmpArray[ i ], tmpArray[ randomIndex ] ] = [ tmpArray[ randomIndex ], tmpArray[ i ] ]; // swap
}
/**
* This class lets you encode animated GIF files
* Base class : http://www.java2s.com/Code/Java/2D-Graphics-GUI/AnimatedGifEncoder.htm
* @author Kevin Weiner (original Java version - kweiner@fmsware.com)
* @author Thibault Imbert (AS3 version - bytearray.org)
* @version 0.1 AS3 implementation
*/
//import flash.utils.ByteArray;
@MAKIO135
MAKIO135 / SonicPiDrumMachine
Created April 3, 2017 16:45 — forked from darinwilson/SonicPiDrumMachine
Sonic Pi Drum Machine
#########################################
## Sonic Pi Drum Machine
## coded by Darin Wilson
##
use_bpm 95
in_thread(name: :drum_machine) do
# choose your kit here (can be :acoustic, :acoustic_soft, :electro, :toy)