protected void DefaultDictionary() { translator = new Dictionary <int, Material>() { { HexColor.DecHex("00000000"), MatMake("default") }, //This should be an empty block. I watched as it was used in the 'delete cube' function of Cubiquity (Quantized color(0,0,0,0)) { HexColor.DecHex("636573FF"), MatMake("rock") }, //Stone { HexColor.DecHex("19E619FF"), MatMake("grass") }, //Grass { HexColor.DecHex("8F4700FF"), MatMake("dirt") }, //Dirt { HexColor.DecHex("8A8C96FF"), MatMake("rock") }, //Cobble { HexColor.DecHex("CCAA00FF"), MatMake("dirt") }, //Wood { HexColor.DecHex("CBFF96FF"), MatMake("grass") }, //Sapling { HexColor.DecHex("000A24FF"), MatMake("rock") }, //Bedrock { HexColor.DecHex("4064C7FF"), MatMake("default") }, //Flowing Water { HexColor.DecHex("1B24A6FF"), MatMake("default") }, //Water { HexColor.DecHex("ED590EFF"), MatMake("default") }, //Flowing Lava { HexColor.DecHex("D94800FF"), MatMake("default") }, //Lava { HexColor.DecHex("F7F2C8FF"), MatMake("dirt") }, //Sand { HexColor.DecHex("1A1616FF"), MatMake("dirt") }, //Coal { HexColor.DecHex("FFCC00FF"), MatMake("dirt") }, //Log { HexColor.DecHex("39A377FF"), MatMake("grass") }, //Leaves { HexColor.DecHex("FFB8E0FF"), MatMake("default") }, //Bed { HexColor.DecHex("E7E8D8FF"), MatMake("default") }, //Wool { HexColor.DecHex("CCCCCCFF"), MatMake("rock") }, //Stone slab { HexColor.DecHex("753437FF"), MatMake("dirt") }, //Brick { HexColor.DecHex("FF1C27FF"), MatMake("dirt") }, //TNT { HexColor.DecHex("2E2D2DFF"), MatMake("rock") }, //Furnace { HexColor.DecHex("67ED00FF"), MatMake("grass") }, //Cactus { HexColor.DecHex("C795F0FF"), MatMake("default") } //Portal }; }
public async Task RoleColor(IRole role, HexColor hc) { if (role == null) { await ReplyErrorLocalized("rc_not_exist").ConfigureAwait(false); return; } var gu = (IGuildUser)Context.User; if (!gu.GuildPermissions.Administrator && (!gu.RoleIds.Any() || gu.GetRoles().Max(r => r.Position) < role.Position)) { await ReplyErrorLocalized("rc_perms_pos").ConfigureAwait(false); return; } try { await role.ModifyAsync(r => r.Color = hc).ConfigureAwait(false); await ReplyConfirmLocalized("rc", Format.Bold(role.Name), Format.Bold(hc.ToString())).ConfigureAwait(false); } catch (Exception) { await ReplyErrorLocalized("rc_perms").ConfigureAwait(false); } }
/** * Returns Adjacent hex with matching "HexColor" */ private void SelectAdjacentHexColor(Vector2 vec2, HexColor color) { int maxX = hexList.GetLength(0); int maxY = hexList.GetLength(1); List <Vector2> m_AdjacentHex = m_AdjacentHexOddRow; if (vec2.y % 2 == 0) { m_AdjacentHex = m_AdjacentHexEvenRow; } foreach (Vector2 vec in m_AdjacentHex) { Vector2 adjHexVec = vec + vec2; if (!m_selectedHex.Contains(adjHexVec)) { if (adjHexVec.x < maxX && adjHexVec.x >= 0 && adjHexVec.y < maxY && adjHexVec.y >= 0) { GameObject hex = hexList[(int)adjHexVec.x, (int)adjHexVec.y]; HexObjScript hexScript = hex.GetComponent <HexObjScript>(); if (hexScript.GetHexColor() == color) { m_selectedHex.Add(new Vector2(adjHexVec.x, adjHexVec.y)); SelectAdjacentHexColor(adjHexVec, color); hexScript.MouseOverColor(); } } } } }
public static ValueTask <FluidValue> ColorExtract(FluidValue input, FilterArguments arguments, TemplateContext context) { var value = input.ToStringValue(); RgbColor rgbColor; HslColor hslColor; if (HexColor.TryParse(value, out HexColor hexColor)) { rgbColor = (RgbColor)hexColor; hslColor = (HslColor)hexColor; } else if (RgbColor.TryParse(value, out rgbColor)) { hslColor = (HslColor)rgbColor; } else if (HslColor.TryParse(value, out hslColor)) { rgbColor = (RgbColor)hslColor; } else { return(NilValue.Empty); } return(arguments.At(0).ToStringValue() switch { "alpha" => new StringValue(rgbColor.A.ToString()), "red" => new StringValue(rgbColor.R.ToString()), "green" => new StringValue(rgbColor.G.ToString()), "blue" => new StringValue(rgbColor.B.ToString()), "hue" => new StringValue(hslColor.H.ToString()), "saturation" => new StringValue(Convert.ToInt32(hslColor.S * 100.0).ToString()), "lightness" => new StringValue(Convert.ToInt32(hslColor.L * 100.0).ToString()), _ => NilValue.Empty, });
public static string GetHexColor(HexColor color) { switch (color) { case HexColor.Blue: return("#0070dd"); case HexColor.Gray: return("#808080"); case HexColor.White: return("#ffffff"); case HexColor.Green: return("#1eff00"); case HexColor.Orange: return("#ff8000"); case HexColor.Purple: return("#a335ee"); case HexColor.Red: return("red"); case HexColor.LightGray: return("#A0A0A0"); default: return(null); } }
public async Task UserRoleColor(SocketRole role, HexColor color) { if (_uow.UserRoleColorBindings.HasBinding(Context.User.Id, role)) { var allowedRoleColors = (Context.User as IGuildUser).GetRoles().Select(r => r.Color).ToArray(); var forbiddenRoleColors = Context.Guild.Roles.Where(r => r.IsHoisted && r.Id != role.Id); var converter = new ConverterBuilder().FromRGB().ToLab().Build(); var colorDifference = new CIEDE2000ColorDifference(); var requestedColor = converter.Convert(color.ToRGBColor()); var similarityRadius = _uow.GuildConfigs.For(Context.Guild.Id).ColorMetricSimilarityRadius; var similarlyColoredRole = forbiddenRoleColors.FirstOrDefault(c => colorDifference.ComputeDifference(requestedColor, converter.Convert(RGBColor.FromRGB8Bit(c.Color.R, c.Color.G, c.Color.B))) < similarityRadius); if (similarlyColoredRole == null || allowedRoleColors.Any(c => colorDifference.ComputeDifference(requestedColor, converter.Convert(RGBColor.FromRGB8Bit(c.R, c.G, c.B))) < similarityRadius)) { await role.ModifyAsync(rp => rp.Color = color).ConfigureAwait(false); await ReplyConfirmLocalized("userrolecolor_changed", role.Name, color).ConfigureAwait(false); } else { await ReplyErrorLocalized("userrolecolor_color_too_similar", color, similarlyColoredRole.Name).ConfigureAwait(false); } } else { await ReplyErrorLocalized("userrolecolor_no_binding", role.Name).ConfigureAwait(false); } }
private int GetIndexOfColor(Color color) { var color2 = new HexColor(); if (color.Name.IndexOf("#") > -1) { color2.Red = Int32.Parse(color.Name.Substring(1, 2), NumberStyles.AllowHexSpecifier); color2.Green = Int32.Parse(color.Name.Substring(3, 2), NumberStyles.AllowHexSpecifier); color2.Blue = Int32.Parse(color.Name.Substring(5, 2), NumberStyles.AllowHexSpecifier); } else { color2.Red = color.R; color2.Green = color.G; color2.Blue = color.B; } var index = colors.IndexOf(color2); if (index > -1) { return(index + 1); } colors.Add(color2); return(colors.Count); }
public void HighlightMouse(Vector3 position, int radius, HexColor color) { position = transform.InverseTransformPoint(position); HexCoordinates coordinates = HexCoordinates.FromPosition(position); int index = coordinates.X + coordinates.Z * cellCountX + coordinates.Z / 2; if (index >= 0 && index < totalCells && CheckOuterEdges(index, coordinates)) { HexCell cell = cells[index]; currentCell = cell; // if color is red (for targeting) and cell is white if (previousCell != null && currentCell != previousCell) { if ((color == HexColor.RED && cell.GetWhite() == true) || color != HexColor.RED) { HighLightCellsCircle(cell, radius, color); } else if (color == HexColor.RED) { clearHighlightedList(color); } } previousCell = currentCell; } }
public async Task recording_user_updates_userinfo_data() { // given UserRepo userRepo = CreateUserRepo(); const string userId = "123"; const string displayNameBefore = "ユーザー名"; const string displayNameAfter = "インマウィアブ"; const string usernameBefore = "username"; const string usernameAfter = "i_changed_my_name"; // when User userBefore = await userRepo.RecordUser(new UserInfo( userId, twitchDisplayName : displayNameBefore, simpleName : usernameBefore, HexColor.FromWithHash("#123456"))); User userAfter = await userRepo.RecordUser(new UserInfo( userId, twitchDisplayName : displayNameAfter, simpleName : usernameAfter, HexColor.FromWithHash("#abcdef"))); // then Assert.AreEqual(1, await userRepo.Collection.CountDocumentsAsync(FilterDefinition <User> .Empty)); Assert.AreEqual(userId, userBefore.Id); Assert.AreEqual(userId, userAfter.Id); Assert.AreEqual(displayNameBefore, userBefore.TwitchDisplayName); Assert.AreEqual(displayNameAfter, userAfter.TwitchDisplayName); Assert.AreEqual(usernameBefore, userBefore.SimpleName); Assert.AreEqual(usernameAfter, userAfter.SimpleName); Assert.AreEqual("123456", userBefore.Color); Assert.AreEqual("abcdef", userAfter.Color); }
public IEnumerator StartGameIE() { colorPalette = colorManager.getBlockColors(); foreach (Transform t in transform) { GameObject.Destroy(t.gameObject); } BackgroundBlocks = new List <Blocks>(); // Initialise space for the blocks in the grid blocks = new Block[gridSize, gridSize]; // Calculate the bottom left position of the grid gridBaseline = -0.5f * new Vector3(((blockPaddingSize + blockSize) * (gridSize - 1)), (blockPaddingSize + blockSize) * (gridSize - 1), 0f); gridBaseline.y += 60.0f; // Initialise Game Services GooglePlayGames.PlayGamesPlatform.Activate(); // Spawn the static background blocks for (int j = gridSize - 2, nj = 0; j > nj; j--) { for (int i = 1, ni = gridSize - 1; i < ni; i++) { Block backgroundBlockInstance = (Block)Instantiate(blockPrefab); backgroundBlockInstance.SquareSize = blockSize; backgroundBlockInstance.Color = HexColor.ColorFromHex("D2D2D2" /*"E9ECEE"*/); backgroundBlockInstance.transform.parent = transform; backgroundBlockInstance.transform.localPosition = GridPosTo3DPos(i, j, -10); backgroundBlockInstance.transform.localScale = Vector3.one; // * 0.001f; backgroundBlockInstance.IsBackground = true; backgroundBlockInstance.gameObject.layer = 8; Blocks sBlock = new Blocks(); sBlock.block = backgroundBlockInstance; BackgroundBlocks.Add(sBlock); //U9Transition transitions = U9T.HOT (HOTween.To, backgroundBlockInstance.gameObject.transform, 0.3f, new TweenParms().Prop("localScale", Vector3.one,false).Ease(EaseType.EaseOutExpo)); U9Transition transitions = U9T.LT(LeanTween.scale, backgroundBlockInstance.gameObject, Vector3.one, 0.3f, iTween.Hash("ease", LeanTweenType.easeOutExpo)); //U9Transition transitions = U9T.T (iTween.ScaleTo, backgroundBlockInstance.gameObject, iTween.Hash ("scale", new Vector3(1,1,1), "time", 0.3f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo )); transitions.Begin(); yield return(new WaitForSeconds(0.05f)); } } GameObject intro = (GameObject)Instantiate(_IntroEffect); StartNewGame(); GameCreated = true; }
/** * <summary>RGBカラーをHexカラーに変換する.</summary> */ public static HexColor FromColor(Color color) { HexColor hexcolor = new HexColor(); string hex = FormColorString(color); hexcolor.hex = hex; return(hexcolor); }
private void ColorCells(HexCell cell, HexColor color, Boolean b, int radius) { selectedCells.Clear(); selectedCells.Add(cell); List <HexCell> temp = new List <HexCell>(); for (int i = 1; i < radius; i++) { foreach (HexCell c in selectedCells) { for (int j = 0; j < 6; j++) { if (c.GetNeighbor(Numerical(j)) != null) { if (!c.GetNeighbor(Numerical(j)).IsImpassible() || color == HexColor.NONE) { temp.Add(c.GetNeighbor(Numerical(j))); } } } } foreach (HexCell c in temp) { if (!selectedCells.Contains(c)) { selectedCells.Add(c); } } temp.Clear(); } foreach (HexCell c in selectedCells) { if (color == HexColor.RED) { c.RedHighlight(true); } else if (color == HexColor.CYAN) { c.CyanHighlight(true); } else if (color == HexColor.WHITE) { c.Highlight(true); } else { c.CellGrid(b); } } }
//Gets the cell that was clicked by the user public void OnClickColorCell(Vector3 position, HexColor color, Boolean b, int radius) { position = transform.InverseTransformPoint(position); HexCoordinates coordinates = HexCoordinates.FromPosition(position); int index = coordinates.X + coordinates.Z * cellCountX + coordinates.Z / 2; if (index >= 0 && index < totalCells && CheckOuterEdges(index, coordinates)) { HexCell cell = cells[index]; ColorCells(cell, color, b, radius); Debug.Log("touched at " + coordinates.ToString()); } }
void DeserializeColor() { if (string.IsNullOrEmpty(HexColor)) { color = Colors.Black; } else { var a = byte.Parse(HexColor.Substring(1, 2), System.Globalization.NumberStyles.HexNumber); var r = byte.Parse(HexColor.Substring(3, 2), System.Globalization.NumberStyles.HexNumber); var g = byte.Parse(HexColor.Substring(5, 2), System.Globalization.NumberStyles.HexNumber); var b = byte.Parse(HexColor.Substring(7, 2), System.Globalization.NumberStyles.HexNumber); color = Color.FromArgb(a, r, g, b); } }
private NSImage GetHexImage(HexColor color) { switch (color) { case HexColor.Off: return(NSImage.ImageNamed("MantaHex")); case HexColor.Yellow: return(NSImage.ImageNamed("MantaHexYellow")); case HexColor.Red: return(NSImage.ImageNamed("MantaHexRed")); case HexColor.Both: return(NSImage.ImageNamed("MantaHexBoth")); default: return(NSImage.ImageNamed("MantaHex")); } }
private HexColor GetNextHexColor(HexColor color) { switch (color) { case HexColor.Off: return(HexColor.Yellow); case HexColor.Yellow: return(HexColor.Red); case HexColor.Red: return(HexColor.Both); case HexColor.Both: return(HexColor.Off); default: return(HexColor.Off); } }
public void CreateCells(int width, int height) { int cellsCount = width * height; NativeArray <Entity> cellsArray = new NativeArray <Entity>(cellsCount, Allocator.Temp); EntityArchetype archetype = HexCellArchetype.GetArchetype(); entityManager.CreateEntity(archetype, cellsArray); for (int z = 0, i = 0; z < height; z++) { for (int x = 0; x < width; x++) { int elevation = UnityEngine.Random.Range(0, 6); entityManager.SetComponentData( cellsArray[i], CoordinatesService.CreateFromOffset(x, z) ); var pos = GetCellPosition(x, elevation, z); entityManager.SetComponentData( cellsArray[i], new Translation { Value = pos } ); entityManager.SetComponentData( cellsArray[i], new ColorComponent { Value = HexColor.GetRandomColor() } ); entityManager.SetComponentData( cellsArray[i], new Elevation { Value = elevation } ); i++; } } }
public void StartGame() { colorPalette = colorManager.getBlockColors(); foreach (Transform t in transform) { GameObject.Destroy(t.gameObject); } BackgroundBlocks = new List <Blocks>(); // Initialise space for the blocks in the grid blocks = new Block[gridSize, gridSize]; // Calculate the bottom left position of the grid gridBaseline = -0.5f * new Vector3(((blockPaddingSize + blockSize) * (gridSize - 1)), (blockPaddingSize + blockSize) * (gridSize - 1), 0f); gridBaseline.y += 60.0f; // Spawn the static background blocks for (int i = 1, ni = gridSize - 1; i < ni; i++) { for (int j = 1, nj = gridSize - 1; j < nj; j++) { Block backgroundBlockInstance = (Block)Instantiate(blockPrefab); backgroundBlockInstance.SquareSize = blockSize; backgroundBlockInstance.Color = HexColor.ColorFromHex("D2D2D2" /*"E9ECEE"*/); backgroundBlockInstance.transform.parent = transform; backgroundBlockInstance.transform.localScale = Vector3.one; backgroundBlockInstance.transform.localPosition = GridPosTo3DPos(i, j, -10); backgroundBlockInstance.IsBackground = true; backgroundBlockInstance.gameObject.layer = 8; Blocks sBlock = new Blocks(); sBlock.block = backgroundBlockInstance; BackgroundBlocks.Add(sBlock); } } StartNewGame(); GameCreated = true; }
public static bool TryParse(string value, out HexColor color) { color = HexColor.Empty; if (String.IsNullOrEmpty(value)) { return(false); } if (value[0] == '#') { string red, blue, green; switch (value.Length) { case 4: red = Char.ToString(value[1]); green = Char.ToString(value[2]); blue = Char.ToString(value[3]); if (IsHexadecimal(red) && IsHexadecimal(green) && IsHexadecimal(blue)) { color = new HexColor(red, green, blue); return(true); } break; case 7: red = value.Substring(1, 2); green = value.Substring(3, 2); blue = value.Substring(5, 2); if (IsHexadecimal(red) && IsHexadecimal(green) && IsHexadecimal(blue)) { color = new HexColor(red, green, blue); return(true); } break; } } return(false); }
/// <summary> /// ミッションクリアのマーキー表示 /// </summary> static public void SetupMissionClearMessage() { ClearMissionClearMessage(); //---------------------------------------- // 新規達成演出前のアチーブメントがあるならメッセージ表示 //---------------------------------------- if (ResidentParam.m_AchievementClear != null && ResidentParam.m_AchievementClear.m_BufferSize > 0) { m_MsgBarResetText = true; m_MsgBarRequestInputIndex = 0; for (int i = 0; i < ResidentParam.m_AchievementClear.m_BufferSize; ++i) { //---------------------------------------- // アチーブメントが演出が必要なステータス状況かチェック //---------------------------------------- PacketAchievement cAchievement = ResidentParam.m_AchievementClear[i]; if (cAchievement == null) { continue; } if (cAchievement.server_state != (int)ServerDataDefine.ACHIEVEMENT_STATE.ACHIEVEMENT_STATE_S1_T1_E0_S0) { continue; } // クエストミッションはミッション画面に表示されず、直接アイテムを受け取るので弾く if (cAchievement.achievement_category_id == (int)ServerDataDefine.ACHIEVEMENT_CATEGORY_TYPE.QUEST) { continue; } HeaderMessage message = new HeaderMessage(); message.fix_id = cAchievement.fix_id; message.message = string.Format(GameTextUtil.GetText("achievement_complete"), TextUtil.RemoveNewLine(cAchievement.draw_msg)); message.message_color = Color.white; message.bg_color = HexColor.ToColor("#f90974"); message.type = HeaderMessage.MESSAGE_TYPE.ACHIEVEMENT_CLEAR; message.priority = ResidentParam.m_AchievementClear.m_BufferSize - i; m_MsgBarOtherMessageList.Add(message); } m_MsgBarOtherMessageList.Sort(HeaderMessage.SortCompare); } }
/** * @brief NGUIのカラータグの文字数を返す * return カラータグの文字数 [FFAA00]=8 [-]=3 それ以外は0 */ static public int ParseSymbol(string text, int index, List <Color> colors, bool premultiply) { int length = text.Length; if (index + 2 < length) { if (text[index + 1] == '-') { if (text[index + 2] == ']') { if (colors != null && colors.Count > 1) { colors.RemoveAt(colors.Count - 1); } return(3); } } else if (index + 7 < length) { if (text[index + 7] == ']') { if (colors != null) { Color c = HexColor.ToColor(text.Substring(index + 1, 6)); if (HexColor.FormColorString(c).Substring(1, 6) != text.Substring(index + 1, 6)) { return(0); } c.a = colors[colors.Count - 1].a; if (premultiply && c.a != 1f) { c = Color.Lerp(ColorUtil.COLOR_INVISIBLE, c, c.a); } colors.Add(c); } return(8); } } } return(0); }
/// <summary> /// 属性ごとの色を取得する /// </summary> /// <param name="element_type"></param> /// <returns></returns> public static Color GetElementLabelColor(MasterDataDefineLabel.ElementType element_type) { string hex = ""; switch (element_type) { case MasterDataDefineLabel.ElementType.NAUGHT: hex = "#c6c6c6"; break; case MasterDataDefineLabel.ElementType.FIRE: hex = "#ff372c"; break; case MasterDataDefineLabel.ElementType.WATER: hex = "#41b6ff"; break; case MasterDataDefineLabel.ElementType.LIGHT: hex = "#ffff00"; break; case MasterDataDefineLabel.ElementType.DARK: hex = "#b400ff"; break; case MasterDataDefineLabel.ElementType.WIND: hex = "#25b300"; break; case MasterDataDefineLabel.ElementType.HEAL: hex = "#ff8c00"; break; } if (hex.IsNullOrEmpty()) { return(Color.white); } return(HexColor.ToColor(hex)); }
public void SelectColor(int index) { hexGrid.clearHighlightedList(activeColor); if (index == 0) { activeColor = HexColor.RED; } else if (index == 1) { activeColor = HexColor.CYAN; } else if (index == 2) { activeColor = HexColor.WHITE; } else if (index == 3) { activeColor = HexColor.HEX; } }
public static ValueTask <FluidValue> ToHsl(FluidValue input, FilterArguments arguments, TemplateContext context) { var value = input.ToStringValue(); if (HexColor.TryParse(value, out HexColor hexColor)) { var hslColor = (HslColor)hexColor; return(new StringValue(hslColor.ToString())); } else if (RgbColor.TryParse(value, out RgbColor rgbColor)) { var hslColor = (HslColor)rgbColor; return(new StringValue(hslColor.ToString())); } else { return(NilValue.Empty); } }
public void clearHighlightedList(HexColor color) { foreach (HexCell c in selectedCells) { if (color == HexColor.RED) { c.RedHighlight(false); } else if (color == HexColor.CYAN) { c.CyanHighlight(false); } else if (color == HexColor.WHITE) { c.Highlight(false); } else { c.Hex(false); } } }
public void Get_Random_Color_From_Color_array() { // Set Color[] possibleColors = { Color.white, Color.green, Color.yellow, Color.gray, Color.blue }; // Act Color color = HexColor.GetRandomColor(); // Assert Assert.True( Array.Exists( possibleColors, possibleColor => possibleColor == color ) ); }
public static Color GetColor(this HexColor param) { switch (param) { case HexColor.Black: return(Color.black); case HexColor.Blue: return(Color.blue); case HexColor.Purple: return(Color.red); case HexColor.Yellow: return(Color.yellow); case HexColor.White: return(Color.white); default: return(Color.gray); } }
public void ChangeImage(HexColor color) { image.sprite = sprites[(int)color]; }
// Use this for initialization void Start() { BindingText = "TextBindingTest<color=#00ffffff>あいうえお</color>"; BindingTextColor = Color.cyan; BindingColor = HexColor.ToColor("#00ffff77"); }
public override Task <TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider services) { return(Task.FromResult(HexColor.TryParse(input, out var hc) ? TypeReaderResult.FromSuccess(hc) : TypeReaderResult.FromError(CommandError.ParseFailed, "input string didn't match hex color template"))); }
internal PixelRgb Tint(HexColor color) { this.B = PixelHelper.Clamp((this.B + (255 - this.B) * ((double)color.Pixel.B / 255))); this.R = PixelHelper.Clamp((this.R + (255 - this.R) * ((double)color.Pixel.R / 255))); this.G = PixelHelper.Clamp((this.G + (255 - this.G) * ((double)color.Pixel.G / 255))); return this; }
private int GetIndexOfColor(Color color) { var color2 = new HexColor(); if (color.Name.IndexOf("#") > -1) { color2.Red = Int32.Parse(color.Name.Substring(1, 2), NumberStyles.AllowHexSpecifier); color2.Green = Int32.Parse(color.Name.Substring(3, 2), NumberStyles.AllowHexSpecifier); color2.Blue = Int32.Parse(color.Name.Substring(5, 2), NumberStyles.AllowHexSpecifier); } else { color2.Red = color.R; color2.Green = color.G; color2.Blue = color.B; } var index = colors.IndexOf(color2); if (index > -1) { return (index + 1); } colors.Add(color2); return colors.Count; }