regex javascript to match both RGB and RGBA

It’s not so simple- an rgb is illegal with a fourth parameter. You also need to allow for percentage decimals as well as integer values for the rgb numbers. And spaces are allowed almost anywhere. function getRgbish(c){ var i= 0, itm, M= c.replace(/ +/g, ”).match(/(rgba?)|(\d+(\.\d+)?%?)|(\.\d+)/g); if(M && M.length> 3){ while(i<3){ itm= M[++i]; if(itm.indexOf(‘%’)!= -1){ itm= … 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

How can I stop the alpha-premultiplication with canvas imageData?

Bleh, this is an acknowledged issue as far as the canvas spec is concerned. It notes: Due to the lossy nature of converting to and from premultiplied alpha color values, pixels that have just been set using putImageData() might be returned to an equivalent getImageData() as different values. So this: var can = document.createElement(‘canvas’); var … Read more

CSS hexadecimal RGBA?

The CSS Color Module Level 4 will probably support 4 and 8-digit hexadecimal RGBA notation! Three weeks ago (18th of December 2014) the CSS Color Module Level 4 editor’s draft was submitted to the CSS W3C Working Group. Though in a state which is heavily susceptible to change, the current version of the document implies … 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)