/// <summary> /// Creates a <see cref="SadConsole.ColoredString"/> object using the current gradient. /// </summary> /// <param name="text">The text to use for the colored string.</param> /// <returns>A new colored string object.</returns> public SadConsole.ColoredString ToColoredString(string text) { SadConsole.ColoredString stringObject = new SadConsole.ColoredString(text); if (Stops.Length == 0) { throw new System.IndexOutOfRangeException("The ColorGradient object does not have any gradient stops defined."); } else if (Stops.Length == 1) { stringObject.SetForeground(Stops[0].Color); return(stringObject); } float lerp = 1f / (text.Length - 1); float lerpTotal = 0f; stringObject[0].Foreground = Stops[0].Color; stringObject[text.Length - 1].Foreground = Stops[Stops.Length - 1].Color; for (int i = 1; i < text.Length - 1; i++) { lerpTotal += lerp; int counter; for (counter = 0; counter < Stops.Length && Stops[counter].Stop < lerpTotal; counter++) { ; } counter--; counter = (int)MathHelper.Clamp(counter, 0, Stops.Length - 2); float newLerp = (Stops[counter].Stop - (float)lerpTotal) / (Stops[counter].Stop - Stops[counter + 1].Stop); stringObject[i].Foreground = Color.Lerp(Stops[counter].Color, Stops[counter + 1].Color, newLerp); } return(stringObject); }
public static SadConsole.ColoredString AttributeString(int value1, int value2, string attribute) { if (value1 == 0 && value2 == 0) { return(null); } else { // currently draws everything as a positive value var pVal = Constants.Theme.PositiveAttributeColor; var cBg = Constants.Theme.BackgroundColor; var cFg = Constants.Theme.ForegroundColor; var val1 = new SadConsole.ColoredString(value1.ToString(), pVal, cBg); var val2 = new SadConsole.ColoredString(value2.ToString(), pVal, cBg); var att = new SadConsole.ColoredString(attribute, cFg, cBg); var separator = new SadConsole.ColoredString(" - ", cFg, cBg); var str = new SadConsole.ColoredString("+ ", cFg, cBg); return(str + val1 + separator + val2 + " " + att); } }
private static void RefreshBackingPanel() { topBarPane.Clear(); var text = new SadConsole.ColoredString(" X: ", Settings.Appearance_Text) + new SadConsole.ColoredString(topBarMousePosition.X.ToString(), Settings.Appearance_TextValue) + new SadConsole.ColoredString(" Y: ", Settings.Appearance_Text) + new SadConsole.ColoredString(topBarMousePosition.Y.ToString(), Settings.Appearance_TextValue) + new SadConsole.ColoredString(" Layer: ", Settings.Appearance_Text) + new SadConsole.ColoredString(topBarLayerName, Settings.Appearance_TextValue) + new SadConsole.ColoredString(" Tool: ", Settings.Appearance_Text) + new SadConsole.ColoredString(topBarToolName, Settings.Appearance_TextValue); topBarPane.Print(0, 0, text); }
public ButtonIndex(Keys key, Color keyColor, Color nameColor, int x = 0, int y = 0, bool isNumeric = false) : base(x, y, key, keyColor, nameColor, isNumeric) { KeyString = FormatKeyDisplay(); }
public static void DrawRectangleTitled(this SadConsole.Console console, int x, int y, int width, int height, string cornerGlyph, string horizontalGlyph, string verticalGlyph, string separatorCornerGlyph, SadConsole.ColoredString title, bool centeredTitle) { int _x; int _y; // top for (_x = x + 1; _x < (x + width) - 1; _x++) { console.Print(_x, y, horizontalGlyph); } // draw top corners console.Print(x, y, cornerGlyph); console.Print(x + width - 1, y, cornerGlyph); // bottom for (_x = x + 1; _x < (x + width) - 1; _x++) { console.Print(_x, height + y, horizontalGlyph); } // draw bottom corners console.Print(x, height + y, cornerGlyph); console.Print(x + width - 1, height + y, cornerGlyph); // left for (_y = y + 1; _y < (y + height); _y++) { console.Print(x, _y, verticalGlyph); } // right for (_y = y + 1; _y < (y + height); _y++) { console.Print(x + width - 1, _y, verticalGlyph); } // draw title separator. simply draws on top of already drawn glyphs for (_x = x + 1; _x < (x + width) - 1; _x++) { console.Print(_x, y + 2, horizontalGlyph); } // draw separator corners console.Print(x, y + 2, separatorCornerGlyph); console.Print(x + width - 1, y + 2, separatorCornerGlyph); // draw the box title if (centeredTitle) { console.Print((width / 2) - (title.String.Length / 2), y + 1, title); } else { console.Print(2, y + 1, title); } }