public static Color changeColor(this Color t, ColorManipulation manipulation) { t = t.setLight(manipulation.light); t = t.setSaturation(manipulation.saturation); if (manipulation.palette.Count > 0) { t = t.applyPalette(manipulation.palette); } return(t); }
private void UpdateColor(bool force = true) { var device = (Device)this.DataContext; if (device != null) { var color = ColorManipulation.ColorFromHSV(Hue.Value, Saturation.Value, Value.Value).ToWMColor(); ColorPreview.Fill = new SolidColorBrush(color); device.Send(new VisualizationData(null, color), force); } }
protected void CalculateAndSetColors() { int tempCount = count; for (int i = 0; tempCount > 0; ++i, tempCount -= 1023) { int startIndex = i * 1023; for (int j = 0; j < Mathf.Min(tempCount, 1023); ++j) { colors [i][j] = ColorManipulation.LerpColorsCorrected(StartColor, EndColor, (float)(startIndex + j) / (float)count); } propBlocks[i].Clear(); propBlocks[i].SetVectorArray("_Color", colors[i]); } }
public static Texture2D changeColor(this Texture2D t, ColorManipulation manipulation) { Color[] colorData = new Color[t.Width * t.Height]; t.GetData(colorData); for (int x = 0; x < t.Width; x++) { for (int y = 0; y < t.Height; y++) { colorData[x * t.Height + y] = changeColor(colorData[x * t.Height + y], manipulation); } } t.SetData(colorData); return(t); }
public Ghostify(IModHelper helper) { this.helper = helper; float ts = 0.6f; float tp = 0.9f; List <Color> colors = new List <Color>() { Color.Black * 0, Color.Gray *tp, Color.LightCyan *tp, Color.LightBlue *tp, Color.LightGray *tp, Color.LightSkyBlue *tp, Color.LightSlateGray *tp, Color.MidnightBlue *tp, Color.DarkSlateGray *tp, Color.DimGray *tp, new Color(1, 1, 1), Color.DarkGray *tp, Color.AliceBlue *tp, Color.Aqua *tp, Color.DarkBlue *tp, Color.WhiteSmoke *tp, Color.Blue *tp, Color.CadetBlue *tp, Color.SlateBlue *tp, Color.DarkSlateBlue *tp }; List <Color> colorsTransparent = new List <Color>() { Color.Black * 0, Color.Gray *ts, Color.LightCyan *ts, Color.LightBlue *ts, Color.LightGray *ts, Color.LightSkyBlue *ts, Color.LightSlateGray *ts, Color.MidnightBlue *ts, Color.DarkSlateGray *ts, Color.DimGray *ts, new Color(10, 10, 10) * ts, Color.DarkGray *ts, Color.AliceBlue *ts, Color.Aqua *ts, Color.DarkBlue *ts, Color.WhiteSmoke *ts, Color.Blue *ts, Color.CadetBlue *ts, Color.SlateBlue *ts, Color.DarkSlateBlue *ts }; portraitGhostifyer = new ColorManipulation(colors); spriteGhostifyer = new ColorManipulation(colorsTransparent); mapsGhostifyer = GhostTownMod.config.desaturate ? new ColorManipulation(40, 100) : new ColorManipulation(); }
public void UpdatePositions(Transform baseTransform, Vector3 startPosition, Vector3 endPosition) { if (Vector3.Magnitude(previousEnd - endPosition) < 0.0001f) { return; } previousEnd = endPosition; Vector3 direction = (endPosition - startPosition).normalized; float distance = Vector3.Magnitude(endPosition - startPosition); count = Mathf.FloorToInt((distance - MarginToLast) / DistanceBetweenDraws); if (count <= 0) { return; } AllocateInstanceMemory(count); //Could possibly reuse a single list as memory, since we're setting it every frame. But RewindDrawer keeps them, so easier this way. //Why is copying transforms such a bitch tempObject.transform.position = baseTransform.position; tempObject.transform.rotation = baseTransform.rotation; tempObject.transform.localScale = baseTransform.localScale; Transform tempTransform = tempObject.transform; tempTransform.position = startPosition; int tempCount = count; for (int i = 0; tempCount > 0; ++i, tempCount -= 1023) { for (int j = 0; j < Mathf.Min(tempCount, 1023); ++j) { tempTransform.position += direction * DistanceBetweenDraws; positions [i][j] = tempTransform.localToWorldMatrix; colors [i][j] = ColorManipulation.LerpColorsCorrected(StartColor, EndColor, (float)(i * 1023 + j) / (float)count); } } CalculateAndSetColors(); }
void SplitToneSelectShadow() { //get as HSL ColorManipulation.RgbToHsl(ColorPickerShadow.Color.R, ColorPickerShadow.Color.G, ColorPickerShadow.Color.B, Byte.MaxValue, out var h, out var s, out var l); //invert luminance l = 1 - l; //get as rgb ColorManipulation.HslToRgb(h, s, l, byte.MaxValue, out var r, out var g, out var b); ResetButtonVisibility.Value = true; EditionValue.SplitShadow = new Pixel() { R = r, G = g, B = b }; EditingControlChanged(); // Close the Flyout. SplitShadowPicker.Flyout.Hide(); }
void Update() { if (updated) { renderer.material.SetColor("_Color", ColorManipulation.LerpColorsCorrected(color1, color2, ratio)); updated = false; } transform.position = papaTransform.position; if (timePassed >= timeLimit) { timePassed = 0; timeLimit = Random.Range(0, 3); rb.AddRelativeTorque(Random.insideUnitSphere * Random.Range(10, 200)); } else { timePassed += Time.deltaTime; } }
public static Texture2D setLight(this Texture2D t, float light) { ColorManipulation manipulation = new ColorManipulation(100, light); return(t.changeColor(manipulation)); }
public static Texture2D setSaturation(this Texture2D t, float saturation) { ColorManipulation manipulation = new ColorManipulation(saturation); return(t.changeColor(manipulation)); }
public static Texture2D applyPalette(this Texture2D t, List <Color> palette) { ColorManipulation manipulation = new ColorManipulation(palette); return(t.changeColor(manipulation)); }
// 使用主题、主题色、表示是否在窗口标题栏上显示主题色的布尔值、表示是否在窗口阴影显示主题色的布尔值与表示窗口是否处于活动状态的布尔值初始化 RecommendColors 的新实例。 internal RecommendColors(Theme theme, ColorX themeColor, bool showCaptionBarColor, bool showShadowColor, bool isActive) { switch (theme) { case Theme.Colorful: { _Main = ColorManipulation.BlendByLAB(themeColor.AtLightness_HSL(56), themeColor, 0.75); _Main = ColorManipulation.ShiftLightnessByLAB(_Main, (1 - _Main.Lightness_LAB / 50) * 0.25); _Main_DEC = ColorManipulation.ShiftLightnessByHSL(_Main, 0.2); _Main_INC = ColorManipulation.ShiftLightnessByHSL(_Main, -0.15); _FormBackground = themeColor.AtLightness_HSL(98); if (isActive) { if (showCaptionBarColor) { _CaptionBar = _Main; _Caption = (!BackColorFitLightText(_CaptionBar) ? Color.FromArgb(16, 16, 16) : Color.FromArgb(240, 240, 240)); } else { _CaptionBar = _FormBackground; _Caption = Color.FromArgb(16, 16, 16); } } else { _CaptionBar = _FormBackground.Grayscale; _Caption = Color.FromArgb(128, 128, 128); } if (showShadowColor) { _Shadow = (isActive ? _Main : _Main.Grayscale); } else { _Shadow = Color.Black; } _ControlButton = ColorX.Transparent; _ControlButton_INC = (!BackColorFitLightText(_CaptionBar) ? ColorManipulation.ShiftLightnessByHSL(_CaptionBar, -0.2) : ColorManipulation.ShiftLightnessByHSL(_CaptionBar, 0.3)).AtOpacity(70); _ControlButton_DEC = _ControlButton_INC.AtOpacity(50); _ExitButton = ColorX.Transparent; _ExitButton_DEC = ColorX.FromRGB(232, 17, 35); _ExitButton_INC = _ExitButton_DEC.AtOpacity(70); _MenuItemBackground = themeColor.AtLightness_HSL(98); _MenuItemText = themeColor.AtLightness_HSL(24); _Text = themeColor.AtLightness_HSL(40); _Text_DEC = themeColor.AtLightness_HSL(56); _Text_INC = themeColor.AtLightness_HSL(24); _Background = themeColor.AtLightness_HSL(92); _Background_DEC = themeColor.AtLightness_HSL(96); _Background_INC = themeColor.AtLightness_HSL(88); _Border = themeColor.AtLightness_HSL(68); _Border_DEC = themeColor.AtLightness_HSL(84); _Border_INC = themeColor.AtLightness_HSL(52); _Button = themeColor.AtLightness_HSL(76); _Button_DEC = themeColor.AtLightness_HSL(82); _Button_INC = themeColor.AtLightness_HSL(70); _Slider = themeColor.AtLightness_HSL(68); _Slider_DEC = themeColor.AtLightness_HSL(76); _Slider_INC = themeColor.AtLightness_HSL(60); _ScrollBar = themeColor.AtLightness_HSL(84); _ScrollBar_DEC = themeColor.AtLightness_HSL(86); _ScrollBar_INC = themeColor.AtLightness_HSL(82); } break; case Theme.White: { _Main = ColorManipulation.BlendByLAB(themeColor.AtLightness_HSL(56), themeColor, 0.75); _Main = ColorManipulation.ShiftLightnessByLAB(_Main, (1 - _Main.Lightness_LAB / 50) * 0.25); _Main_DEC = ColorManipulation.ShiftLightnessByHSL(_Main, 0.2); _Main_INC = ColorManipulation.ShiftLightnessByHSL(_Main, -0.15); _FormBackground = themeColor.AtLightness_HSL(98).Grayscale; if (isActive) { if (showCaptionBarColor) { _CaptionBar = _Main; _Caption = (!BackColorFitLightText(_CaptionBar) ? Color.FromArgb(16, 16, 16) : Color.FromArgb(240, 240, 240)); } else { _CaptionBar = _FormBackground; _Caption = Color.FromArgb(16, 16, 16); } } else { _CaptionBar = _FormBackground.Grayscale; _Caption = Color.FromArgb(128, 128, 128); } if (showShadowColor) { _Shadow = (isActive ? _Main : _Main.Grayscale); } else { _Shadow = Color.Black; } _ControlButton = ColorX.Transparent; _ControlButton_INC = (!BackColorFitLightText(_CaptionBar) ? ColorManipulation.ShiftLightnessByHSL(_CaptionBar, -0.2) : ColorManipulation.ShiftLightnessByHSL(_CaptionBar, 0.3)).AtOpacity(70); _ControlButton_DEC = _ControlButton_INC.AtOpacity(50); _ExitButton = ColorX.Transparent; _ExitButton_DEC = ColorX.FromRGB(232, 17, 35); _ExitButton_INC = _ExitButton_DEC.AtOpacity(70); _MenuItemBackground = themeColor.AtLightness_HSL(98).Grayscale; _MenuItemText = themeColor.AtLightness_HSL(24).Grayscale; _Text = themeColor.AtLightness_HSL(40).Grayscale; _Text_DEC = themeColor.AtLightness_HSL(56).Grayscale; _Text_INC = themeColor.AtLightness_HSL(24).Grayscale; _Background = themeColor.AtLightness_HSL(92).Grayscale; _Background_DEC = themeColor.AtLightness_HSL(96).Grayscale; _Background_INC = themeColor.AtLightness_HSL(88).Grayscale; _Border = themeColor.AtLightness_HSL(68).Grayscale; _Border_DEC = themeColor.AtLightness_HSL(84).Grayscale; _Border_INC = themeColor.AtLightness_HSL(52).Grayscale; _Button = themeColor.AtLightness_HSL(76).Grayscale; _Button_DEC = themeColor.AtLightness_HSL(82).Grayscale; _Button_INC = themeColor.AtLightness_HSL(70).Grayscale; _Slider = themeColor.AtLightness_HSL(68).Grayscale; _Slider_DEC = themeColor.AtLightness_HSL(76).Grayscale; _Slider_INC = themeColor.AtLightness_HSL(60).Grayscale; _ScrollBar = themeColor.AtLightness_HSL(84).Grayscale; _ScrollBar_DEC = themeColor.AtLightness_HSL(86).Grayscale; _ScrollBar_INC = themeColor.AtLightness_HSL(82).Grayscale; } break; case Theme.LightGray: { _Main = ColorManipulation.BlendByLAB(themeColor.AtLightness_HSL(56), themeColor, 0.75); _Main = ColorManipulation.ShiftLightnessByLAB(_Main, (1 - _Main.Lightness_LAB / 50) * 0.25).Grayscale; _Main_DEC = ColorManipulation.ShiftLightnessByHSL(_Main, 0.2); _Main_INC = ColorManipulation.ShiftLightnessByHSL(_Main, -0.15); _FormBackground = themeColor.AtLightness_HSL(98).Grayscale; if (isActive) { if (showCaptionBarColor) { _CaptionBar = _Main; _Caption = (!BackColorFitLightText(_CaptionBar) ? Color.FromArgb(16, 16, 16) : Color.FromArgb(240, 240, 240)); } else { _CaptionBar = _FormBackground; _Caption = Color.FromArgb(16, 16, 16); } } else { _CaptionBar = _FormBackground.Grayscale; _Caption = Color.FromArgb(128, 128, 128); } if (showShadowColor) { _Shadow = (isActive ? _Main : _Main.Grayscale); } else { _Shadow = Color.Black; } _ControlButton = ColorX.Transparent; _ControlButton_INC = (!BackColorFitLightText(_CaptionBar) ? ColorManipulation.ShiftLightnessByHSL(_CaptionBar, -0.2) : ColorManipulation.ShiftLightnessByHSL(_CaptionBar, 0.3)).AtOpacity(70); _ControlButton_DEC = _ControlButton_INC.AtOpacity(50); _ExitButton = ColorX.Transparent; _ExitButton_DEC = ColorX.FromRGB(232, 17, 35); _ExitButton_INC = _ExitButton_DEC.AtOpacity(70); _MenuItemBackground = themeColor.AtLightness_HSL(98).Grayscale; _MenuItemText = themeColor.AtLightness_HSL(24).Grayscale; _Text = themeColor.AtLightness_HSL(40).Grayscale; _Text_DEC = themeColor.AtLightness_HSL(56); _Text_INC = themeColor.AtLightness_HSL(24); _Background = themeColor.AtLightness_HSL(92).Grayscale; _Background_DEC = themeColor.AtLightness_HSL(96); _Background_INC = themeColor.AtLightness_HSL(88); _Border = themeColor.AtLightness_HSL(68).Grayscale; _Border_DEC = themeColor.AtLightness_HSL(84); _Border_INC = themeColor.AtLightness_HSL(52); _Button = themeColor.AtLightness_HSL(76).Grayscale; _Button_DEC = themeColor.AtLightness_HSL(82); _Button_INC = themeColor.AtLightness_HSL(70); _Slider = themeColor.AtLightness_HSL(68).Grayscale; _Slider_DEC = themeColor.AtLightness_HSL(76); _Slider_INC = themeColor.AtLightness_HSL(60); _ScrollBar = themeColor.AtLightness_HSL(84).Grayscale; _ScrollBar_DEC = themeColor.AtLightness_HSL(86); _ScrollBar_INC = themeColor.AtLightness_HSL(82); } break; case Theme.DarkGray: { _Main = ColorManipulation.BlendByLAB(themeColor.AtLightness_HSL(44), themeColor, 0.75); _Main = ColorManipulation.ShiftLightnessByLAB(_Main, (1 - _Main.Lightness_LAB / 50) * 0.25).Grayscale; _Main_DEC = ColorManipulation.ShiftLightnessByHSL(_Main, -0.2); _Main_INC = ColorManipulation.ShiftLightnessByHSL(_Main, 0.15); _FormBackground = themeColor.AtLightness_HSL(2).Grayscale; if (isActive) { if (showCaptionBarColor) { _CaptionBar = _Main; _Caption = (!BackColorFitLightText(_CaptionBar) ? Color.FromArgb(16, 16, 16) : Color.FromArgb(240, 240, 240)); } else { _CaptionBar = _FormBackground; _Caption = Color.FromArgb(240, 240, 240); } } else { _CaptionBar = _FormBackground.Grayscale; _Caption = Color.FromArgb(192, 192, 192); } if (showShadowColor) { _Shadow = (isActive ? _Main : _Main.Grayscale); } else { _Shadow = Color.Black; } _ControlButton = ColorX.Transparent; _ControlButton_INC = (!BackColorFitLightText(_CaptionBar) ? ColorManipulation.ShiftLightnessByHSL(_CaptionBar, -0.2) : ColorManipulation.ShiftLightnessByHSL(_CaptionBar, 0.3)).AtOpacity(70); _ControlButton_DEC = _ControlButton_INC.AtOpacity(50); _ExitButton = ColorX.Transparent; _ExitButton_DEC = ColorX.FromRGB(232, 17, 35); _ExitButton_INC = _ExitButton_DEC.AtOpacity(70); _MenuItemBackground = themeColor.AtLightness_HSL(98).Grayscale; _MenuItemText = themeColor.AtLightness_HSL(24).Grayscale; _Text = themeColor.AtLightness_HSL(60).Grayscale; _Text_DEC = themeColor.AtLightness_HSL(44); _Text_INC = themeColor.AtLightness_HSL(76); _Background = themeColor.AtLightness_HSL(8).Grayscale; _Background_DEC = themeColor.AtLightness_HSL(4); _Background_INC = themeColor.AtLightness_HSL(12); _Border = themeColor.AtLightness_HSL(32).Grayscale; _Border_DEC = themeColor.AtLightness_HSL(16); _Border_INC = themeColor.AtLightness_HSL(48); _Button = themeColor.AtLightness_HSL(24).Grayscale; _Button_DEC = themeColor.AtLightness_HSL(18); _Button_INC = themeColor.AtLightness_HSL(30); _Slider = themeColor.AtLightness_HSL(32).Grayscale; _Slider_DEC = themeColor.AtLightness_HSL(24); _Slider_INC = themeColor.AtLightness_HSL(40); _ScrollBar = themeColor.AtLightness_HSL(16).Grayscale; _ScrollBar_DEC = themeColor.AtLightness_HSL(14); _ScrollBar_INC = themeColor.AtLightness_HSL(18); } break; case Theme.Black: { _Main = ColorManipulation.BlendByLAB(themeColor.AtLightness_HSL(44), themeColor, 0.75); _Main = ColorManipulation.ShiftLightnessByLAB(_Main, (1 - _Main.Lightness_LAB / 50) * 0.25); _Main_DEC = ColorManipulation.ShiftLightnessByHSL(_Main, -0.2); _Main_INC = ColorManipulation.ShiftLightnessByHSL(_Main, 0.15); _FormBackground = themeColor.AtLightness_HSL(2).Grayscale; if (isActive) { if (showCaptionBarColor) { _CaptionBar = _Main; _Caption = (!BackColorFitLightText(_CaptionBar) ? Color.FromArgb(16, 16, 16) : Color.FromArgb(240, 240, 240)); } else { _CaptionBar = _FormBackground; _Caption = Color.FromArgb(240, 240, 240); } } else { _CaptionBar = _FormBackground.Grayscale; _Caption = Color.FromArgb(192, 192, 192); } if (showShadowColor) { _Shadow = (isActive ? _Main : _Main.Grayscale); } else { _Shadow = Color.Black; } _ControlButton = ColorX.Transparent; _ControlButton_INC = (!BackColorFitLightText(_CaptionBar) ? ColorManipulation.ShiftLightnessByHSL(_CaptionBar, -0.2) : ColorManipulation.ShiftLightnessByHSL(_CaptionBar, 0.3)).AtOpacity(70); _ControlButton_DEC = _ControlButton_INC.AtOpacity(50); _ExitButton = ColorX.Transparent; _ExitButton_DEC = ColorX.FromRGB(232, 17, 35); _ExitButton_INC = _ExitButton_DEC.AtOpacity(70); _MenuItemBackground = themeColor.AtLightness_HSL(98).Grayscale; _MenuItemText = themeColor.AtLightness_HSL(24).Grayscale; _Text = themeColor.AtLightness_HSL(60).Grayscale; _Text_DEC = themeColor.AtLightness_HSL(44).Grayscale; _Text_INC = themeColor.AtLightness_HSL(76).Grayscale; _Background = themeColor.AtLightness_HSL(8).Grayscale; _Background_DEC = themeColor.AtLightness_HSL(4).Grayscale; _Background_INC = themeColor.AtLightness_HSL(12).Grayscale; _Border = themeColor.AtLightness_HSL(32).Grayscale; _Border_DEC = themeColor.AtLightness_HSL(16).Grayscale; _Border_INC = themeColor.AtLightness_HSL(48).Grayscale; _Button = themeColor.AtLightness_HSL(24).Grayscale; _Button_DEC = themeColor.AtLightness_HSL(18).Grayscale; _Button_INC = themeColor.AtLightness_HSL(30).Grayscale; _Slider = themeColor.AtLightness_HSL(32).Grayscale; _Slider_DEC = themeColor.AtLightness_HSL(24).Grayscale; _Slider_INC = themeColor.AtLightness_HSL(40).Grayscale; _ScrollBar = themeColor.AtLightness_HSL(16).Grayscale; _ScrollBar_DEC = themeColor.AtLightness_HSL(14).Grayscale; _ScrollBar_INC = themeColor.AtLightness_HSL(18).Grayscale; } break; } // double LShift = (themeColor.Lightness_LAB / 50 - 1) * 0.1; _Text = ColorManipulation.ShiftLightnessByLAB(_Text, LShift); _Text_DEC = ColorManipulation.ShiftLightnessByLAB(_Text_DEC, LShift); _Text_INC = ColorManipulation.ShiftLightnessByLAB(_Text_INC, LShift); _Background = ColorManipulation.ShiftLightnessByLAB(_Background, LShift); _Background_DEC = ColorManipulation.ShiftLightnessByLAB(_Background_DEC, LShift); _Background_INC = ColorManipulation.ShiftLightnessByLAB(_Background_INC, LShift); _Border = ColorManipulation.ShiftLightnessByLAB(_Border, LShift); _Border_DEC = ColorManipulation.ShiftLightnessByLAB(_Border_DEC, LShift); _Border_INC = ColorManipulation.ShiftLightnessByLAB(_Border_INC, LShift); _Button = ColorManipulation.ShiftLightnessByLAB(_Button, LShift); _Button_DEC = ColorManipulation.ShiftLightnessByLAB(_Button_DEC, LShift); _Button_INC = ColorManipulation.ShiftLightnessByLAB(_Button_INC, LShift); _Slider = ColorManipulation.ShiftLightnessByLAB(_Slider, LShift); _Slider_DEC = ColorManipulation.ShiftLightnessByLAB(_Slider_DEC, LShift); _Slider_INC = ColorManipulation.ShiftLightnessByLAB(_Slider_INC, LShift); _ScrollBar = ColorManipulation.ShiftLightnessByLAB(_ScrollBar, LShift); _ScrollBar_DEC = ColorManipulation.ShiftLightnessByLAB(_ScrollBar_DEC, LShift); _ScrollBar_INC = ColorManipulation.ShiftLightnessByLAB(_ScrollBar_INC, LShift); }