FromColor() public static méthode

public static FromColor ( Color color ) : HSBColor
color Color
Résultat HSBColor
 void OnRainbowModeToggle()
 {
     rainbowMode  = !rainbowMode;
     rainbowColor = HSBColor.FromColor(Color.white);
     rainbowModeButton.UpdateStateText();
     CourierLogger.Log("NinjaAesthetic", "Rainbow Mode: " + rainbowMode);
 }
Exemple #2
0
        static public void setupNavPoint(Waypoint wp)
        {
            if (HighLogic.LoadedSceneIsFlight)
            {
                linkNavPoint();

                if (navWaypoint != null)
                {
                    CelestialBody body = Planetarium.fetch.Home;

                    foreach (CelestialBody cb in FlightGlobals.Bodies)
                    {
                        if (cb.GetName() == wp.celestialName)
                        {
                            body = cb;
                        }
                    }

                    HSBColor brighterRandom = HSBColor.FromColor(RandomColor(wp.seed));
                    brighterRandom.b = 1.0f;
                    navWaypoint.SetupNavWaypoint(body, wp.latitude, wp.longitude, wp.altitude, wp.waypointType, brighterRandom.ToColor());
                    trackWP = wp;
                }
            }
        }
Exemple #3
0
        public void Update()
        {
            if (!MultiplierController.isActiveAndEnabled)
            {
                return;
            }

            if (Config.SmoothTransition)
            {
                if (CurrentMultiplier == 1)
                {
                    BG.color = HSBColor.Lerp(HSBColor.FromColor(Config.One), HSBColor.FromColor(Config.Two), FG.fillAmount).ToColor().ColorWithAlpha(0.25f);
                    FG.color = HSBColor.Lerp(HSBColor.FromColor(Config.One), HSBColor.FromColor(Config.Two), FG.fillAmount).ToColor();
                }
                else if (CurrentMultiplier == 2)
                {
                    BG.color = HSBColor.Lerp(HSBColor.FromColor(Config.Two), HSBColor.FromColor(Config.Four), FG.fillAmount).ToColor().ColorWithAlpha(0.25f);
                    FG.color = HSBColor.Lerp(HSBColor.FromColor(Config.Two), HSBColor.FromColor(Config.Four), FG.fillAmount).ToColor();
                }
                else if (CurrentMultiplier == 4)
                {
                    BG.color = HSBColor.Lerp(HSBColor.FromColor(Config.Four), HSBColor.FromColor(Config.Eight), FG.fillAmount).ToColor().ColorWithAlpha(0.25f);
                    FG.color = HSBColor.Lerp(HSBColor.FromColor(Config.Four), HSBColor.FromColor(Config.Eight), FG.fillAmount).ToColor();
                }
            }

            if (CurrentMultiplier == 8 && Config.RainbowOnMaxMultiplier)
            {
                BG.color = HSBColor.ToColor(new HSBColor(Mathf.PingPong(Time.time * 0.5f, 1), 1, 1));
            }
        }
 void Start()
 {
     color = HSBColor.FromColor(startColor);
     GetComponent <Renderer>().material.SetColor("_Color", color.ToColor());
     transform.parent.BroadcastMessage("SetColor", color);
     setPlayerColor();
 }
Exemple #5
0
        private HSBColor FilterLightSample(byte baseLightHue, byte baseLightSaturation, byte baseLightValue,
                                           byte filterHue, byte filterSaturation, byte filterValue)
        {
            HSBColor filterColorHsb;

            filterColorHsb.a = 1.0f;
            filterColorHsb.h = filterHue / 255.0f;
            filterColorHsb.s = filterSaturation / 255.0f;
            filterColorHsb.b = filterValue / 255.0f;
            Color filterColor = filterColorHsb.ToColor();

            HSBColor baseLightHsb;

            baseLightHsb.a = 1.0f;
            baseLightHsb.h = baseLightHue / 255.0f;
            baseLightHsb.s = baseLightSaturation / 255.0f;
            baseLightHsb.b = baseLightValue / 255.0f;
            Color baseLight = baseLightHsb.ToColor();

            baseLight.a = 1.0f;
            baseLight.r = Mathf.Max(baseLight.r - (1.0f - filterColor.r), 0.0f);
            baseLight.g = Mathf.Max(baseLight.g - (1.0f - filterColor.g), 0.0f);
            baseLight.b = Mathf.Max(baseLight.b - (1.0f - filterColor.b), 0.0f);

            return(HSBColor.FromColor(baseLight));
        }
Exemple #6
0
            public override Color?ColorForBody(DesignBody designBody)
            {
                Color    color    = designBody.GetVisibleColor();
                HSBColor hsbColor = HSBColor.FromColor(color);

                return(HSBColor.ShiftSaturation(color, RandomMiddleRGB() - hsbColor.S));
            }
        public void UpdatePlayerInfo(PlayerScore _info, int _index)
        {
            _playerScore = _info;

            if (_playerScore != default && _info.valid)
            {
                playerPlaceText.text = (_index + 1).ToString();
                playerNameText.text  = _playerScore.name;
                playerNameText.color = _playerScore.color;
                _previousScore       = _currentScore;
                _currentScore        = _playerScore.score;
                playerSpeakerIcon.gameObject.SetActive(InGameOnlineController.Instance.VoiceChatIsTalking(_playerScore.id));
                _progress = 0;

                if (_info.playerFlags.rainbowName && !_rainbowName)
                {
                    playerNameText.color = _info.color;
                    _color = HSBColor.FromColor(_info.color);
                }
                else if (!_info.playerFlags.rainbowName && playerNameText.color != _info.color)
                {
                    playerNameText.color = _info.color;
                }

                _rainbowName = _info.playerFlags.rainbowName;
            }
            else
            {
                playerPlaceText.text = "";
                playerNameText.text  = "";
                playerScoreText.text = "";
                playerSpeakerIcon.gameObject.SetActive(false);
                _rainbowName = false;
            }
        }
Exemple #8
0
    public static Color setBrightness(Color c, float b)
    {
        HSBColor tmp = HSBColor.FromColor(c);

        tmp.b = b;
        return(tmp.ToColor());
    }
Exemple #9
0
    public void SpawnColumns()
    {
        ColumnClone = GameObject.Instantiate(columnPiece,
                                             new Vector3(0, (numColumns + 1), -0.22f),
                                             Quaternion.Euler(0, numColumns * 5, 0)) as GameObject;
        numColumns++;

        //Color Editor:

        //Switches base color gradient at beginning of each level. Level 1 already set at Start();
        switch (PlayerPrefs.GetInt("Score"))               //numRings
        {
        case 7: hsbc_columns = HSBColor.FromColor(Level2); //Start of Level 2 - 11-3
            break;

        case 17: hsbc_columns = HSBColor.FromColor(Level3);          //Start of Level 3
            break;

        case 27: hsbc_columns = HSBColor.FromColor(Level4);          //Start of Level 4
            break;

        case 37: hsbc_columns = HSBColor.FromColor(Level5);          //Start of Level 5
            break;

        case 47: hsbc_columns = HSBColor.FromColor(GodLevel);          //Start of Level God - 51-3
            break;
        }

        hsbc_columns.h = (hsbc_columns.h + ((Time.deltaTime * 4f / time) / 30)) % 1.0f;     //Mutates color slightly
        ColumnClone.GetComponent <Renderer>().material.color = HSBColor.ToColor(hsbc_columns);
    }
Exemple #10
0
    void Awake()
    {
        color = HSBColor.FromColor(GetComponent <Renderer>().sharedMaterial.GetColor("_Color"));

        colorHuePicker.SetColor(color);
        colorSaturationBrightnessPicker.SetColor(color);
    }
Exemple #11
0
        public static void B(this UnityEngine.Color c, int brightness0to360, ref UnityEngine.Color thisColor)
        {
            HSBColor temp = HSBColor.FromColor(thisColor);

            temp.b    = brightness0to360 / 360.0f;
            thisColor = HSBColor.ToColor(temp);
        }
Exemple #12
0
        public static void S(this UnityEngine.Color c, int saturation0to360, ref UnityEngine.Color thisColor)
        {
            HSBColor temp = HSBColor.FromColor(thisColor);

            temp.s    = saturation0to360 / 360.0f;
            thisColor = HSBColor.ToColor(temp);
        }
Exemple #13
0
        public static void S(this UnityEngine.Color c, float saturation0to1, ref UnityEngine.Color thisColor)
        {
            HSBColor temp = HSBColor.FromColor(thisColor);

            temp.s    = saturation0to1;
            thisColor = HSBColor.ToColor(temp);
        }
Exemple #14
0
        // To use the following functions, you must input the Color you wish to change.
        // Example:
        // myColor.H(180, ref myColor);

        // You can either manipulate the values on a scale from 0 to 360 or
        // on a scale from 0 to 1.

        public static void H(this UnityEngine.Color c, int hue0to360, ref UnityEngine.Color thisColor)
        {
            HSBColor temp = HSBColor.FromColor(c);

            temp.h    = (hue0to360 / 360.0f);
            thisColor = HSBColor.ToColor(temp);
        }
Exemple #15
0
        public static void H(this UnityEngine.Color c, float hue0to1, ref UnityEngine.Color thisColor)
        {
            HSBColor temp = HSBColor.FromColor(thisColor);

            temp.h    = hue0to1;
            thisColor = HSBColor.ToColor(temp);
        }
Exemple #16
0
    static Color GetMainColorFromPixels(Color32[] pixels, out List <Color> topColors, int blendTopColors = 1)
    {
        // get frequency of each solid pixel color
        var pixelFrequencies = new Dictionary <Color32, int>();

        foreach (var pixel in pixels)
        {
            if (pixel.a > 128)
            {
                var freq = pixelFrequencies.ContainsKey(pixel) ? pixelFrequencies[pixel] : 0;
                pixelFrequencies[pixel] = freq + 1;
            }
        }
        // black if nothing
        if (pixelFrequencies.Count == 0)
        {
            topColors = new List <Color> {
                Color.black, Color.black
            };
            return(Color.black);
        }
        // get most common colors
        topColors = pixelFrequencies.OrderByDescending(pair => pair.Value).Select(pair => (Color)pair.Key).ToList();
        // blend top colors together in equal proportion
        var finalColor = topColors[0];

        for (int i = 1; i < topColors.Count && i < blendTopColors; i++)
        {
            finalColor = Color.Lerp(finalColor, topColors[i], 1f / (i + 1));
        }
        // max sat/val of final color
        finalColor = Color.HSVToRGB(HSBColor.FromColor(finalColor).h, 1, 1);
        return(finalColor);
    }
Exemple #17
0
    private void ChangeTeams(Color color)
    {
        // Main ChangeTeams()

        HSBColor hsbColor = HSBColor.FromColor(color);

        HSBColor darkHsbColor = hsbColor;

        darkHsbColor.b -= .2f;

        HSBColor complimentHsbColor = hsbColor;

        complimentHsbColor.h += .14f;
        complimentHsbColor.h %= 1f;

        for (int i = 0; i < this.objectsToChangeTeamColor.Length; i++)
        {
            if (this.objectsToChangeTeamColor[i].renderer)
            {
                this.objectsToChangeTeamColor[i].renderer.material.color = darkHsbColor.ToColor();
                this.objectsToChangeTeamColor[i].renderer.material.SetColor("_SpecColor", complimentHsbColor.ToColor());
                this.objectsToChangeTeamColor[i].renderer.material.SetColor("_RimColor", complimentHsbColor.ToColor());
            }
        }

        // Only push it out if it your own to do
        if (networkView.isMine)
        {
            networkView.RPC("RPCChangeTeams", RPCMode.OthersBuffered, (int)this.PlayerTeam, new Vector3(color.r, color.g, color.b));
        }
    }
Exemple #18
0
        public async Task <HueTheme> CreateThemeAsync()
        {
            var newTheme = new HueTheme();
            var newIndex = Themes.Count + 1;

            newTheme.Name          = "theme " + newIndex.ToString();
            newTheme.FileName      = "theme_" + newIndex.ToString();
            newTheme.IsSystemTheme = false;

            // Add a default color
            newTheme.ColorList.Add(HSBColor.FromColor(Color.FromArgb(0xff, 0xec, 0xcd, 0x67)));
            newTheme.ColorList.Add(HSBColor.FromColor(Color.FromArgb(0xff, 0xec, 0xcd, 0x67)));
            newTheme.ColorList.Add(HSBColor.FromColor(Color.FromArgb(0xff, 0xec, 0xcd, 0x67)));

            // Add to themes
            Themes.Add(newTheme);
            await SaveThemeToFileAsync(newTheme);

            // Notify theme list changes
            if (ThemeListChanged != null)
            {
                ThemeListChanged(this, null);
            }

            return(newTheme);
        }
        private IEnumerator PrepareColorsForEnergyType(GameplayModifiers.EnergyType type)
        {
            yield return(new WaitUntil(() => EnergyPanel != null));

            if (type == GameplayModifiers.EnergyType.Battery)
            {
                List <Image> batterySegments = EnergyPanel.GetField <List <Image>, GameEnergyUIPanel>("_batteryLifeSegments");

                batterySegments[0].color = Config.Low;
                batterySegments[1].color = HSBColor.Lerp(HSBColor.FromColor(Config.Low), HSBColor.FromColor(Config.Mid), 0.34f).ToColor();
                batterySegments[2].color = HSBColor.Lerp(HSBColor.FromColor(Config.Mid), HSBColor.FromColor(Config.High), 0.66f).ToColor();
                batterySegments[3].color = Config.High;

                yield break;
            }

            else if (type == GameplayModifiers.EnergyType.Bar)
            {
                if (Modifiers.instaFail)
                {
                    EnergyBar       = EnergyPanel.transform.Find("BatteryLifeSegment(Clone)").GetComponent <ImageView>();
                    EnergyBar.color = Config.High;
                }
                else
                {
                    EnergyBar       = EnergyPanel.transform.Find("EnergyBarWrapper/EnergyBar").GetComponent <ImageView>();
                    EnergyBar.color = Config.Mid;
                }
            }

            EnergyCounter.gameEnergyDidChangeEvent += HandleEnergyDidChange;
        }
Exemple #20
0
        public static void B(this UnityEngine.Color c, float brightness0to1, ref UnityEngine.Color thisColor)
        {
            HSBColor temp = HSBColor.FromColor(thisColor);

            temp.b    = brightness0to1;
            thisColor = HSBColor.ToColor(temp);
        }
Exemple #21
0
    public static Color GetHue(Color color)
    {
        var hsb = HSBColor.FromColor(color);

        hsb.s = hsb.b = 1f;

        return(hsb);
    }
Exemple #22
0
    public static Color SetBright(this Color col, float val)
    {
        HSBColor temphsbCol = HSBColor.FromColor(col);

        temphsbCol.b = val;

        return(temphsbCol.ToColor());
    }
 void Start()
 {
     gameOver     = FindObjectOfType <GameOver4>();
     followHeight = FindObjectOfType <FollowHeight>();
     scoreTracker = FindObjectOfType <StackScoreTracker>();
     sprite       = GetComponent <SpriteRenderer>();
     currentColor = HSBColor.FromColor(sprite.color);
 }
Exemple #24
0
    Color GetActiveColor(Color color)
    {
        HSBColor hsbColor = HSBColor.FromColor(color);

        hsbColor.s += .3f;
        hsbColor.b += .5f;
        return(hsbColor.ToColor());
    }
        private void AddColorButton_Click(object sender, RoutedEventArgs e)
        {
            var newColor = HSBColor.FromColor(Color.FromArgb(0xff, 0xec, 0xcd, 0x67));

            localColorList.Add(newColor);

            OnThemeColorChanged(this, null);
        }
Exemple #26
0
    public static Color ShiftSaturation(Color c, float saturationDelta)
    {
        HSBColor hsb = HSBColor.FromColor(c);

        hsb.s += saturationDelta;
        hsb.s  = Math.Min(Math.Max(hsb.s, 0), 255);
        return(FromHSB(hsb));
    }
 void Start()
 {
     light   = GetComponent <Light>();
     hsbc    = HSBColor.FromColor(color);
     color.r = 255;
     color.g = 0;
     color.b = 0;
 }
Exemple #28
0
    public static Color ShiftBrighness(Color c, float brightnessDelta)
    {
        HSBColor hsb = HSBColor.FromColor(c);

        hsb.b += brightnessDelta;
        hsb.b  = Math.Min(Math.Max(hsb.b, 0), 255);
        return(FromHSB(hsb));
    }
Exemple #29
0
    public static Color SetSaturation(this Color col, float val)
    {
        HSBColor temphsbCol = HSBColor.FromColor(col);

        temphsbCol.s = val;

        return(temphsbCol.ToColor());
    }
Exemple #30
0
    public static Color ShiftHue(Color c, float hueDelta)
    {
        HSBColor hsb = HSBColor.FromColor(c);

        hsb.h += hueDelta;
        hsb.h  = Math.Min(Math.Max(hsb.h, 0), 255);
        return(FromHSB(hsb));
    }