当前位置: 首页>>代码示例>>C#>>正文


C# HSBColor类代码示例

本文整理汇总了C#中HSBColor的典型用法代码示例。如果您正苦于以下问题:C# HSBColor类的具体用法?C# HSBColor怎么用?C# HSBColor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HSBColor类属于命名空间,在下文中一共展示了HSBColor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FromColor

    public static HSBColor FromColor( Color color )
    {
        HSBColor result = new HSBColor( 0f, 0f, 0f, color.a );
        RGBToHSV( color, out result.h, out result.s, out result.b );

        return result;
    }
开发者ID:haozi000005,项目名称:happy2d,代码行数:7,代码来源:HSBColor.cs

示例2: Update

    // 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;
        }
    }
开发者ID:mjewkes,项目名称:SpaceRaceCollab,代码行数:26,代码来源:HSBTest.cs

示例3: CloseToWallTint

	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());
	}
开发者ID:samkern108,项目名称:InteractiveFiction,代码行数:7,代码来源:Background.cs

示例4: Start

	// Use this for initialization
	void Start()
	{
		// setup components
		lt = GetComponent<Light>();
		// setup hsb color
		col = new HSBColor(hue, saturation, brightness);
	}
开发者ID:bitchwhocodes,项目名称:ITP_Storytelling,代码行数:8,代码来源:ColorShift.cs

示例5: OnEnable

    private void OnEnable()
    {
      lightModes = new string[2];
      lightModes[0] = @"UnLit";
      lightModes[1] = @"BumpLit";

      spriteRenderer = this.GetComponent<SpriteRenderer>();

      sunLight = this.GetComponent<Light>();

      hsbColor = new HSBColor(Color.white);
      hsbColor.s = 1.0f;

      if (GameObject.Find("FlareSpawner0") != null)
      {
        flareSpawners.Add(GameObject.Find("FlareSpawner0").GetComponent<Spawner>());
        flareSpawners[0].enabled = false;
      }

      if (GameObject.Find("FlareSpawner1") != null)
      {
        flareSpawners.Add(GameObject.Find("FlareSpawner1").GetComponent<Spawner>());
        flareSpawners[1].enabled = false;
      }

      if (GameObject.Find("FlareSpawner2") != null)
      {
        flareSpawners.Add(GameObject.Find("FlareSpawner2").GetComponent<Spawner>());
        flareSpawners[2].enabled = false;
      }
    }
开发者ID:zacharymacleod,项目名称:Betrayer,代码行数:31,代码来源:Sun.cs

示例6: HSVToColor

    public Color HSVToColor(HSBColor hsbColor)
    {
        float r = hsbColor.b;
        float g = hsbColor.b;
        float b = hsbColor.b;
        if (hsbColor.s != 0)
        {
            float max = hsbColor.b;
            float dif = hsbColor.b * hsbColor.s;
            float min = hsbColor.b - dif;

            float h = hsbColor.h * 360f;

            if (h < 60f)
            {
                r = max;
                g = h * dif / 60f + min;
                b = min;
            }
            else if (h < 120f)
            {
                r = -(h - 120f) * dif / 60f + min;
                g = max;
                b = min;
            }
            else if (h < 180f)
            {
                r = min;
                g = max;
                b = (h - 120f) * dif / 60f + min;
            }
            else if (h < 240f)
            {
                r = min;
                g = -(h - 240f) * dif / 60f + min;
                b = max;
            }
            else if (h < 300f)
            {
                r = (h - 240f) * dif / 60f + min;
                g = min;
                b = max;
            }
            else if (h <= 360f)
            {
                r = max;
                g = min;
                b = -(h - 360f) * dif / 60 + min;
            }
            else
            {
                r = 0;
                g = 0;
                b = 0;
            }
        }

        return new Color(Mathf.Clamp01(r), Mathf.Clamp01(g), Mathf.Clamp01(b), hsbColor.a);
    }
开发者ID:OSW-team,项目名称:Project-4,代码行数:59,代码来源:EffectsColorizer.cs

示例7: GenerateNewColor

	void GenerateNewColor()
	{
		HSBColor newColor = new HSBColor(Random.value, saturation, brightness, alpha);

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


	}
开发者ID:adamison,项目名称:Transformation,代码行数:8,代码来源:RandomMaterialHue.cs

示例8: Update

 // Update is called once per frame
 void Update()
 {
     if(main != oldMain){
         mainHSB = HSBColor.FromColor(main);
         UpdateColors();
         oldMain = main;
     }
 }
开发者ID:jlocas,项目名称:TheGreatProject,代码行数:9,代码来源:ColorPalette.cs

示例9: OnEnable

    private void OnEnable()
    {
      spriteColorOutline = gameObject.GetComponent<SpriteColorOutline>();

      hsbColor = new HSBColor(Color.white);
      hsbColor.s = 1.0f;

      originalOutlineSize = spriteColorOutline.outlineSize;
    }
开发者ID:zacharymacleod,项目名称:Betrayer,代码行数:9,代码来源:DemoOutline.cs

示例10: Update

	// 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();
		}
	}
开发者ID:HarizMustafa,项目名称:SpessShooterX,代码行数:10,代码来源:RandomMaterialHue.cs

示例11: GetComplementary

    public List<Color> GetComplementary(int colorsNum)
    {
        List<Color> colors = new List<Color>();

        for(int i = 0; i < colorsNum; i++){
            HSBColor col = new HSBColor((mainHSB.h + (i * (1/(float)colorsNum))) % 1, mainHSB.s, mainHSB.b, mainHSB.a);
            colors.Add(HSBColor.ToColor(col));
        }

        return colors;
    }
开发者ID:jlocas,项目名称:TheGreatProject,代码行数:11,代码来源:ColorPalette.cs

示例12: Start

	// 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;
		}

	}
开发者ID:guozanhua,项目名称:kinect-oculus-demo,代码行数:13,代码来源:RandomHSV.cs

示例13: FromColor

    public static HSBColor FromColor(Color color)
    {
        HSBColor ret = new HSBColor(0f, 0f, 0f, color.a);

        float r = color.r;
        float g = color.g;
        float b = color.b;

        float max = Mathf.Max(r, Mathf.Max(g, b));

        if (max <= 0)
        {
            return ret;
        }

        float min = Mathf.Min(r, Mathf.Min(g, b));
        float dif = max - min;

        if (max > min)
        {
            if (g == max)
            {
                ret.h = (b - r) / dif * 60f + 120f;
            }
            else if (b == max)
            {
                ret.h = (r - g) / dif * 60f + 240f;
            }
            else if (b > g)
            {
                ret.h = (g - b) / dif * 60f + 360f;
            }
            else
            {
                ret.h = (g - b) / dif * 60f;
            }
            if (ret.h < 0)
            {
                ret.h = ret.h + 360f;
            }
        }
        else
        {
            ret.h = 0;
        }

        ret.h *= 1f / 360f;
        ret.s = (dif / max) * 1f;
        ret.b = max;

        return ret;
    }
开发者ID:LitpoEric,项目名称:Prticle-test,代码行数:52,代码来源:HSBColor.cs

示例14: UpdateCustomerNumber

    public void UpdateCustomerNumber()
    {
        customerNumberLabel.text = zoneModel.customers.Count.ToString();
        float transparency = .3f;
        HSBColor red = new HSBColor(new Color(1f,0f,0f,transparency));
        HSBColor green = new HSBColor(new Color(0f,1f,0f,transparency));

        icon.color = HSBColor.ToColor( HSBColor.Lerp(green, red, (float)zoneModel.customers.Count / zoneModel.maxQueue));
        progressIndicator.color = icon.color;

        progressIndicator.fillAmount = 0f;
        //icon.color = Color.Lerp(Color.green, Color.red, (float) zone.customers.Count / zone.maxQueue );
    }
开发者ID:vorrin,项目名称:store-game,代码行数:13,代码来源:ZoneView.cs

示例15: RGBCircle

    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;
    }
开发者ID:Blizzardx,项目名称:ClientFrameWork,代码行数:51,代码来源:GUIControls.cs


注:本文中的HSBColor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。