protected override void OnPaint(ITerminal terminal) { base.OnPaint(terminal); int titleY = Items.Count - 1; terminal[0, titleY][TitleColor].Write(Title); terminal[Title.Length + 1, titleY][TermColor.Yellow].Write(Glyph.TriangleRight); int x = Title.Length + 3; for (int i = 0; i < Items.Count; i++) { ColorPair color = TextColor; if (i == Selected) { color = SelectionColor; } int y = Items.Count - 1 + i - Selected; terminal[x, y][color].Write(Items[i].Text); } }
public void Update(GameTime gameTime) { if (Done) { return; } var elasped = (float)gameTime.ElapsedGameTime.TotalSeconds; _frameTimer += elasped; fadeDelay -= elasped; if (fadeDelay <= 0 && alphaValue > 0) { fadeDelay = 0.035f; alphaValue -= fadeIncrement; var colr1 = Color.FromNonPremultiplied(ColorUsed.Color1.R, ColorUsed.Color1.G, ColorUsed.Color1.B, (byte)MathHelper.Clamp(alphaValue, 1, 255)); var colr2 = Color.FromNonPremultiplied(ColorUsed.Color2.R, ColorUsed.Color2.G, ColorUsed.Color2.B, (byte)MathHelper.Clamp(alphaValue, 1, 255)); ColorUsed = new ColorPair(colr1, colr2); } if (_frameTimer >= _frameTimerDuration) { Done = true; } for (var i = 0; i < BurstPositions.Length; i++) { BurstPositions[i] += directions[i] * _speed[i] * elasped; } }
public static Color GetClosestColor(LabColor lc) { //ColorPair select = (ColorPair)(Colors.OrderBy(x => DeltaE.Distance(x.LAB, lc)).ToList().First()); ColorPair select = Colors.MinBy(x => DeltaE.Distance(x.LAB, lc)); return(select.Color); }
public void SetColor(int index, Color foreColor, Color backColor) { if (index >= 0) { Colors[index] = new ColorPair(foreColor, backColor); } }
public void NormalPath() { var fg = ConsoleColor.Green; var bg = ConsoleColor.DarkGray; var colors = new ColorPair(_console, fg, bg); // ensure that initial color state is preserved Assert.IsTrue(colors.OriginalBackground == _console.BackgroundColor); Assert.IsTrue(colors.OriginalForeground == _console.ForegroundColor); Assert.IsTrue(colors.Foreground == fg); Assert.IsTrue(colors.Background == bg); // ensure that the colors are applied colors.ApplyColors(); Assert.IsTrue(_console.BackgroundColor == bg); Assert.IsTrue(_console.ForegroundColor == fg); // ensure that the colors are reset colors.ResetColors(); Assert.IsTrue(_console.BackgroundColor == origBG); Assert.IsTrue(_console.ForegroundColor == origFG); Assert.IsTrue(colors.Foreground == fg); Assert.IsTrue(colors.Background == bg); }
/// <summary> /// Draw a preview of the <see cref="ColorPair"/> /// </summary> /// <param name="e">The paint event args providing the <see cref="Graphics"/> and bounding /// rectangle</param> public override void PaintValue(PaintValueEventArgs e) { ColorPair colorPair = (ColorPair)e.Value; using (SolidBrush b = new SolidBrush(colorPair.Background)) { e.Graphics.FillRectangle(b, e.Bounds); } // Draw the text "ab" using the Foreground/Background values from the ColorPair using (SolidBrush b = new SolidBrush(colorPair.Foreground)) { using (Font f = new Font("Arial", 6)) { RectangleF temp = new RectangleF(e.Bounds.Left, e.Bounds.Top, e.Bounds.Height, e.Bounds.Width); temp.Inflate(-2, -2); // Set up how we want the text drawn StringFormat format = new StringFormat(StringFormatFlags.FitBlackBox | StringFormatFlags.NoWrap); format.Trimming = StringTrimming.EllipsisCharacter; format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; // save the Smoothing mode of the Graphics object so we can restore it SmoothingMode saveMode = e.Graphics.SmoothingMode; e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.DrawString("ab", f, b, temp, format); e.Graphics.SmoothingMode = saveMode; } } }
public void IsVisiblySimilarToTest() { ColorPair colorPair1 = new ColorPair(new Color(0, 0, 0), new Color(1, 1, 1)); ColorPair colorPair2 = new ColorPair(new Color(2, 2, 2), new Color(3, 3, 3)); Assert.IsTrue(colorPair1.IsVisiblySimilarTo(colorPair2)); }
public void test_setBackground_WithAValidHtmlColorCode() { ColorPair colorPair = new ColorPair(); colorPair.Background = "#ffffff"; Assert.Equal("#ffffff", colorPair.Background); }
public BurstEffect(ColorPair startColors, Vector2 originPos) { Init(); BurstPositions = new Vector2[MaxBursts]; _speed = new int[MaxBursts]; isColor1 = new bool[MaxBursts]; ColorUsed = startColors; for (var x = 0; x < 4; x++) { for (var y = 0; y < 4; y++) { BurstPositions[y * 4 + x] = new Vector2( (x * 2) + 22 + (int)originPos.X, (y * 2) + 22 + (int)originPos.Y); _speed[y * 4 + x] = MasterRandom.FRandom.Next(25, 45); isColor1[y * 4 + x] = MasterRandom.FRandom.NextBool(); } } _frameTimer = 0; }
private void StartGame() { InGame = true; correctAnswers = 0; gameStartTime = Time.time; CurrentPair = GetNextPair(); }
public void test_setForeground_WithAValidHtmlColorCode() { ColorPair colorPair = new ColorPair(); colorPair.Foreground = "#000000"; Assert.Equal("#000000", colorPair.Foreground); }
public void test_construction() { ColorPair colorPair = new ColorPair("#ffffff", "#000000"); Assert.Equal("#ffffff", colorPair.Background); Assert.Equal("#000000", colorPair.Foreground); }
public ColorPair GetColor(string groupName, ConsoleColor?foreGround, ConsoleColor?backGround) { RefreshColors(); ColorPair result = new ColorPair(); var group = string.IsNullOrWhiteSpace(groupName) ? _defaultGroupName : groupName; if (!_definedColors.ContainsKey(group)) { group = _defaultGroupName; } result = _definedColors[group]; if (foreGround.HasValue) { result.Foreground = foreGround.Value; } if (backGround.HasValue) { result.Background = backGround.Value; } return(result); }
protected override void OnPaint(ITerminal terminal) { base.OnPaint(terminal); int x = 0; // draw the title if (!String.IsNullOrEmpty(Title)) { terminal[0, 0][TitleColor].Write(Title); terminal[Title.Length + 1, 0][TermColor.Yellow].Write(Glyph.TriangleRight); x += Title.Length + 3; } // draw the options for (int i = 0; i < Items.Count; i++) { ColorPair shortcutColor = TitleColor; ColorPair color = TextColor; if (i == mSelected) { shortcutColor = SelectionColor; color = SelectionColor; } terminal[x, i][shortcutColor].Write(Items[i].Shortcut + " "); terminal[x + 2, i][color].Write(Items[i].Text); } }
public BoardCell(int x, int y) { Bounds = new Rectangle(x * 64, y * 64, 64, 64); CellColors = new ColorPair(Color.White, Color.White); CurrentNumber = 0; CurrentID = 0; Age = 0; Timer = 0; PlantType = FlowerTypes.Undefined; SourceReference = new Point(1216, 1696); currentScale = BeginScaling; Ready = false; Mate = new Point(16, 16); MateType = MateTypes.None; DrawLayer = normalDrawLayer; MainAge = 0; Blocked = false; Rotation = startRotation; }
public static void ReplaceColor(GradientStop in_Stop, IEnumerable <ColorPair> in_Colors) { if ((in_Stop == null) || (in_Colors == null)) { return; } if (in_Colors.Count( ) == 0) { return; } double R = Convert.ToDouble(in_Stop.Color.R / 255.0); double G = Convert.ToDouble(in_Stop.Color.G / 255.0); double B = Convert.ToDouble(in_Stop.Color.B / 255.0); double A = Convert.ToDouble(in_Stop.Color.A / 255.0); ColorPair pair = in_Colors.FirstOrDefault(x => (R == x.OldColor.R) && (G == x.OldColor.G) && (B == x.OldColor.B) && (A == x.OldColor.A)); if (pair != null) { in_Stop.Color = new System.Windows.Media.Color( ) { R = Convert.ToByte(pair.NewColor.R * 255), G = Convert.ToByte(pair.NewColor.G * 255), B = Convert.ToByte(pair.NewColor.B * 255), A = Convert.ToByte(pair.NewColor.A * 255) } } ; }
public void SetData(Vector2 origin, ColorPair thisColor) { var mainAngle = MasterRandom.FRandom.Next(180, 300); var spreadMin = mainAngle - 15; var spreadMax = mainAngle + 15; var tempAngle = 0f; for (var i = 0; i < SprayBitsPositions.Length; i++) { SprayBitsPositions[i] = origin; speed[i] = MasterRandom.FRandom.Next(25, 55); tempAngle = MathHelper.ToRadians(MasterRandom.FRandom.Next(spreadMin, spreadMax + 1)); direction[i] = new Vector2((float)Math.Cos(tempAngle), (float)Math.Sin(tempAngle)); direction[i].Normalize(); if (MasterRandom.FRandom.NextBool()) { SprayColor[i] = thisColor.Color1; } else { SprayColor[i] = thisColor.Color2; } IsBigger[i] = MasterRandom.FRandom.NextBool(); } Active = true; }
public MarkupPattern(string name, Style style, bool highlightAttributes, ColorPair bracketColors, ColorPair attributeNameColors, ColorPair attributeValueColors) : base(name, style) { HighlightAttributes = highlightAttributes; BracketColors = bracketColors; AttributeNameColors = attributeNameColors; AttributeValueColors = attributeValueColors; }
/// <summary> /// Construct a <see cref="ColorPair"/> from the properties in a <see cref="IDictionary"/> /// </summary> /// <param name="context">designer context</param> /// <param name="propertyValues">The "serialized" values for the <see cref="ColorPair"/></param> /// <returns> /// A <see cref="ColorPair"/> /// </returns> public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) { ColorPair colorPair = new ColorPair(); colorPair.Foreground = (System.Drawing.Color)propertyValues["Foreground"]; colorPair.Background = (System.Drawing.Color)propertyValues["Background"]; return((object)colorPair); }
/// <summary> /// Initialize new default instance. /// </summary> public AppearanceBar() { backStyle = new ColorPair(); backStyle.AppearanceChanged += OnAppearanceChanged; appearanceBorder = new AppearanceBorder(); appearanceBorder.AppearanceChanged += OnAppearanceChanged; Reset(); }
internal static RectangleF PaintGradientRectangle(Graphics g, int aPointX, int aPointY, int aWidth, int aHeight, ColorPair pair) { var ef2 = XRectangleF(aPointX, aPointY, aWidth, aHeight); var brush1 = new LinearGradientBrush(ef2, pair.BackColor1, pair.BackColor2, pair.Gradient); g.FillRectangle(brush1, ef2); return(ef2); }
public void TestShared() { Assert.AreEqual(ColorSet.Shared.Colors.Count, 2); Assert.IsTrue(ColorSet.Shared["NoVariant"] != null); Assert.IsTrue(ColorSet.Shared["Variant"] != null); ColorPair p1 = ColorSet.Shared["NoVariant"]; ColorPair p2 = ColorSet.Shared["Variant"]; { if (p1.Color is SolidColorBrush c) { Assert.AreEqual(c.Color.R, 50); Assert.AreEqual(c.Color.G, 100); Assert.AreEqual(c.Color.B, 150); Assert.AreEqual(c.Color.A, 128); } else { Assert.Fail("Color is not defined"); } } if (p1.Variant != null) { Assert.Fail("No variant should be defined"); } { if (p2.Color is SolidColorBrush c) { Assert.AreEqual(c.Color.R, 250); Assert.AreEqual(c.Color.G, 200); Assert.AreEqual(c.Color.B, 150); Assert.AreEqual(c.Color.A, 191); } else { Assert.Fail("Color is not defined"); } } { if (p2.Variant is SolidColorBrush c) { Assert.AreEqual(c.Color.R, 200); Assert.AreEqual(c.Color.G, 150); Assert.AreEqual(c.Color.B, 250); Assert.AreEqual(c.Color.A, 64); } else { Assert.Fail("Color is not defined"); } } }
public void VisualStudioTab() { ColorPair approximateColorPair = new ColorPair(new CCColor(9, 126, 206), new CCColor(37, 37, 38)); var colorContrastResult = LoadFromResources("visual_studio_tab.bmp").RunColorContrastCalculation(); Assert.AreEqual(Confidence.Mid, colorContrastResult.ConfidenceValue()); Assert.AreEqual(approximateColorPair, colorContrastResult.MostLikelyColorPair); }
public TextAreaEnclosure(string left, string right, ColorPair colors = new ColorPair()) { if (left.Length != right.Length) { throw new ArgumentException("Left and Right must be same length"); } Left = left; Right = right; Colors = colors; }
public void SetColorCapacity(int numColors) { int colorCount = (colors == null) ? 0 : colors.Length; ColorPair[] newColors = new ColorPair[Items.Count]; for (int index = 0; index < Items.Count; index++) { newColors[index] = (index < colorCount) ? colors[index] : defaultColorPair; } colors = newColors; }
/// <summary> /// Adds the spray effect to pointer when a flower is touched /// </summary> /// <param name="pos">effects start position</param> /// <param name="colors">colors used in effect</param> public void ActivateSpray(Vector2 pos, ColorPair colors) { for (var i = 0; i < activeSprays.Count; i++) { if (!activeSprays[i].Active) { activeSprays[i].SetData(pos, colors); break; } } }
internal static string GetColorCoding() { string color_mapping = ""; for (int i = 0; i < ColorMap.NumberofMajorColors * ColorMap.NumberofMinorColors; i++) { ColorPair colorPair = ColorMap.GetColorFromPairNumber(i + 1); color_mapping = color_mapping + "\n" + (i + 1) + " : " + colorPair.ToString(); } return(color_mapping); }
public void WriteHeader(string msg, ConsoleColor?foregroundColor = null, ConsoleColor?backgroundColor = null, ConsoleTextPosition position = ConsoleTextPosition.Left) { var color = new ColorPair(_console, foregroundColor, backgroundColor); _console.CursorLeft = 0; //pos; _console.CursorTop = _originalState.WindowTop; var line = BuildLine(msg, position); this.Write(line, color); _originalState.ResetCursor(); }
public void WeirdTextArrangement() { var image = LoadFromResources("weird_text_arrangement.bmp"); ColorPair approximateColorPair = new ColorPair(new CCColor(177, 199, 188), new CCColor(30, 30, 30)); ColorContrastResult result = image.RunColorContrastCalculation(); Assert.AreEqual(approximateColorPair, result.MostLikelyColorPair); Assert.AreEqual(Confidence.High, result.ConfidenceValue()); }
} // end _PushSgr() private void _PopSgr(List <int> args) { if ((args != null) && (args.Count != 0)) { throw new InvalidOperationException("The XTPOPSGR command does not accept arguments."); } ColorPair cp = m_colorStack.Pop(); Console.ForegroundColor = cp.Foreground; Console.BackgroundColor = cp.Background; } // end _PopSgr()
/// <summary> /// Initialize new instance of <see cref="AppearanceItem"/>. /// </summary> public AppearanceItem() { backStyle = new ColorPair(); backStyle.AppearanceChanged += OnAppearanceChanged; clickStyle = new ColorPair(); clickStyle.AppearanceChanged += OnAppearanceChanged; hoverStyle = new ColorPair(); hoverStyle.AppearanceChanged += OnAppearanceChanged; selectedHoverStyle = new ColorPair(); selectedHoverStyle.AppearanceChanged += OnAppearanceChanged; selectedStyle = new ColorPair(); selectedStyle.AppearanceChanged += OnAppearanceChanged; disabledStyle = new ColorPair(); disabledStyle.AppearanceChanged += OnAppearanceChanged; appearenceText = new AppearenceText(); appearenceText.AppearenceChanged += OnAppearanceChanged; Reset(); }
private static void ColorizeEscapeSequences( TextWriter output, string message, ColorPair startingColor, ColorPair defaultColor) { var colorStack = new Stack<ColorPair>(); colorStack.Push(startingColor); int p0 = 0; while (p0 < message.Length) { int p1 = p0; while (p1 < message.Length && message[p1] >= 32) { p1++; } // text if (p1 != p0) { output.Write(message.Substring(p0, p1 - p0)); } if (p1 >= message.Length) { p0 = p1; break; } // control characters char c1 = message[p1]; char c2 = (char)0; if (p1 + 1 < message.Length) { c2 = message[p1 + 1]; } if (c1 == '\a' && c2 == '\a') { output.Write('\a'); p0 = p1 + 2; continue; } if (c1 == '\r' || c1 == '\n') { Console.ForegroundColor = defaultColor.ForegroundColor; Console.BackgroundColor = defaultColor.BackgroundColor; output.Write(c1); Console.ForegroundColor = colorStack.Peek().ForegroundColor; Console.BackgroundColor = colorStack.Peek().BackgroundColor; p0 = p1 + 1; continue; } if (c1 == '\a') { if (c2 == 'X') { colorStack.Pop(); Console.ForegroundColor = colorStack.Peek().ForegroundColor; Console.BackgroundColor = colorStack.Peek().BackgroundColor; p0 = p1 + 2; continue; } var foreground = (ConsoleOutputColor)(c2 - 'A'); var background = (ConsoleOutputColor)(message[p1 + 2] - 'A'); if (foreground != ConsoleOutputColor.NoChange) { Console.ForegroundColor = (ConsoleColor)foreground; } if (background != ConsoleOutputColor.NoChange) { Console.BackgroundColor = (ConsoleColor)background; } colorStack.Push(new ColorPair(Console.ForegroundColor, Console.BackgroundColor)); p0 = p1 + 3; continue; } output.Write(c1); p0 = p1 + 1; } if (p0 < message.Length) { output.Write(message.Substring(p0)); } }
internal static RectangleF PaintGradientRectangle(Graphics g, RectangleF rect, ColorPair pair) { var brush1 = new LinearGradientBrush(rect, pair.BackColor1, pair.BackColor2, pair.Gradient); g.FillRectangle(brush1, rect); return rect; }
internal static RectangleF PaintGradientRectangle(Graphics g, int aPointX, int aPointY, int aWidth, int aHeight, ColorPair pair) { var ef2 = XRectangleF(aPointX, aPointY, aWidth, aHeight); var brush1 = new LinearGradientBrush(ef2, pair.BackColor1, pair.BackColor2, pair.Gradient); g.FillRectangle(brush1, ef2); return ef2; }
protected virtual void ResetHeaderPair() { this.headerPair = new ColorPair(); }
private IEnumerable<KeyValuePair<ColorPair, CardColor>> GenerateTrainPairs() { CsvWriter writer = new CsvWriter(@"D:\Development\OpenCV\SetVision\SetVision\bin\Debug\colordebug\generated.csv"); DirectoryInfo colordebug = new DirectoryInfo(@"D:\Development\OpenCV\SetVision\SetVision\bin\Debug\colordebug"); DirectoryInfo traindir = colordebug.GetDirectories("Pass 9")[0]; foreach (DirectoryInfo colordir in traindir.GetDirectories()) { CardColor color = CardColor.Other; string colname = colordir.Name.ToLower(); if (colname.Contains("purple")) { color = CardColor.Purple; } else if (colname.Contains("green")) { color = CardColor.Green; } else if (colname.Contains("red")) { color = CardColor.Red; } else if (colname.Contains("white")) { color = CardColor.White; } foreach (FileInfo file in colordir.GetFiles()) { Bgr bgr; Hsv hsv; fileNameToColors(file.Name, out bgr, out hsv); if (!bgr.Equals(new Bgr()) && !hsv.Equals(new Hsv())) { ColorPair colors = new ColorPair(bgr, hsv); writer.Write((int)bgr.Blue, (int)bgr.Green, (int)bgr.Red); yield return new KeyValuePair<ColorPair, CardColor>(colors, color); } } } writer.Close(); }
public void ResetPair() { this.pair = new ColorPair(); }
protected virtual bool ShouldSerializeLeftPair() { ColorPair pa = new ColorPair(Color.Orange, Color.White, 270); return leftPair != pa; }
private void ResetLeftPair() { leftPair = new ColorPair(Color.Orange, Color.White, 270); }