Tinting Drawn Textures with the Color property in XNA / Monogame, how to balance? - colors

I have these four icons that look like this:
But I want to be able to just have 1 gray icon and then tint them different colors by setting the color in XNA / Monogames Draw function.
I took one of the images and pulled all the colour out and made it a bit lighter it to get
I also tried a version where the center of the gray image is fully white but neither look right in the game, here's an image with the icons on top and my tinted gray on the bottom (the tint color is sampled from the center of the original icons):
I figure there should be a way, given the original icons, to figure out how to make the gray icon and also the colors to plug into the draw function so that I get an exact copy of the original. I assume this is possible? How do you do it?
EDIT:
To elaborate on my issue here is another image all with blue icons, the top images are all the original blue icon for comparison. The bottom images are all grey icons I used to tint to make the middle icons. The grey icons are, from left to right, 0 saturation, 0 saturation and 100 brightness, and auto level + 0 saturation. It seems to me that by setting the saturation to 0 I am losing the ability to make the icon look right as it's not just "darker" blue but also "bluer" blue.
EDIT 2: I don't think it's possible, thanks for the help Goose.

Would it work if the grey icon was full white at the center (it's brightest point) and got darker from there.
Then you could just sample the color at the center of your source image (the colored ones) and tint with that.
I think the issue you are seeing now is that the grey image will darken the color you are tinting with, so you actually want to tint with the source color PLUS the amount of grey at the brightest point in the image (if that makes sense).

Related

Create an image or photo that can change colour in Tkinter

I need to display an outline of a dog in a window. I then need to be able to change the colour for different part of the dog by inputting numbers into entry boxes- for example if I put a '1' in the 'head' entry box, the head changes to a yellow colour. The dog should be white by default.
I can just create 4 images (one for the head, body, legs, and tale) to change each part of the bod. I've thought about changing the rgb values of each image to change the colour, but this would also change the colour for the outline (meant to stay black). The only other thing I could think of was making a red, blue, green, yellow, blue, etc. version of each image (head, body, legs, tail), and then just displaying the red version of the image when I need to (and the same for other colours).
I need to know if there is any other way to do this (perhaps with the canvas widget?) before I code it because It will take a long time to change the colour of each image. I just have no idea where to start.
Thanks in advance for your answers
You will have to make different widgets for each part of the dog(e.g: Head, Abdomen etc.) and you will need different images for the dogs part and color, after that you can implement a button that changes the color with the 'if' function.

How to implement a color contrast enriching algorithm? [duplicate]

This question already has answers here:
Determine font color based on background color
(22 answers)
Closed 2 years ago.
I am currently developing an App. In this App I get some RGB color code from the server, that I want to display.
As the color I get should be the background color of a Label, there is some text, that should be displayed above it. The user defining the color is completely free in choosing a color, so I am in need of finding an algorithm, where the text color of the label is somehow contrasted to the color I get from the webservice.
Problem explained in an example:
I choose black 0x000000 to be the textcolor. If the user defines a color like dark gray 0x111111, the text's visibility would be very bad.
In addition, I want the text color to be black or white in order to not over-color the app.
So how can I determine, if white or black is the better color for the textcolor, based on a RGB code I get from the server?
You just should calculate contrast ratio for user color with black and white, then choose the color with higher ratio.
Here is description for calculating relative color contrast from RGB.
Note that relative luminance of white is 1.0 and for black is 0.0, so (if you are considering only black and white) you can just check if relative luminance of user color is <0.5 then use white, and use black otherwise.

Batch replace colour images, except a specific colour on Linux

I have 456 .PNG icons with a white image on a blue background, but the background is pixelated. So when I use mogrify to replace a colour, lots of parts of the icon won't become the red colour I want, and stay in a shade of blue. Is there a way to replace all colours, all shades of blue, and keep the white icon intact? Because mogrify recolouring the icons would turn the whole icon red, even the white part.
I have a feeling the solution should be simple, but after some googling and some messing around with Imagemagick and Phatch, I can't seem to figure it out.
I kind of need a batch solution, since theming all the icons manually would be... Something I don't want to do.
I am open for any suggestions and I apologizs in advance if this question turns out to be a duplicate!
If you need more information, just ask, and I can give it to you!
The "+opaque color" option will select all colors except the named one, and turn them to the fill color. Thus,
mogrify -fill red +opaque white *.png
will turn everything except the white pixels to red.

Extend two colors bars across full width of browser?

I have two boxes filled with colors, a green one on the left, and gray one on the right. They go right up against each other in the middle of the screen, and I would like each one to extend the width of the browser, so the green one extends all the way to the left, and the gray one extends all the way to the right, no matter how wide the browser gets. How can I do this?
the width property supports percentage values, which are relative to the size of the window it exists in.
See:
http://learnlayout.com/percent.html
http://www.w3schools.com/cssref/pr_dim_width.asp

Convert a black & white image to white & transparent

I have a black and white System.Drawing.Bitmap being passed from a 3rd party SDK, that I want to convert from black on white to white on transparent... i.e. make all the black pixels white, and all the white pixels transparent.
Do I have to iterate over every pixel, check the color and change it accordingly? How do I go about this?
If it's a paletted image (as it should be, given that it's a BW image) you could replace black with transparent inside the palette of the bitmap (Palette property of Bitmap, edit its Entries property).

Resources