bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Add a convinence macro to create a color from a hex code / const function with comptime error

Open A-Walrus opened this issue 2 years ago • 1 comments

What problem does this solve or what need does it fill?

Creating a color from a hex code. Alternative to having Color::hex("...").unwrap() (or Srgba::hex("...").unwrap())

What solution would you like?

Either:

  • A macro to create a color from a hex code without unwraps, compile error if color is invalid.
  • A const function with a compiletime error on invalid color, no need to unwrap

Not sure how this fits in with the new color overhaul :P

What alternative(s) have you considered?

Leave it as is.

A-Walrus avatar Apr 23 '24 21:04 A-Walrus

I believe the best solution to his problem, a const fn, is blocked by RFC #911. Once const float operations are permitted, I imagine almost the entire bevy_color crate could then by marked const.

bushrat011899 avatar Apr 24 '24 06:04 bushrat011899