Last active
October 26, 2018 18:36
-
-
Save bendmorris/3957c1912aed6bcfc443cdae5cbf2d1c to your computer and use it in GitHub Desktop.
Kit: additive blending
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
abstract Color: Uint32 { | |
rules { | |
(${a: Color} + ${b: Color}) => | |
((($a & 0xff0000) + ($b & 0xff0000)) & 0xff0000) + | |
((($a & 0xff00) + ($b & 0xff00)) & 0xff00) + | |
((($a & 0xff) + ($b & 0xff)) & 0xff) as Color; | |
} | |
} | |
function main() { | |
var red: Color = 0xff0000; | |
var green: Color = 0x00ff00; | |
var blue: Color = 0x0000ff; | |
var combined: Color = green + blue + red; | |
printf("%x\n", combined); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment