Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
bit-shifting...

Chris Ross crossproduct

💭
bit-shifting...
View GitHub Profile
@crossproduct
crossproduct / rgb_hsv.txt
Last active Nov 17, 2015
HSV / RGB Conversions in GLSL
View rgb_hsv.txt
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 Aug 29, 2015
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...
View gist:ad1004de20f498664fa3
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 Aug 29, 2015
Kiosk App Snippets : Android : 4.4.4 API 19
View gist:305c5a1fe3a9b790ba21
** 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 Oct 16, 2013
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 :)
View gist:7009224
<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%;
You can’t perform that action at this time.