Posts

Showing posts with the label Colors

Algorithm To Randomly Generate An Aesthetically-pleasing Color Palette

Image
Answer : You could average the RGB values of random colors with those of a constant color: (example in Java) public Color generateRandomColor(Color mix) { Random random = new Random(); int red = random.nextInt(256); int green = random.nextInt(256); int blue = random.nextInt(256); // mix the color if (mix != null) { red = (red + mix.getRed()) / 2; green = (green + mix.getGreen()) / 2; blue = (blue + mix.getBlue()) / 2; } Color color = new Color(red, green, blue); return color; } Mixing random colors with white (255, 255, 255) creates neutral pastels by increasing the lightness while keeping the hue of the original color. These randomly generated pastels usually go well together, especially in large numbers. Here are some pastel colors generated using the above method: You could also mix the random color with a constant pastel, which results in a tinted set of neutral colors. For example, using a light blue cr...

Can We Use More Colors In Batch Script?

Image
Answer : Can I use more the 16 colours in a Windows batch file? No, as most most Windows apps only support 16 colours. However, in the Windows 10 Insiders Build #14931 the Windows Console was updated to support 24-bit RGB true color. Unfortunately as mentioned above most Windows apps cannot make use of this enhancement (yet). However, using Windows Subsystem for Linux (WSL), Linux scripts and tools can use the Console's new 24-bit color support: One of the most frequent requests we receive is to increase the number of colors that the Windows Console can support. We love nothing more than to deliver features you ask for! But rather than just add a few more colors, or limit our console to a mere 256 colors, in Windows 10 Insiders Build #14931, we’ve updated the Windows Console to support full, glorious 24-bit RGB true color! This is actually a little tricky to demo since most Windows apps only support 16 colors at most whereas the Linux world has broadly supported 256 col...

An Application To Easily Pick A Color In Mac OS X And Get The Hex Value

Image
Answer : OS X comes with DigitalColor Meter: Applications > Utilities > DigitalColor Meter.app It has many options and preferences. command+shift+c will copy the color under the cursor to the clipboard in many different formats. The Mac OS X color picker is extensible. Use Hex Color Picker to add a tab that provides you the configured color in hexadecimal RGB. Just run e.g. TextEdit and press Cmd-Shift-C to open the color picker, or run your standalone program. An even more versatile color picker is Developer Color Picker with many different output formats, one of which is hexadecimal. This is easily done with AppleScript. A complete working example of code is available here.

Convert Hex Color To RGB Values In PHP

Answer : If you want to convert hex to rgb you can use sscanf: <?php $hex = "#ff9900"; list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x"); echo "$hex -> $r $g $b"; ?> Output: #ff9900 -> 255 153 0 Check out PHP's hexdec() and dechex() functions: http://php.net/manual/en/function.hexdec.php Example: $value = hexdec('ff'); // $value = 255 I made a function which also returns alpha if alpha is provided as a second parameter the code is below. The function function hexToRgb($hex, $alpha = false) { $hex = str_replace('#', '', $hex); $length = strlen($hex); $rgb['r'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0)); $rgb['g'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0)); $rgb['b'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1)...

Convert RGBA To HEX

Answer : Since alpha value both attenuates the background color and the color value, something like this could do the trick: function rgba2rgb(RGB_background, RGBA_color) { var alpha = RGBA_color.a; return new Color( (1 - alpha) * RGB_background.r + alpha * RGBA_color.r, (1 - alpha) * RGB_background.g + alpha * RGBA_color.g, (1 - alpha) * RGB_background.b + alpha * RGBA_color.b ); } (Try it interactively: https://marcodiiga.github.io/rgba-to-rgb-conversion)

Convert Hex Color Value ( #ffffff ) To Integer Value

Answer : The real answer is to use: Color.parseColor(myPassedColor) in Android, myPassedColor being the hex value like #000 or #000000 or #00000000 . However, this function does not support shorthand hex values such as #000 . Answer is really simple guys, in android if you want to convert hex color in to int, just use android Color class, example shown as below this is for light gray color Color.parseColor("#a8a8a8"); Thats it and you will get your result. Integer.parseInt(myString.replaceFirst("#", ""), 16)

Advantages Of "Premier Color" On A Dell 4k Monitor

Answer : What Dell calls "Premier Color" and HP calls "Dreamcolor" is marketing-speak for 10-bits per channel color. They are also pre-calibrated with a selection of color profiles for professional work in (especially) video and television, also applicable to photography and graphic design, which you can find in their specs. You can use the full capabilities of a 10-bit monitor only if you have an OS that supports it and have a professional-grade GPU that will output 10-bit color. There is a good answer here with more details on that topic. Unless you are doing truly color-critical work, the extra color depth and color presets may not be worth the extra cost, but it's worth noting that they can display sRGB, Adobe RGB (almost!), and several television standards, which are not achievable with the usual 8-bit/channel displays. The details are, frankly, highly technical and tl;dr for most purposes. If you Google "10 bit displays" you'll find a...

Can A Printer Print White Color?

Answer : You will not get anything on the paper with a basic CMYK inkjet or laser printer. The CMYK color mixing is subtractive , meaning that it requires the base that is being colored to have all colors (i.e., White ) So that it can create color variation through subtraction: White - Cyan - Yellow = Green White - Yellow - Magenta = Red White - Cyan - Magenta = Blue White is represented as 0 cyan, 0 yellow, 0 magenta, and 0 black - effectively, 0 ink for a printer that simply has those four cartridges. This works great when you have white media, as "printing no ink" simply leaves the white exposed, but as you can imagine, this doesn't work for non-white media. If you don't have a base color to subtract from (i.e., Black ), then it doesn't matter what you subtract from it, you still have the color Black. As others are pointing out, there are special printers which can operate in the CMYW color space, or otherwise have a white ink or toner. These can ...