Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.
This repository was 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

Description

@zdima

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions