Skip to content

Instantly share code, notes, and snippets.

Bluu JordanDelcros

Block or report user

Report or block JordanDelcros

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View GLSL-Noise.md

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
	return mix(rand(fl), rand(fl + 1.0), fc);
}
View gist:c52db5343acf1e15cd72abdab1289c70
open -a Google\ Chrome --args --disable-webgl
@JordanDelcros
JordanDelcros / url.txt
Created May 10, 2016
Base THREE JS fiddle
View url.txt
https://jsfiddle.net/uLhxg615/
@JordanDelcros
JordanDelcros / parseHTML.js
Created Nov 6, 2015
Parse HTML file and highlight it
View parseHTML.js
var parser = function( html ){
html = html
.replace(/&(lt|nbsp|amp)/gim, "&$1")
.replace(//gi, "·")
.replace(/#/gi, "&#35")
.replace(/</gim, "&lt;")
.replace(/>/gim, "&gt;")
.replace(/(&lt;(?!\!)\/?(?:\w+)((?:\s*?[\w-]+(?:\s*=\s*)?(?:\"[^\"]*(?:\")?|\'[^\']*(?:\')?)?)*)?(?:\s*\/?\s*&gt;|[\s\S]*$)?)/gi, function( matchTag ){
@JordanDelcros
JordanDelcros / parseJavaScript.js
Last active Aug 29, 2015
Highlight JavaScript
View parseJavaScript.js
// Basic JavaScript RegExps to parse JavaScript (itself ahah!)
// and translate it into HTML markup ready for CSS.
// Please, give me your feedback on twitter @JordanDelcros.
code // string (multiline) of JavaScript code
.replace(/&(lt|nbsp|amp)/gim, "&amp;$1")
.replace(/(\/\/[^\n]*)/gi, "##comment••$1••comment##")
.replace(/(\/\*[\s\S]*?((\*\/)|$))/gi, "##comment••$1••comment##")
.replace(/(\"[\s\S]*?(\"|$))/gi, "##string••$1••string##")
.replace(/([\<\>\+\-\*\/\%\!]|\=+)/gim, "##math••$1••math##")
@JordanDelcros
JordanDelcros / combine-rgba-colors.js
Created Jul 31, 2015
Combine two RGBA colors with JavaScript
View combine-rgba-colors.js
// Fast and easy way to combine (additive mode) two RGBA colors with JavaScript.
// [red, green, blue, alpha] based on these maximul values [255, 255, 255, 1].
var base = [69, 109, 160, 1];
var added = [61, 47, 82, 0.8];
var mix = [];
mix[3] = 1 - (1 - added[3]) * (1 - base[3]); // alpha
mix[0] = Math.round((added[0] * added[3] / mix[3]) + (base[0] * base[3] * (1 - added[3]) / mix[3])); // red
mix[1] = Math.round((added[1] * added[3] / mix[3]) + (base[1] * base[3] * (1 - added[3]) / mix[3])); // green
mix[2] = Math.round((added[2] * added[3] / mix[3]) + (base[2] * base[3] * (1 - added[3]) / mix[3])); // blue
@JordanDelcros
JordanDelcros / distance-between-vectors.js
Created Jul 30, 2015
Find distance between two vectors
View distance-between-vectors.js
// Easy way to find distance between two vectors in JavaScript
// [x, y, z]
var vectorFrom = [10, 10, 1];
var vectorTo = [12, 11, 0];
var distance = Math.sqrt(((vectorFrom[0] - vectorTo[0]) * (vectorFrom[0] - vectorTo[0])) + ((vectorFrom[1] - vectorTo[1]) * (vectorFrom[1] - vectorTo[1])) + ((vectorFrom[2] - vectorTo[2]) * (vectorFrom[2] - vectorTo[2])));
@JordanDelcros
JordanDelcros / triangle-center.js
Created Jul 30, 2015
Find centroid of a triangle with JavaScript
View triangle-center.js
// Very simple way to compute the center (centroid) of a triangle.
// The only things you have to know are the three vectors forming the triangle.
// vector = [x, y, z];
var vectorA = [-1, -3, -2];
var vectorB = [2, 1, 2];
var vectorC = [8, -4, 1];
var centerX = ((vectorA[0] + vectorB[0] + vectorC[0]) / 3);
var centerY = ((vectorA[1] + vectorB[1] + vectorC[1]) / 3);
@JordanDelcros
JordanDelcros / elegant-class.js
Last active Aug 29, 2015
Elegant JavaScript Class creation
View elegant-class.js
/*
Must easy and elegant way to create classes or complex objects in JavaScript
*/
(function( window, document ){
function Class( options ){
if( this instanceof Class ){
return Class.fn.init(options);
You can’t perform that action at this time.