FolkComputer / folk

🎁 Physical computing system.
https://folk.computer
Apache License 2.0
75 stars 4 forks source link

Add rgb, hsl, & hex as color formats #134

Closed cwervo closed 4 months ago

cwervo commented 4 months ago

I've modified the Colors namespace to put all the color logic in Colors.tcl and support the following formats for colors:

Here's a fun sample program using the new capabilities:

When the clock time is /t/ {
    for {set i 0} {$i < 36} {incr i} {
    Wish $this draws a circle with color hsl([expr {$i * 10 + round(sin($t) * 200)}],100%,50%) filled true radius 10 offset [list [* $i -20] 0]

    Wish $this draws a circle with color rgb([* $i 10],0,0) filled true radius 10 offset [list [* $i -20] 30]

    Wish $this draws a circle with color 0xC0E filled true radius 10 offset [list [* $i -20] 60]
    }
}

IMG_5343 2

osnr commented 4 months ago

Code mostly looks great. Two things:

cwervo commented 4 months ago

Yep, just declaring ::getColor in Colors.tcl works great!

Yeah, it's annoying ergonomically/might commonly trip people up. That said I'm not sure how to handle spaces in that argument, is the only option to manually make a parser to go through the /...options/ from every wishes to draw a call site?

osnr commented 4 months ago

Yeah, I guess other alternatives to Wish this is outlined rgb([* $i 10],0,0) are:

Neither seems like an unqualified win to me :-/

osnr commented 4 months ago

merging for now but yeah!