/// <summary> /// 返回将 ColorX 结构表示的两种颜色在 HSL 色彩空间按指定比例线性混合得到的颜色。 /// </summary> /// <param name="color1">ColorX 结构表示的第一种颜色。</param> /// <param name="color2">ColorX 结构表示的第二种颜色。</param> /// <param name="proportion">第一种颜色所占的比例,取值范围为 [0, 1] 或 (1, 100]。</param> /// <returns>ColorX 结构,表示将两种颜色在 HSL 色彩空间按指定比例线性混合得到的颜色。</returns> public static ColorX BlendByHSL(ColorX color1, ColorX color2, double proportion) { proportion = _CheckProportion(proportion); PointD3D hsl1 = color1.HSL; PointD3D hsl2 = color2.HSL; double deltaHue = hsl1.X - hsl2.X; if (deltaHue < -180) { deltaHue += 360; } else if (deltaHue > 180) { deltaHue -= 360; } double newHue = hsl2.X + deltaHue * proportion; if (newHue < 0) { newHue += 360; } else if (newHue >= 360) { newHue -= 360; } return(ColorX.FromHSL(newHue, hsl1.Y * proportion + hsl2.Y * (1 - proportion), hsl1.Z * proportion + hsl2.Z * (1 - proportion), color1.Opacity * proportion + color2.Opacity * (1 - proportion))); }
public override void init(Dictionary <string, string> param) { this.param = param; GameObject g = Resources.Load(GameSetting.PATH_PREFAB + "Text") as GameObject; this.rootObject = (GameObject)Instantiate(g, new Vector3(0, 0.5f, -3.2f), Quaternion.identity); GUIText guiText = this.rootObject.GetComponent <GUIText> ().guiText; guiText.alignment = TextEnum.textAlignment(this.param["alignment"]); guiText.anchor = TextEnum.textAnchor(this.param["anchor"]); string color = this.param ["color"]; Color objColor = ColorX.HexToRGB(color); objColor.a = 0; guiText.color = objColor; guiText.fontSize = int.Parse(this.param ["fontsize"]); this.guiScaler = new GuiScaler(guiText); this.rootObject.name = this.name; if (this.param ["layer"] == "ui") { //タグをつける this.rootObject.tag = "ui"; } }
public object ReadYaml(IParser parser, Type type) { var scalar = (YamlDotNet.Core.Events.Scalar)parser.Current; var value = scalar.Value; if (string.IsNullOrWhiteSpace(value)) { parser.MoveNext(); return(null); } var values = value .Split(delimiter, StringSplitOptions.RemoveEmptyEntries) .ToList(); Color?color = TryParseEachAndRemove <Color?>(values, x => { bool success = ColorX.TryParse(x, out Color c); return(success, c); }); int?size = TryParseEachAndRemove(values, x => { bool success = int.TryParse(x, out int number); return(success, number); }); var result = new BorderSideStyle { Width = size ?? 0, Color = color ?? Color.Transparent, }; parser.MoveNext(); return(result); }
public void ChangeColor(ColorX color) { gunColor = color; isActive = true; switch (color) { case ColorX.red: gunMaterial.SetColor("_Color", Color.red); break; case ColorX.green: gunMaterial.SetColor("_Color", Color.green); break; case ColorX.blue: gunMaterial.SetColor("_Color", Color.blue); break; case ColorX.pink: gunMaterial.SetColor("_Color", Color.magenta); break; case ColorX.yellow: gunMaterial.SetColor("_Color", Color.yellow); break; case ColorX.cyan: gunMaterial.SetColor("_Color", Color.cyan); break; default: break; } }
void OnTriggerEnter(Collider col) { if (col.CompareTag("Coin")) { UpdateScore(); AudioSource.PlayClipAtPoint(gotCoin, transform.position); Destroy(col.gameObject); } if (col.CompareTag("Color Pill")) { playerColor = col.gameObject.GetComponent <PillColor>().color; ChangeColor(); AudioSource.PlayClipAtPoint(changedColor, transform.position); Destroy(col.gameObject); } if (col.CompareTag("Enemy")) { Die(); } if (col.CompareTag("Gun Pill")) { gunColor.ChangeColor(col.gameObject.GetComponent <GunPillColor>().color); AudioSource.PlayClipAtPoint(gunColorChange, transform.position); Destroy(col.gameObject); } }
//現在のメッセージをクリアする public void clearCurrentMessage() { this.messageForSaveTitle = this.currentMessage; GameObject obj = GameObject.Find("Canvas/_sp_chara_name"); Color c; string name = ""; if (obj == null) { c = Color.white; } else { c = obj.GetComponent <Text> ().color; name = obj.GetComponent <Text>().text; } //バックログ用 string color = ColorX.RGBToHex(c); this.gameManager.logManager.addLog(name, color, this.currentMessage); this.currentMessage = ""; }
public override void start() { string name = this.param ["val"]; string show_name = name; GameObject obj = GameObject.Find("_sp_chara_name"); if (StatusManager.variable.get("_chara_jname." + name) != "null") { show_name = StatusManager.variable.get("_chara_jname." + name); //色の指定もある場合 if (StatusManager.variable.get("_chara_jcolor." + name) != "null") { obj.GetComponent <GUIText> ().guiText.color = ColorX.HexToRGB(StatusManager.variable.get("_chara_jcolor." + name)); } } else { obj.GetComponent <GUIText> ().guiText.color = Color.white; } Image img = this.gameManager.imageManager.getImage("_sp_chara_name"); img.dicSave ["val"] = show_name; obj.GetComponent <GUIText> ().guiText.text = show_name; this.gameManager.nextOrder(); }
private void OnMouseOver() { if (!pbn.PbnSequenceActive) { return; } Ray ray = Camera.main.ViewportPointToRay(Camera.main.ScreenToViewportPoint(Input.mousePosition)); RaycastHit hit; if (Physics.Raycast(ray, out hit, 1000)) { Color c = GetColorAtPoint(hit.point); debugHit = c; if (ColorX.Approximately(c, Color.green)) { paintedNumber = ColorCell.ActiveNumber; Valid = paintedNumber == colorCell.CellNumber; SetColor(spriteRenderer); } } }
/** * Update death message with the given player as killer. * Message fades away via TweenColor */ public void Activate(PhotonPlayer player) { // find the RocketFightPlayer instance for the given player to get its color Match match = GameObject.Find("PhotonNetman").GetComponent <Match>(); List <RocketFightPlayer> playerList = match.GetPlayerList(); RocketFightPlayer rfplayer = null; foreach (RocketFightPlayer rfp in playerList) { if (rfp.photonPlayer == player) { rfplayer = rfp; break; } } // activate label if it is inactive if (!label.gameObject.activeSelf) { label.gameObject.SetActive(true); } // update text label.text = "[" + ColorX.RGBToHex(rfplayer.color) + "] " + rfplayer.photonPlayer.name + " [ffffff]has killed you!"; // init fade via TweenColor label.color = Color.white; TweenColor.Begin(label.gameObject, 1.5f, new Color(1, 1, 1, 0)); }
public void LoadWorlds(IContentProvider content) { CSettingsFile file = new CSettingsFile(content.ReadAllText("lvls/worlds.cfg")); for (int i = 0; i < file.SectionCount; i++) { string w = file.getSection(i); CWorld world; world = new CWorld(); world.name = file.ReadString(w + ".name", w); world.background = file.ReadString(w + ".background", "bg1.png"); string light = file.ReadString(w + ".ambient", "ffffff"); world.light = ColorX.FromArgb(light); string[] values = file.ReadStringArray(w + ".levels"); world.lvls.AddRange(values); if (world.lvls.Count > 0) { worlds.Add(world); } } }
public override void init(Dictionary <string, string> param) { this.param = param; GameObject g = Resources.Load(GameSetting.PATH_PREFAB + "Text") as GameObject; this.rootObject = (GameObject)Instantiate(g, new Vector3(0, 0.5f, -3.2f), Quaternion.identity); GameObject canvas = GameObject.Find("Canvas") as GameObject; this.rootObject.name = param ["name"]; this.rootObject.transform.parent = canvas.transform; UnityEngine.UI.Text guiText = this.rootObject.GetComponent <Text> (); //Debug.Log (this.param ["anchor"]); //Debug.Log (TextEnum.textAnchor (this.param ["anchor"])); guiText.alignment = TextEnum.textAnchor(this.param ["anchor"]); string color = this.param ["color"]; Color objColor = ColorX.HexToRGB(color); objColor.a = 0; guiText.color = objColor; guiText.fontSize = int.Parse(this.param ["fontsize"]); this.rootObject.name = this.name; }
public void HsvCyan() { var clr1 = ColorX.FromHsv(200, 1, 1); clr1.A.Should().Be(0xff); clr1.R.Should().Be(0); clr1.G.Should().Be(0xa9); clr1.B.Should().Be(0xff); }
public void HsvMagenta() { var clr1 = ColorX.FromHsv(330, 1, 1); clr1.A.Should().Be(0xff); clr1.R.Should().Be(0xff); clr1.G.Should().Be(0); clr1.B.Should().Be(0x7f); }
/** * Set label text to current network ping and set color, depending on ping value * to something between green and red. */ void Update() { int ping = PhotonNetwork.GetPing(); float r = (float)PhotonNetwork.GetPing() / 300; float g = 1 - r; label.text = "Ping: [" + ColorX.RGBToHex(new Color(r, g, 0, 1)) + "]"; label.text += ping.ToString(); }
public void HsvBlue() { var clr1 = ColorX.FromHsv(240, 1, 1); clr1.A.Should().Be(0xff); clr1.R.Should().Be(0); clr1.G.Should().Be(0); clr1.B.Should().Be(0xff); }
void IXleSerializable.ReadData(XleSerializationInfo info) { X = info.ReadInt32("X"); Y = info.ReadInt32("Y"); Color = ColorX.FromArgb(info.ReadInt32("Color").ToString("X8")); HP = info.ReadInt32("HP"); Attack = info.ReadInt32("Attack"); Defense = info.ReadInt32("Defense"); }
void IXleSerializable.ReadData(XleSerializationInfo info) { mGuards = info.ReadList <Guard>("Guards"); DefaultAttack = info.ReadInt32("GuardDefaultAttack"); DefaultColor = ColorX.FromArgb(info.ReadInt32("GuardDefaultColor").ToString("X8")); DefaultDefense = info.ReadInt32("GuardDefaultDefense"); DefaultHP = info.ReadInt32("GuardDefaultHP"); InitializeGuardData(); }
public override void start() { //this.gameView.messageArea.GetComponent<GUIText> ().guiText.color = ColorX.HexToRGB (this.gameManager.getConfig ("messageFontColor")); this.gameView.messageArea.GetComponent <Text>().color = ColorX.HexToRGB(this.gameManager.getConfig("messageFontColor"));; //this.gameView.messageArea.GetComponent<GUIText> ().guiText.fontSize = int.Parse(this.gameManager.getConfig ("messageFontSize")); this.gameView.messageArea.GetComponent <Text> ().fontSize = int.Parse(this.gameManager.getConfig("messageFontSize")); this.gameManager.nextOrder(); }
static ConsoleThemes() { Paper = Validate(new ConsoleTheme { BackgroundColor = new Color(0xff, 0xfe, 0xd3), EntryColor = new Color(0x40, 0x30, 0x1a), EntryBackgroundColor = new Color(0xff, 0xff, 0xe3), MessageThemes = { { ConsoleMessageType.Text, new MessageTheme(new Color(0x60, 0x50, 0x2a)) }, { ConsoleMessageType.UserInput, new MessageTheme(new Color(0x40, 0x30,0x1a), new Color(0xff, 0xff, 0xe3)) }, { ConsoleMessageType.Temporary, new MessageTheme(Color.Red, new Color(0xff,0xff, 0xe8)) } } }); Green = Validate(new ConsoleTheme { BackgroundColor = new Color(0x20, 0x20, 0x20), EntryPrefix = "$ ", EntryColor = ColorX.FromHsv(120, 0.8, 1), EntryBackgroundColor = new Color(0x30, 0x30, 0x30), MessageThemes = { { ConsoleMessageType.Text, new MessageTheme(ColorX.FromHsv(120, 1, 0.8)) }, { ConsoleMessageType.UserInput, new MessageTheme(ColorX.FromHsv(120, 0.8,1), new Color(0x30, 0x30, 0x30)) }, { ConsoleMessageType.Temporary, new MessageTheme(Color.White, new Color(0x50,0x50, 0x50)) } } }); Classic = Validate(new ConsoleTheme { BackgroundColor = new Color(0x33, 0x27, 0x99), EntryColor = new Color(0x70, 0x64, 0xd6), MessageThemes = { { ConsoleMessageType.Text, new MessageTheme(new Color(0x70, 0x64, 0xd6)) }, { ConsoleMessageType.UserInput, new MessageTheme(new Color(0x70, 0x64, 0xd6)) }, { ConsoleMessageType.Temporary, new MessageTheme(new Color(0xcb, 0xd7, 0x65)) } } }); WhiteOnBlack = Validate(new ConsoleTheme { BackgroundColor = Color.Black, EntryColor = Color.Yellow, MessageThemes = { { ConsoleMessageType.Text, new MessageTheme(Color.White) }, { ConsoleMessageType.UserInput, new MessageTheme(Color.Yellow) }, { ConsoleMessageType.Temporary, new MessageTheme(Color.Red, Color.White)} } }); Default = Green; }
void SpriteToColorString(Sprite s, int colorCount) { mappedColors.Clear(); Texture2D t = s.CreateTexture2D(); List <string> colors = ColorX.GetColorsHexesFromStrip(t, colorCount); mappedColors = colors.Select(c => new ColorMap() { color = c.ToColor(), colorString = c }).ToList(); }
public void HsvRed() { var clr1 = ColorX.FromHsv(0, 1, 1); var clr2 = ColorX.FromHsv(360, 1, 1); clr1.A.Should().Be(0xff); clr1.R.Should().Be(0xff); clr1.G.Should().Be(0); clr1.B.Should().Be(0); clr1.Should().Be(clr2); }
void OnTriggerEnter(Collider col) { if (col.CompareTag("Player")) { playerColor = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovement>().playerColor; if (color == playerColor) { GameManager.NextLevel(); } } }
public void HsvYellow() { var clr1 = ColorX.FromHsv(60, 1, 1); var clr2 = ColorX.FromHsv(420, 1, 1); clr1.A.Should().Be(0xff); clr1.R.Should().Be(0xff); clr1.G.Should().Be(0xff); clr1.B.Should().Be(0); clr1.Should().Be(clr2); }
public void HsvGreen() { var clr1 = ColorX.FromHsv(120, 1, 1); var clr2 = ColorX.FromHsv(-240, 1, 1); clr1.A.Should().Be(0xff); clr1.R.Should().Be(0); clr1.G.Should().Be(0xff); clr1.B.Should().Be(0); clr1.Should().Be(clr2); }
void OnCollisionEnter(Collision col) { if (col.gameObject.CompareTag("Player")) { ColorX playerColor = col.gameObject.GetComponent <PlayerMovement>().playerColor; if (playerColor == blockColor) { fadeAnimation.Play(); float t = fadeAnimation.clip.length; Destroy(gameObject, t); } } }
public void Execute(LayoutContext context, string arg) { Color newColor; if (ColorX.TryParse(arg, out newColor)) { context.Font.Color = newColor; } else { context.Font.Color = Color.White; } }
private void DrawBoxes() { Size size = new Size(10, 10); for (int i = 0; i < points.Count; i++) { var point = points[i]; Color clr = ColorX.FromHsv(i / 5.0, 1, 1); Rectangle dest = new Rectangle(point, size); spriteBatch.Draw(whiteTexture, dest, clr); } }
public void ToAbgrString() { string[] colorsToTest = new[] { "ffaabbcc", "20f8f8f8", "ffaabbcc", "ffffffff", "01000000", "01020304" }; foreach (var color in colorsToTest) { var text = ColorX.FromAbgr(color).PackedValue.ToString("x8"); text.ToLowerInvariant().Should().Be(color, "Failed to convert color {0} correctly.", color); } }
private static Color AttributeToColor(XElement node, string name) { var attrib = GetAttribute(node, name); try { Color result = ColorX.FromArgb(attrib.Value); return(result); } catch (Exception e) { throw new InvalidOperationException("Attribute " + name + " does not contain a properly formatted color.", e); } }
public Field(Vector3 pos, float s, string c) { if (c.StartsWith("\"#")) { Color = ColorX.HexToRGB(c.Substring(2, c.Length - 3)); } else { Color = ColorX.HexToRGB(c); } Position = pos; Size = s; Faces = new bool[6] { true, true, true, true, true, true }; }