Last active
May 17, 2024 22:20
-
-
Save companje/0e95822163ecdd734b1cb2603f922a60 to your computer and use it in GitHub Desktop.
Lerp / Blend color - blue+yellow and cyan+yellow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import processing.serial.*; | |
int h=40; | |
Serial port; | |
void setup() { | |
size(320, 320); | |
background(0); | |
port = new Serial(this, "/dev/cu.usbmodem21401", 9600); | |
} | |
void draw() { | |
while (port.available() > 0) { | |
int i = port.read()-'A'; | |
boolean r = (i&1)!=0; | |
boolean g = (i&2)!=0; | |
boolean b = (i&4)!=0; | |
boolean y = (i&8)!=0; | |
boolean k = (i&16)!=0; | |
boolean w = (i&32)!=0; | |
color rgb = color(r?255:0, g?255:0, b?255:0); | |
color rgby = y ? b&&g&&!r ? #88ff77 : b&&!r ? #00ff00 : (r||g||b) ? lerpColor(rgb, #ffff00, .5) : #ffff00 : rgb; | |
color rgbyk = k ? lerpColor(rgby, #000000, .5) : rgby ; | |
color rgbykw = w ? (r||g||b||y||k) ? lerpColor(rgbyk, #ffffff, .5) : color(255) : rgbyk ; | |
background(rgbykw); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment