Skip to content

Instantly share code, notes, and snippets.

View baptistebriel's full-sized avatar

Baptiste Briel baptistebriel

View GitHub Profile
@mattdesl
mattdesl / color-glsl.js
Created March 2, 2015 03:18
ES6 tagged template strings for GLSL hex-to-vec3 http://tc39wiki.calculist.org/es6/template-strings/
import { getRgb } from 'color-string'
function glsl(strings, ...variables) {
variables = variables.map(v => {
var rgb = getRgb(v)
.map(x => x/255)
.slice(0, 3)
.join(', ')
return `vec3(${rgb})`
})
@mattdesl
mattdesl / modules.md
Last active October 12, 2024 16:17
my favourite modules.
@magicznyleszek
magicznyleszek / random-non-overlapping-position.js
Last active April 11, 2022 21:37
JavaScript -- get random non-overlapping position
// declarations
var positions = [];
// Returns a random integer between min (included) and max (excluded)
// Using Math.round() will give you a non-uniform distribution!
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
// generate random positions
@LukyVj
LukyVj / gist:ab433e989a3a1dfb9318
Created June 12, 2014 15:12
Iconic SASS system
$icons: "phone", "twitter", "email";
@each $icon in $icons {
.ico{
display: block;
&:before{
@include single-element();
@include square(1.2em);
}
&[class*="ico-#{($icon)}"]{
@mrdoob
mrdoob / gist:4132ef6c84185a3ebe37
Created May 22, 2014 11:54
three.js authors (May 2014)
Adam Leeper
Aditya Sawant
Adria2
Akash Manohar J
Aki
Aleksandar Rodic
Alessandro Piva
Alex
Alex Kogan
Alex Schworer
@lancejpollard
lancejpollard / index.js
Created February 20, 2014 07:14
webgl basics
var vs = document.getElementById('vs').textContent;
var fs = document.getElementById('fs').textContent;
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext('experimental-webgl', {
alpha: false,
antialias: true,
premultipliedAlpha: false,
stencil: true
});
@jondashkyle
jondashkyle / epileptic.css
Created December 27, 2013 08:08
Blink rehash #css
.element:hover {
-moz-animation: blink 150ms steps(1, end) infinite;
-webkit-animation: blink 150ms steps(1, end) infinite;
}
@-moz-keyframes blink {
0% { opacity: 0; }
50% { opacity: 1; }
}
@daneden
daneden / style.css
Created December 18, 2013 21:38
TL;DR – rems are awesome. You should use them.
/* PX sucks */
html {
font: 18px/27px Georgia, serif;
}
p {
font-size: 18px;
}
p small {
@kewah
kewah / css-animation.js
Created January 9, 2013 14:49
JavaScript snippet to get CSS Animation event types (animationstart, animationend, animationiteration).
var CSSAnimation = (function(window, document, undefined) {
'use strict';
function camelCaseEventTypes(prefix) {
prefix = prefix || '';
return {
start: prefix + 'AnimationStart',
end: prefix + 'AnimationEnd',
iteration: prefix + 'AnimationIteration'
@conorbuck
conorbuck / angle-between-points.js
Created May 5, 2012 22:51
JavaScript: Find the angle between two points
var p1 = {
x: 20,
y: 20
};
var p2 = {
x: 40,
y: 40
};