Skip to content

clamping on colors should be done when the values are asked #9

@MARTIMM

Description

@MARTIMM

There are some blending operations which have intermediate color values exceeding their maximum or minimum values and are clamped to their maximum or minimum. A suggestion is to postpone the clamping until the values are asked for using the to-string methods and others.

A piece of code shows that operations can result in wrong values

my Color $b .= new('#08f');
my Color $c .= new('#8f0");
my Color $r1 = ($b + $c)/2;                    # '#447F7F'
my Color $r2 = $b/2 + $c/2;                   # '#44C37F'

The value of $r2 is the correct one but it needs more operations to get it right. There might be operations which are not that easy to circumvent and always deliver a wrong result.

Regards,
Marcel

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions