Libgdx Fill in Color of Image start from the center like an animation - colors

I would like to preform a color fill in from the center of the image in Libgdx. I know I have to use 2 different texture to perform the color change with setColor on the current image to the next image color, but how can I fill in the color starting from the center of the image just like performing an animation?

Related

Algorithm for resize multi selected elements on the canvas

I have shapes with integer coordinates of width and height. They can be selected and stretched separately, I want to add the function of stretching a group of selected shapes. For example, as in the Figma editor or in VS Studio on a visual canvas, when we select a set of shapes and stretch them and they stretch proportionally with integer coordinates of width and height. Can you tell me how it works? For example, I have a list of 5 shapes with a width and height of 10px, indents from each other in 1px, I have selected them and pull them along the X axis in the positive direction by 8 pixels, which algorithm do I need to use? Here is an example of how it looks in VS when stretching buttons on the canvas.
https://i.stack.imgur.com/mYOAf.gif

SVG Filter Grayscale to Alpha

I have an rgb image with various colors and grayish parts (white - grey - black).
Now I would like to transform the grayish pixels to transparent / alpha, whilst keeping the colored pixels as they are.
As of now I am rendering the image on a canvas and then iterate over the pixels. If the channels R, G, B are close for a pixel it turn the pixels alpha to 0.
Is there a way of doing this via svg filters?
https://www.w3.org/TR/SVG11/filters.html

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.

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

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).

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