List of ANSI color escape sequences

The ANSI escape sequences you’re looking for are the Select Graphic Rendition subset. All of these have the form \033[XXXm where XXX is a series of semicolon-separated parameters. To say, make text red, bold, and underlined (we’ll discuss many other options below) in C you might write: printf(“\033[31;1;4mHello\033[0m”); In C++ you’d use std::cout<<“\033[31;1;4mHello\033[0m”; In Python3 … Read more

Converting RGB to grayscale/intensity

The specific numbers in the question are from CCIR 601 (see Wikipedia article). If you convert RGB -> grayscale with slightly different numbers / different methods, you won’t see much difference at all on a normal computer screen under normal lighting conditions — try it. Here are some more links on color in general: Wikipedia … Read more

Color different parts of a RichTextBox string

Here is an extension method that overloads the AppendText method with a color parameter: public static class RichTextBoxExtensions { public static void AppendText(this RichTextBox box, string text, Color color) { box.SelectionStart = box.TextLength; box.SelectionLength = 0; box.SelectionColor = color; box.AppendText(text); box.SelectionColor = box.ForeColor; } } And this is how you would use it: var userid … Read more

How to set the text color of TextView in code?

You should use: holder.text.setTextColor(Color.RED); You can use various functions from the Color class to get the same effect of course. Color.parseColor (Manual) (like LEX uses) text.setTextColor(Color.parseColor(“#FFFFFF”)); Color.rgb and Color.argb (Manual rgb) (Manual argb) (like Ganapathy uses) holder.text.setTextColor(Color.rgb(200,0,0)); holder.text.setTextColor(Color.argb(0,200,0,0)); And of course, if you want to define your color in an XML file, you can do … Read more

HSL to RGB color conversion

Garry Tan posted a Javascript solution on his blog (which he attributes to a now defunct mjijackson.com, but is archived here and the original author has a gist – thanks to user2441511). The code is re-posted below: HSL to RGB: /** * Converts an HSL color value to RGB. Conversion formula * adapted from http://en.wikipedia.org/wiki/HSL_color_space. … Read more