Skip to content
Snippets Groups Projects
Commit 5e2abfe5 authored by Micah Elizabeth Scott's avatar Micah Elizabeth Scott
Browse files

More tools for testing/demoing the dithering algorithm

parent 89e33e0d
No related branches found
No related tags found
No related merge requests found
#define PROCESSING_COLOR_SHADER
uniform float time;
uniform float time, hue;
uniform vec2 resolution;
uniform vec2 mouse;
vec3 hsv2rgb(vec3 c)
{
......@@ -18,9 +17,9 @@ void main(void)
vec2 centerDist = gl_FragCoord.xy - resolution.xy * 0.5;
float d = dot(centerDist, centerDist);
// Some interesting colors, in HSV, based on the mouse position
vec3 color1 = vec3(mouse.x, mouse.y, 0.0);
vec3 color2 = vec3(mouse.x, mouse.y, 0.5);
// Interpolation endpoints in HSV
vec3 color1 = vec3(hue, 0.25, 0.0);
vec3 color2 = vec3(hue, 0.25, 0.75);
// Mixing factor
float m = 0.5 * (1.0 + sin(d * 1e-4 - time * 1.2));
......
......@@ -21,6 +21,9 @@ void setup() {
opc.ledGrid8x8(64, width/2 - spacing * 8, height/2, spacing, 0);
opc.ledGrid8x8(128, width/2 + spacing * 8, height/2, spacing, 0);
opc.showLocations(true);
// Initial color correction settings
mouseMoved();
}
void mousePressed() {
......@@ -31,30 +34,34 @@ void mouseReleased() {
opc.setStatusLed(false);
}
void mouseMoved() {
// Use Y axis to control brightness
float b = mouseY / float(height);
opc.setColorCorrection(2.5, b, b, b);
}
void keyPressed() {
if (key == 'd') opc.setDithering(false);
if (key == 'i') opc.setInterpolation(false);
if (key == 'l') opc.setStatusLed(true);
if (key == 'g') opc.setColorCorrection(1.0, 1.0, 1.0, 1.0);
}
void keyReleased() {
if (key == 'd') opc.setDithering(true);
if (key == 'i') opc.setInterpolation(true);
if (key == 'l') opc.setStatusLed(false);
if (key == 'g') opc.setColorCorrection(2.5, 1.0, 1.0, 1.0);
}
void draw() {
// The entire effect happens in a pixel shader
effect.set("time", millis() / 1000.0);
effect.set("mouse", float(mouseX) / width, float(mouseY) / height);
effect.set("hue", float(mouseX) / width);
shader(effect);
rect(0, 0, width, height);
resetShader();
// Status text
textSize(20);
text("Firmware config byte: " + opc.firmwareConfig, 10, 350);
textSize(12);
text("FW Config: " + opc.firmwareConfig + ", " + " Color: " + opc.colorCorrection, 10, 350);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment