Skip to content

Instantly share code, notes, and snippets.

@bendmorris
Last active October 26, 2018 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bendmorris/3957c1912aed6bcfc443cdae5cbf2d1c to your computer and use it in GitHub Desktop.
Save bendmorris/3957c1912aed6bcfc443cdae5cbf2d1c to your computer and use it in GitHub Desktop.
Kit: additive blending
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