Color similarity/distance in RGBA color space

Finally, I’ve found it! After thorough testing and experimentation my conclusions are: The correct way is to calculate maximum possible difference between the two colors. Formulas with any kind of estimated average/typical difference had room for discontinuities. I was unable to find a working formula that calculates the distance without blending RGBA colors with some … Read more

Convert RGBA to HEX

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 … Read more

CSS: lighten an element on hover

It’s a long time ago but you can do something like this: .element { background-color: red; } .element:hover { box-shadow: inset 0 0 100px 100px rgba(255, 255, 255, 0.1); } You can change the 100px into a number you want. I took a large one to cover the whole element. It isn’t a very beautiful … Read more

Is it possible to change only the alpha of a rgba background colour on hover?

This is now possible with custom properties: .brown { –rgb: 118, 76, 41; } .green { –rgb: 51, 91, 11; } a { display: block; position: relative; } div { position: absolute; bottom: 0; background-color: rgba(var(–rgb), 0.8); } a:hover div { background-color: rgba(var(–rgb), 1); } To understand how this works, see How do I apply … Read more

Convert RGBA PNG to RGB with PIL

Here’s a version that’s much simpler – not sure how performant it is. Heavily based on some django snippet I found while building RGBA -> JPG + BG support for sorl thumbnails. from PIL import Image png = Image.open(object.logo.path) png.load() # required for png.split() background = Image.new(“RGB”, png.size, (255, 255, 255)) background.paste(png, mask=png.split()[3]) # 3 … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)