You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to use TinyColor to create custom color swatch.
But when I try to mix colors with different amount, such as 20, 30, 40, 50, some of them return the same output.
Then I check to the original mix at tinycolor.js. It seems like you use rounded integer value of p:
final int p = (amount / 100).round(); (line 146 at tinycolor.dart)
when originally it should not be rounded, like:
var p = amount / 100; (line 707 at tinycolor.js)
or when convert to dart:
final double p = amount / 100;
I think the value that need to be rounded is after multiply with p:
I try to use TinyColor to create custom color swatch.
But when I try to mix colors with different amount, such as 20, 30, 40, 50, some of them return the same output.
Then I check to the original mix at tinycolor.js. It seems like you use rounded integer value of p:
final int p = (amount / 100).round(); (line 146 at tinycolor.dart)
when originally it should not be rounded, like:
var p = amount / 100; (line 707 at tinycolor.js)
or when convert to dart:
final double p = amount / 100;
I think the value that need to be rounded is after multiply with p:
final double p = amount / 100;
final color = Color.fromARGB(
((input.alpha - _color.alpha) * p).round() + _color.alpha,
((input.red - _color.red) * p).round() + _color.red,
((input.green - _color.green) * p).round() + _color.green,
((input.blue - _color.blue) * p).round() + _color.blue);
return TinyColor(color);
The text was updated successfully, but these errors were encountered: