Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

clamped methods of BaseRGBColor does not work as expected #64

Open
zdima opened this issue Nov 24, 2016 · 1 comment
Open

clamped methods of BaseRGBColor does not work as expected #64

zdima opened this issue Nov 24, 2016 · 1 comment

Comments

@zdima
Copy link

zdima commented Nov 24, 2016

Hi

It seems the clamped method has issue when class has been initialized with is_upscaled=True

>>> from colormath.color_objects import sRGBColor
>>> rgb = sRGBColor( 15,45,65,is_upscaled=True)
>>> rgb
sRGBColor(rgb_r=0.058823529411764705,rgb_g=0.17647058823529413,rgb_b=0.2549019607843137)
>>> rgb.rgb_r
0.058823529411764705
>>> rgb.clamped_rgb_r
1 << expecting 15

The change in BaseRGBColor._clamp_rgb_coordinate would fix the issue:

< return min(max(coord, 1), 255)
> return min(max(int(math.floor(0.5 + coord * 255)), 1), 255)

Thanks

@gtaylor
Copy link
Owner

gtaylor commented Nov 26, 2016

I'm not currently using this module actively, so I'm a bit out of touch. Any other active users want to check this out?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants