Skip to content

Instantly share code, notes, and snippets.

View crossproduct's full-sized avatar
💭
bit-shifting...

Chris Ross crossproduct

💭
bit-shifting...
View GitHub Profile
@crossproduct
crossproduct / rgb_hsv.txt
Last active November 17, 2015 17:40
HSV / RGB Conversions in GLSL
vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
@crossproduct
crossproduct / gist:ad1004de20f498664fa3
Last active August 29, 2015 14:23
I love me some Nyan Cat! ... And I wanted a quick way to make this --> https://dl.dropboxusercontent.com/u/6213850/WebGL/nyanCat/nyan.html into screensaver of sorts to run fullscreen in a browser window with some dynamic camera motion, so wrote a little javascript snippet to run in console to achieve just that. Tweak to your hearts consent...
setInterval(function() {
var w = document.querySelector("body").offsetWidth;
var h = document.querySelector("body").offsetHeight;
var c = {x: w/2, y: h/2};
var tolerance = (w < h ? w/8 : h/8);
var dx = c.x + (Math.random() * tolerance) * (Math.random() > 0.5 ? 1 : -1);
var dy = c.y + (Math.random() * tolerance) * (Math.random() > 0.5 ? 1 : -1);
@crossproduct
crossproduct / gist:305c5a1fe3a9b790ba21
Last active August 29, 2015 14:08
Kiosk App Snippets : Android : 4.4.4 API 19
** Custom ViewGroup class which will be used to EAT all the touch events. nom nom nom. **
public class customViewGroup extends ViewGroup {
public customViewGroup(Context context) {
super(context);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
@crossproduct
crossproduct / gist:7009224
Created October 16, 2013 15:09
Here is a basic starting point for a WebComponent. It is by no means a law or rule or even showing the complete set of things you can do... but that is the beauty of the platform :)
<element name="x-thing" attributes="" constructor="x-thing" reset-style-inheritance="false">
//INCLUDE A LITE COMMENT FOR API HERE? LINK? COPYRIGHT?
<template> <!-- INERT MARKUP -->
<style>
/* default styles */
@host {
*{
position: relative;
opacity: 1;
width:100%;