[Preprocessing] New Builtin functions: completion_color, hsluv_color, hex2dec, dec2hex, ...

0 votes
asked Jun 29, 2021 in Wanted features by The-Lu (64,760 points)

Hello PlantUML team,

To continue with color functions, here is a request for new Builtin functions:

1. %completion_color

Could you implement a Builtin function, named %completion_color (for example: for Gantt completed tacks color), with those characteristics: 

  • %completion_color(0) -> red, [or %completion_color("0%") -> red]
  • %completion_color(100) -> green, [or %completion_color("100%") -> green]

as:

  • x in [0, 100] -> toRGB(HSLColor(1.2 * x, 100, 50, 1))
    [or x in ["0%", "100%"] -> toRGB(HSLColor(1.2 * ~int(x), 100, 50, 1))
  • or  hsluvToRgb(hsluv(1.2 * x, 100, 50, 1))

2. %hsluv_color
And more generic a HSL color function '%hsluv_color', which return a RGBa color, as:

  • %hsluv_color(h, s, l, a) -> #RGBa color

3. Other %functions
With not also some other functions as:

  • %hex2dec(<string>)
  • %dec2hex(<int>)

I can perhaps help on that,
Regards,
Th.

1 Answer

0 votes
answered Jun 30, 2021 by plantuml (295,000 points)

These are very good ideas!

So with last beta http://beta.plantuml.net/plantuml.jar you can now have http://www.plantuml.com/plantuml/uml/TSxHQeOW5C3nUv_Y40mA7AbXi329xMAFCKgDZLc2wTWOU_UvsCsNTUdv_uuwR67q8IuMYIryMIEHTYekPWtmZG0UH_N-x5rSzPEppiFTwsRZnulwEvG4Su9fYu6J2lqWKV_VW4RxfWpSIvZS15rQCfzC6rKMyrnKMKs59L5IVcotpr7CS9EHYVQ7Jr52CC50IMxPXUKdjhcm3xdrHaCF9vosLSfY7tNdNQPbKUz3YGQpwhZONm00

For the Gantt, we are thinking about a new syntax, like:

[TASK] is colored for completion from Fuchsia/FireBrick to GreenYellow/Green

Tasks at 0% would be in Fuchsia/FireBrick and tasks at 100% would be GreeYellow/Green.

commented Jul 1, 2021 by The-Lu (64,760 points)

Hello PlantUML team,

That is very good.yes

1. completion_color

With new '%hsluv_color'  function that is already good, see a result here:

But awaiting also your proposal:

For the Gantt, we are thinking about a new syntax, like:

[TASK] is colored for completion from Fuchsia/FireBrick to GreenYellow/Green

Tasks at 0% would be in Fuchsia/FireBrick and tasks at 100% would be GreeYellow/Green.

2. %hsluv_color

Are you sure that is really %hsluv_color, perhaps better having the both (normal HSL and HSLuv [See comparison here]):

  • %hsluv_color(h, s, l, a) or %hsluv_color(h, s, l)
  • %hsl_color(h, s, l, a) or %hsl_color(h, s, l)

3. Other %functions

Sorry for all the requests, but perhaps add a parameter to format the output as:

  • %dec2hex(<int>) --> <string>
  • %dec2hex(<int>, <int_format>) --> <string> of <int_format> length 
    e.g. %dec2hex(5, 2) --> "05" or %dec2hex(12, 2) --> "0C"

And, in fine, perhaps implement a %sprintf function?

Have a good day,
Regards,
Th.

...