ToColor() публичный Метод

public ToColor ( ) : Color
Результат Color
Пример #1
0
    // Update is called once per frame
    void Update()
    {
        HSBColor randCol = new HSBColor(Mathf.PingPong(Time.time * speed, 1), 1, 1);

        randCol.s = randCol.s / 2;
        camera.backgroundColor      = randCol.ToColor();
        Camera.main.backgroundColor = randCol.ToColor();
    }
    void Start()
    {
        var color = new HSBColor(Random.value, Saturation, 1);

        sprite1.color = color.ToColor();
        text1.color   = color.ToColor();
        text1b.color  = color.ToColor();
        var color2 = new HSBColor((color.h + 0.5f) % 1, Saturation, 1);

        text2.color = color2.ToColor();
    }
Пример #3
0
        private void Update()
        {
            if (cycleColors == true)
            {
                hsbColor.h += Time.deltaTime * 0.1f;
                if (hsbColor.h >= 1.0f)
                {
                    hsbColor.h = 0.0f;
                }

                spriteColorOutline.outlineColor = hsbColor.ToColor();

                if (spriteColorOutline.Mode == SpriteColorOutline.OutlineMode.Gradient)
                {
                    hsbColor.h = 1.0f - hsbColor.h;

                    spriteColorOutline.outlineColor2 = hsbColor.ToColor();

                    hsbColor.h = 1.0f - hsbColor.h;
                }
            }

            if (cycleAlpha == true)
            {
                spriteColorOutline.outlineColor.a = (1.0f + Mathf.Sin(Time.time * 2.0f)) * 0.5f;

                if (spriteColorOutline.Mode == SpriteColorOutline.OutlineMode.Gradient)
                {
                    spriteColorOutline.outlineColor2.a = 1.0f - spriteColorOutline.outlineColor.a;
                }
            }

            if (changeOutlineSize == true)
            {
                spriteColorOutline.outlineSize = (originalOutlineSize * 0.4f) + (originalOutlineSize * ((1.0f + Mathf.Sin(Time.time * 2.0f)) * 0.6f));
            }

            if (changeGradientScale == true)
            {
                spriteColorOutline.gradientScale = Mathf.Sin(Time.time * 2.0f) * 10.0f;
            }

            if (changeGradientOffset == true)
            {
                spriteColorOutline.gradientOffset = (1.0f + Mathf.Cos(Time.time * 2.0f)) * 1.0f;
            }

            if (cycleAngle == true)
            {
                spriteColorOutline.outlineTextureUVAngle = (spriteColorOutline.outlineTextureUVAngle >= 360.0f) ? 0.0f : spriteColorOutline.outlineTextureUVAngle + Time.deltaTime * 25.0f;
            }
        }
Пример #4
0
    public static Color addHue(Color color, double change)
    {
        HSBColor hsbColor = new HSBColor(color);

        hsbColor.Hue += change;
        return(hsbColor.ToColor());
    }
Пример #5
0
    private void Start()
    {
        Texture2D heatTexture = new Texture2D(256, 32);

        for (int x = 0; x < 256; x++)
        {
            for (int y = 0; y < 32; y++)
            {
                Color col;
                float xp   = x / (255f);
                float lerp = -((xp - 1) * (xp - 1)) + 1;

                float h = 1f - Mathf.Lerp(1 / 3f, 1f, lerp);

                HSBColor hsb = new HSBColor(h, 1f, 1f);

                col = hsb.ToColor();

                col.a = lerp;

                heatTexture.SetPixel(x, y, col);
            }
        }

        System.IO.File.WriteAllBytes(Application.dataPath + "/HSBTex.png", heatTexture.EncodeToPNG());
    }
Пример #6
0
    // Update is called once per frame
    void Update()
    {
        if (HSLToRGB) {
            hsl = new HSBColor(h, s, l);
            rgbCol = hsl.ToColor();

            renderer.material.color = rgbCol;

            r = rgbCol.r;
            g = rgbCol.g;
            b = rgbCol.b;
        } else {
            hsl = HSBColor.FromColor(rgbCol);
            Color temp = hsl.ToColor();

            renderer.material.color = temp;

            h = hsl.h;
            s = hsl.s;
            l = hsl.b;
            r = temp.r;
            g = temp.g;
            b = temp.b;
        }
    }
Пример #7
0
        void Update()
        {
            try
            {
                if (playerNameText != null)
                {
                    if (playerCamera == null)
                    {
                        playerCamera = Camera.main;
                    }

                    playerNameText.rectTransform.rotation    = Quaternion.LookRotation(playerNameText.rectTransform.position - playerCamera.transform.position);
                    playerSpeakerIcon.rectTransform.rotation = Quaternion.LookRotation(playerSpeakerIcon.rectTransform.position - playerCamera.transform.position);

                    if (rainbowName)
                    {
                        playerNameText.color = HSBColor.ToColor(nameColor);
                        nameColor.h         += 0.125f * Time.deltaTime;
                        if (nameColor.h >= 1f)
                        {
                            nameColor.h = 0f;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Plugin.log.Warn($"Unable to rotate text to the camera! Exception: {e}");
            }
        }
Пример #8
0
 void Update()
 {
     alpha = 1.0f - ((Time.time - spawnTime) * 0.3f);
     alpha = Mathf.Clamp(alpha, 0, 1.0f);
     sphere_material.SetColor("_Color", new Color(1, 1, 1, alpha));
     cube_material.SetColor("_Color", HSBColor.ToColor(new HSBColor(Mathf.PingPong(Time.time * color_speed, 1), 1, 1, 0.9f)));
 }
Пример #9
0
    // Use this for initialization
    void Start()
    {
        Renderer changeColor = GetComponent <Renderer>();
        HSBColor randomColor = new HSBColor(Random.value, Random.Range(saturationRange.x, saturationRange.y), Random.Range(valueRange.x, valueRange.y));

        changeColor.material.color = randomColor.ToColor();
    }
Пример #10
0
    public static Color addSaturation(Color color, double change)
    {
        HSBColor hsbColor = new HSBColor(color);

        hsbColor.Saturation += change;
        return(hsbColor.ToColor());
    }
Пример #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);
        }
Пример #12
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));
            }
        }
Пример #13
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);
    }
Пример #14
0
        // Update is called once per frame
        public override void Update()
        {
            if (Player != null)
            {
                if (HealthBar != null)
                {
                    HealthBar.fillAmount = Player.Status.DurabilityInPercent * 0.01f;
                    HealthBar.color      = HSBColor.ToColor(HSBColor.Lerp(Color.red, Color.green, HealthBar.fillAmount));
                }

                if (DamageIndicator != null)
                {
                    DamageIndicator.color = new Color(DamageIndicator.color.r, DamageIndicator.color.g, DamageIndicator.color.b, Mathf.Clamp01(1 - (Player.Status.DurabilityInPercent * 0.01f)));
                }

                if (InventorySlotBar != null)
                {
                    InventorySlotObject _slot = Player.Inventory.GetSlotByIndex(0);

                    if (_slot != null)
                    {
                        InventorySlotBar.fillAmount = _slot.AmountInPercent * 0.01f;
                        InventorySlotBar.color      = HSBColor.ToColor(HSBColor.Lerp(Color.red, Color.green, InventorySlotBar.fillAmount));
                    }
                }
            }

            DisplayEntityInfos();
        }
Пример #15
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);
        }
Пример #16
0
        public static void name_border_clr()
        {
            var users = utils.get_all_player();

            if (users == null)
            {
                return;
            }
            for (var i = 0; i < users.Count; i++)
            {
                var obj = users[i];
                if (obj == null)
                {
                    continue;
                }
                if (obj.field_Private_APIUser_0 == null)
                {
                    continue;
                }
                if (obj.field_Private_APIUser_0.id.Contains(APIUser.CurrentUser.id))
                {
                    continue;
                }
                if (hashmod.friend_list.Contains(obj.field_Private_APIUser_0.id) == false)
                {
                    continue;
                }

                obj.field_Private_VRCPlayerApi_0.SetNamePlateColor(HSBColor.ToColor(new HSBColor(Mathf.PingPong(Time.time * 0.1f, 1), 1, 1)));
            }
        }
Пример #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));
        }
    }
Пример #18
0
 // Update is called once per frame
 void Update()
 {
     //transform.Rotate(new Vector3(1, 1, 1));
     rend.material.SetColor("_Color", HSBColor.ToColor(new HSBColor(Mathf.PingPong(Time.time * Speed, 1), Audior.samples[3] * 100, Audior.samples[3] * 200)));
     transform.Rotate(Audior.samples[5] * 150, Audior.samples[10] * 160, Audior.samples[15] * 170);
     transform.localScale = new Vector3((Audior.samples[20] * maxScale * 2) + 0.8f, (Audior.samples[20] * maxScale * 2) + 0.8f, (Audior.samples[20] * maxScale * 2) + 0.8f);
 }
Пример #19
0
 void Update()
 {
     hsbc.h                 = (hsbc.h + Time.deltaTime / time) % 1.0f;
     color                  = HSBColor.ToColor(hsbc);
     light.color            = color;
     light.colorTemperature = hsbc.h;
 }
Пример #20
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);
        }
Пример #21
0
    public Mesh BakeResultNoSeams()
    {
        Mesh m = new Mesh();

        Vector3[] vs = new Vector3[uverts.Length];
        Color[]   cs = new Color[uverts.Length];
        Vector3[] ns = new Vector3[uverts.Length];
        int[]     ts = new int[tris.Length * 3];

        for (int i = 0; i < uverts.Length; i++)
        {
            vs[i] = uverts[i].pos;
            cs[i] = HSBColor.ToColor(uverts[i].color);
            ns[i] = uverts[i].normal;
        }

        for (int i = 0; i < tris.Length; i++)
        {
            ts[i * 3]     = tris[i].i0;
            ts[i * 3 + 1] = tris[i].i1;
            ts[i * 3 + 2] = tris[i].i2;
        }

        m.vertices  = vs;
        m.colors    = cs;
        m.normals   = ns;
        m.triangles = ts;
        return(m);
    }
Пример #22
0
	public void CloseToWallTint(float distance)
	{
		HSBColor tempColor = new HSBColor (bgMat.color);
		distance = Mathf.Clamp(50 - distance, 0, tempColor.b);
		tempColor.b -= distance;
		bgMat.SetColor ("_EmissionColor", tempColor.ToColor());
	}
Пример #23
0
    Color mandelBrot(float a, float b)
    {
        float x = 0, y = 0, x2 = 0, y2 = 0;
        float i = 0;

        for (; i < iterations && x2 + y2 <= 4; i++)
        {
            y  = 2 * x * y + b;
            x  = x2 - y2 + a;
            x2 = x * x;
            y2 = y * y;
        }

        if (x2 + y2 >= 4)
        {
            float log_zn = Mathf.Log(x2 + y2) / 2;
            float nu     = Mathf.Log(log_zn / Mathf.Log(2)) / Mathf.Log(2);
            i += (1 - nu);
            HSBColor col1 = new HSBColor(i % 1f, 1f, 1f);
            return(col1.ToColor());
        }
        else
        {
            return(Color.black);
        }
    }
Пример #24
0
    public static Color addBrightness(Color color, double change)
    {
        HSBColor hsbColor = new HSBColor(color);

        hsbColor.Brightness += change;
        return(hsbColor.ToColor());
    }
Пример #25
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);
        }
Пример #26
0
    void Update()
    {
        // rotate hue
        {
            currentColor.h = (currentColor.h + HueSpeed * Time.deltaTime) % 1;
            sprite.color   = currentColor.ToColor();
        }
        // drop when clicked
        {
            if (Input.GetMouseButtonDown(0))
            {
                var drop = Instantiate(DropPrefab);
                drop.transform.position   = transform.position;
                drop.transform.rotation   = transform.rotation;
                drop.transform.localScale = transform.localScale;

                var dropStack = drop.GetComponent <Stack>();
                dropStack.GameOver     = gameOver;
                dropStack.FollowHeight = followHeight;
                dropStack.ScoreTracker = scoreTracker;

                var dropSprite = drop.GetComponent <SpriteRenderer>();
                dropSprite.color = sprite.color.withAlpha(1);
            }
        }
    }
Пример #27
0
    public static Color SetBrightness(this Color color, float amount)
    {
        HSBColor hsb = new HSBColor(color);

        hsb.b = amount;
        return(hsb.ToColor());
    }
        public void Update()
        {
            if (_muteButton != null && playerInfo != null)
            {
                if (_isMuted && !InGameOnlineController.Instance.mutedPlayers.Contains(playerInfo.playerId))
                {
                    _isMuted = false;
                    _muteButton.SetButtonText("MUTE");
                }
                else if (!_isMuted && InGameOnlineController.Instance.mutedPlayers.Contains(playerInfo.playerId))
                {
                    _isMuted = true;
                    _muteButton.SetButtonText("UNMUTE");
                }

                if (_rainbowName)
                {
                    _playerNameText.color = HSBColor.ToColor(_color);
                    _color.h += 0.125f * Time.deltaTime;
                    if (_color.h >= 1f)
                    {
                        _color.h = 0f;
                    }
                }
            }
        }
Пример #29
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);
        }
Пример #30
0
 void Start()
 {
     color = HSBColor.FromColor(startColor);
     GetComponent <Renderer>().material.SetColor("_Color", color.ToColor());
     transform.parent.BroadcastMessage("SetColor", color);
     setPlayerColor();
 }
Пример #31
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);
        }
Пример #32
0
    public static Color ShiftHue(this Color color, float amount)
    {
        HSBColor hsb = new HSBColor(color);

        hsb.h = (hsb.h + amount) % 1;
        return(hsb.ToColor());
    }
Пример #33
0
	void GenerateNewColor()
	{
		HSBColor newColor = new HSBColor(Random.value, saturation, brightness, alpha);

		renderer.material.color = newColor.ToColor();


	}
	// Update is called once per frame
	void Update ()
	{
		HSBColor newColor = new HSBColor(Random.value,saturation,brightness,alpha);
		
		foreach(Material mat in materialsToChange)
		{	
			mat.color = newColor.ToColor();
		}
	}
Пример #35
0
	// Use this for initialization
	void Start () {
		HSBColor color;
		color = new HSBColor(Random.Range(0.0f, 1.0f), 1f, 1f);
		Color col;
		col =color.ToColor();		

		foreach (Renderer r in transform.GetComponentsInChildren<Renderer>())
		{			
			r.material.color = col;
		}

	}
Пример #36
0
    public static Color RGBCircle(Color c, string label, Texture2D colorCircle)
    {
        var r = GUILayoutUtility.GetAspectRect(1);
        r.height = r.width -= 15;
        var r2 = new Rect(r.x + r.width + 5, r.y, 10, r.height);
        var hsb = new HSBColor(c);//It is much easier to work with HSB colours in this case


        var cp = new Vector2(r.x + r.width / 2, r.y + r.height / 2);

        if (Input.GetMouseButton(0))
        {
            var InputVector = Vector2.zero;
            InputVector.x = cp.x - Event.current.mousePosition.x;
            InputVector.y = cp.y - Event.current.mousePosition.y;

            var hyp = Mathf.Sqrt((InputVector.x * InputVector.x) + (InputVector.y * InputVector.y));
            if (hyp <= r.width / 2 + 5)
            {
                hyp = Mathf.Clamp(hyp, 0, r.width / 2);
                float a = Vector3.Angle(new Vector3(-1, 0, 0), InputVector);

                if (InputVector.y < 0)
                {
                    a = 360 - a;
                }

                hsb.h = a / 360;
                hsb.s = hyp / (r.width / 2);
            }
        }

        var hsb2 = new HSBColor(c);
        hsb2.b = 1;
        var c2 = hsb2.ToColor();
        GUI.color = c2;
        hsb.b = GUI.VerticalSlider(r2, hsb.b, 1.0f, 0.0f, "BWSlider", "verticalsliderthumb");

        GUI.color = Color.white * hsb.b;
        GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 1);
        GUI.Box(r, colorCircle, GUIStyle.none);

        var pos = (new Vector2(Mathf.Cos(hsb.h * 360 * Mathf.Deg2Rad), -Mathf.Sin(hsb.h * 360 * Mathf.Deg2Rad)) * r.width * hsb.s / 2);

        GUI.color = c;
        GUI.Box(new Rect(pos.x - 5 + cp.x, pos.y - 5 + cp.y, 10, 10), "", "ColorcirclePicker");
        GUI.color = Color.white;

        c = hsb.ToColor();
        return c;
    }
Пример #37
0
    void CreateLanes()
    {
        lanes = new List<Lane>(numberOfLanes);

        for (int i = 0; i < numberOfLanes; i++) {
            var lane = Instantiate(lanePrefab, Vector3.zero, Quaternion.identity) as Lane;
            //lane.GetComponent<tk2dSprite>().color = lerpPoints.GetRangeValue((float)i/(float)numberOfLanes);
            float h = Mathf.Lerp(hueBottom, hueTop, (float)i / (float)numberOfLanes);
            var hsb = new HSBColor(0.6f, h, 1.0f, 0.3f);
            lane.GetComponent<tk2dSprite>().color = hsb.ToColor();
            lane.transform.parent = transform;
            lane.transform.localPosition = new Vector3(0, i * laneDistance, i * zLaneDistance);
            lanes.Add(lane);
        }
    }
Пример #38
0
    private void OnEnable()
    {
      HSBColor hsbColor = new HSBColor();
      hsbColor.h = UnityEngine.Random.value;
      hsbColor.s = 1.0f;
      hsbColor.b = 1.0f;

      Color color = hsbColor.ToColor();
      color.a = 1.0f;

      Light light = gameObject.GetComponent<Light>();
      light.color = color;

      SpriteRenderer spriteRenderer = gameObject.GetComponent<SpriteRenderer>();
      spriteRenderer.color = color;

      sun = GameObject.FindObjectOfType<Sun>();
    }
Пример #39
0
 public void LerpColor()
 {
     HSBColor newColor = new HSBColor(Mathf.Sin (Random.Range(0f, 360f) + Mathf.PI / 2 ), 1f, 1f);
     _material.DOColor(newColor.ToColor(), delayDuration);
     _lineRenderer.material.DOColor(newColor.ToColor(), delayDuration);
 }
Пример #40
0
    public static Color RGBCircle( Color c ,  string label, float w_, float h_)
    {
        Rect r = new Rect();
        //if(Event.current.type == EventType.Repaint){
        Rect rect = GUILayoutUtility.GetLastRect();
        r = new Rect(rect.x,rect.y+rect.height+2, w_, h_);
        //}

        Rect r2 = new Rect(r.x + r.width +5, r.y, 10, r.height);
        HSBColor hsb = new HSBColor (c);//It is much easier to work with HSB colours in this case

        Vector2 cp = new Vector2 (r.x + r.width/2, r.y + r.height/2);

        if (Input.GetMouseButton (0) && r.x > 0) {// r.x > 0  inok hack

            Vector2 InputVector = Vector2.zero;
            InputVector.x = cp.x - Event.current.mousePosition.x;
            InputVector.y = cp.y - Event.current.mousePosition.y;

            float hyp = Mathf.Sqrt( (InputVector.x * InputVector.x) + (InputVector.y * InputVector.y) );
            if (hyp <= r.width/2 + 5) {
                hyp = Mathf.Clamp (hyp,0,r.width/2);
                float a = Vector3.Angle(new Vector3(-1,0,0), InputVector);

                if (InputVector.y<0) {
                    a = 360 - a;
                }

                hsb.h = a / 360;
                hsb.s = hyp / (r.width/2);
            }
        }

        HSBColor hsb2 = new HSBColor (c);
        hsb2.b = 1;
        Color c2 = hsb2.ToColor ();

        //hsb.b = GUI.VerticalSlider (r2,hsb.b,1.0f,0.0f,"BWSlider","verticalsliderthumb");
        hsb.b = GUI.VerticalSlider (r2, hsb.b,1.0f,0.0f);

        GUI.color = c2;

        Color guiColor = Color.white * hsb.b;
        guiColor.a = 1.0f;
        GUI.color = guiColor;

        GUILayout.Box("", GUIStyle.none, GUILayout.Width(r.width), GUILayout.Height(r.height));//dummySize
        //GUI.Box(r, colorCircle, GUIStyle.none);
        GUI.Box(r, "", "colorCircle");

        float w = r.width;

        Vector2 pos = (new Vector2 (Mathf.Cos (hsb.h*360*Mathf.Deg2Rad), -Mathf.Sin (hsb.h*360*Mathf.Deg2Rad))* w *hsb.s/2);

        GUI.color = c;
        GUI.Box(new Rect(pos.x-5+cp.x, pos.y-5+cp.y, 10, 10),"","ColorcirclePicker");
        //GUI.Box(new Rect(cp.x, cp.y, 10, 10),"","ColorcirclePicker");

        c = hsb.ToColor ();

        //GUILayout.Label(getWhiteTexture(), style, GUILayout.ExpandWidth(true));

        // color chip
        GUIStyle style = new GUIStyle();
        style.stretchWidth = true;
        style.normal.background = GUILayoutExtra.getWhiteTexture();
        style.margin = new RectOffset(0,0,5,5);

        Rect r3 = r2;
        r3.x += r2.width + 10;
        //GUI.Label(r3, GUILayoutExtra.getWhiteTexture(), style);
        GUI.Label(r3, " ", "ColorChip");
        GUI.color = Color.white;
        return c;
    }
	private Color ColorCombine(Color a, Color b)
	{
		/*if (a == Color.white)
        {
            a = Color.black;
        }
        Color res = new Color();
        float fr = 1f;
        float fg = 1f;
        float fb = 1f;

        if (a.r + b.r > 1)
        {
            fr = 2.0f;
        }
        if (a.g + b.g > 1)
        {
            fg = 2.0f;
        }
        if (a.b + b.b > 1)
        {
            fb = 2.0f;
        }
        res.r = (a.r + b.r) / fr;
        res.g = (a.g + b.g) / fg;
        res.b = (a.b + b.b) / fb;
        res.a = 1.0f;
        return res;
*/
		if (a == Color.white)
		{
			return b;
		}
		if (b == Color.white)
		{
			return a;
		}
		HSBColor hsbA = HSBColor.FromColor(a);
		HSBColor hsbB = HSBColor.FromColor(b);
		
		HSBColor res = new HSBColor(0.5f * (hsbA.h + hsbB.h), hsbB.s, hsbB.b);
		return res.ToColor();
	}
Пример #42
0
	void OnColorChange(HSBColor color) 
	{
        this.color = color.ToColor();
	}
Пример #43
0
 public void UpdateColor()
 {
     //Vector3 direction = _parentObj.position - _transform.position;
     float angle = Vector3.Angle(Vector3.up, _transform.position);
     HSBColor newColor = new HSBColor(Mathf.Sin (angle + Mathf.PI / 2 ), 1f, 1f);
     _material.color = newColor.ToColor();
 }