浏览代码

Merge pull request #240 from Unity-Technologies/zgh/fix_painting_colors

fix: small fix about colors.cs
/main
GitHub 3 年前
当前提交
b16ac716
共有 1 个文件被更改,包括 22 次插入7 次删除
  1. 29
      com.unity.uiwidgets/Runtime/painting/colors.cs

29
com.unity.uiwidgets/Runtime/painting/colors.cs


public static HSVColor fromAHSV(float alpha, float hue, float saturation, float value) {
return new HSVColor(alpha, hue, saturation, value);
}
public static HSVColor fromColor(Color color) {
float red = color.red / 0xFF;
float green = color.green / 0xFF;
float blue = color.blue / 0xFF;
float max = Mathf.Max(red, Mathf.Max(green, blue));
float min = Mathf.Min(red, Mathf.Min(green, blue));
float delta = max - min;
float alpha = color.alpha / 0xFF;
float hue = painting_._getHue(red, green, blue, max, delta);
float saturation = max == 0.0f ? 0.0f : delta / max;
return new HSVColor(alpha, hue, saturation, max);
}
public HSVColor withAlpha(float alpha) {
return fromAHSV(alpha, hue, saturation, value);

return HSLColor.fromAHSL(alpha, hue, saturation, lightness);
}
readonly float alpha;
public readonly float alpha;
readonly float hue;
public readonly float hue;
readonly float saturation;
public readonly float saturation;
readonly float lightness;
public readonly float lightness;
HSLColor withAlpha(float alpha) {
return HSLColor.fromAHSL(alpha, hue, saturation, lightness);

return HSLColor.fromAHSL(alpha, hue, saturation, lightness);
}
HSLColor withSaturation(float saturation) {
public HSLColor withSaturation(float saturation) {
HSLColor withLightness(float lightness) {
public HSLColor withLightness(float lightness) {
Color toColor() {
public Color toColor() {
float chroma = Mathf.Abs(1.0f - (2.0f * lightness - 1.0f) * saturation);
float secondary = chroma * (1.0f - Mathf.Abs(((hue / 60.0f) % 2.0f) - 1.0f));
float match = lightness - chroma / 2.0f;

正在加载...
取消
保存