gumyr/build123d

Add better repr to Color class

Closed this issue · 3 comments

print(Color(*(.3,.5,.6)))

Returns: Color: (0.30000001192092896, 0.5, 0.6000000238418579, 1.0)

Color(*(.3,.5,.6))

Returns: <build123d.geometry.Color at 0x12f6e8eb3d0>

After 6eb00f1:

>>> str(Color(*(.3,.5,.6)))
'Color: (0.30000001192092896, 0.5, 0.6000000238418579, 1.0) ~ LIGHTBLUE3'
>>> Color(*(.3,.5,.6))
Color(0.30000001192092896, 0.5, 0.6000000238418579, 1.0)

Wow that was fast, thanks!

The string now returns the closest named color which is a good sanity check that the color is correct.