Пример #1
0
        public static void OnGUI(VPaintLayerAction action, VPaintActionType type)
        {
            switch (type)
            {
            case VPaintActionType.Brightness:
                BrightnessGUI(action);
                break;

            case VPaintActionType.HueShift:
                HueShiftGUI(action);
                break;

            case VPaintActionType.Saturation:
                SaturationGUI(action);
                break;

            case VPaintActionType.OpacityAdjustment:
                OpacityGUI(action);
                break;

            case VPaintActionType.Contrast:
                ContrastGUI(action);
                break;

            case VPaintActionType.TintColor:
                TintColorGUI(action);
                break;
            }
        }
Пример #2
0
        public void Apply(ref Color c, ref float t, VPaintActionType type)
        {
            HSBColor hsb = new HSBColor(c);

            switch (type)
            {
            case VPaintActionType.Brightness:
                if (brightnessAdjustment < 1f)
                {
                    hsb.b = Mathf.Lerp(0, hsb.b, brightnessAdjustment);
                }
                else if (1f < brightnessAdjustment)
                {
                    hsb.b = Mathf.Lerp(hsb.b, 1f, brightnessAdjustment - 1f);
                }
                c = hsb.ToColor();
                break;

            case VPaintActionType.Saturation:
                hsb.s *= saturationAdjustment;
                c      = hsb.ToColor();
                break;

            case VPaintActionType.HueShift:
                hsb.h += hueAdjustment / 360f;
                if (1f < hsb.h)
                {
                    hsb.h--;
                }
                c = hsb.ToColor();
                break;

            case VPaintActionType.Contrast:
                if (1 < contrastAdjustment)
                {
                    c.a = Mathf.Pow(c.a + contrastThreshhold, contrastAdjustment) - contrastThreshhold;
                    c.r = Mathf.Pow(c.r + contrastThreshhold, contrastAdjustment) - contrastThreshhold;
                    c.g = Mathf.Pow(c.g + contrastThreshhold, contrastAdjustment) - contrastThreshhold;
                    c.b = Mathf.Pow(c.b + contrastThreshhold, contrastAdjustment) - contrastThreshhold;
                }
                else
                {
                    c = Color.Lerp(Color.grey, c, contrastAdjustment);
                }
                break;

            case VPaintActionType.TintColor:
                float tintOpa = tintColorOpacity;
                if (tintUseValue)
                {
                    if (tintInvertUseValue)
                    {
                        tintOpa *= hsb.b;
                    }
                    else
                    {
                        tintOpa *= 1 - hsb.b;
                    }
                }
                c = Color.Lerp(c, tintColor, tintOpa);
                break;

            case VPaintActionType.OpacityAdjustment:
                t = Mathf.Clamp01(t * opacityAdjustment);
                break;
            }
        }