Please add this text as rgb_darken.beads, to add another language to your list.
This produces output based on colors 0..255
As you can see from the word count, it is more compact than TypeScript.
beads 1 program rgb_darken
// this is the Beads language version of the color darkening program
// as presented on YouTube at https://www.youtube.com/watch?v=Bxel30L6C5U
// from Context Free channel
//
// produces the output:
// blue (0, 0, 255) (0, 0, 127)
// red (255, 0, 0) (127, 0, 0)
// yellow (255, 255, 0) (127, 127, 0)
// a 3 element tree of colors
const list <=== { "red":RED, "yellow":YELLOW, "blue":BLUE }
// function that darkens a color. We could use HSV space, but darkening in RGB
// has the same results as using HSV.
calc darken (
c : color
) : color
const SCALE = 0.5
// the std lib has functions that work 0..1 or 0..255 for colors
return rgb255(r255(c)*SCALE, g255(c)*SCALE, b255(c)*SCALE)
// loop across the list of colors
calc main_init
// loop across the list of colors
var c : color
loop across:list kind:str val:c index:name
var d = darken(c)
log "{name} ({r255(c)}, {g255(c)}, {b255(c)}) ({r255(d)}, {g255(d)}, {b255(d)})"
Please add this text as rgb_darken.beads, to add another language to your list.
This produces output based on colors 0..255
As you can see from the word count, it is more compact than TypeScript.