October 11, 2016 Re: color lib | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrea Fontana | On 11 October 2016 at 18:10, Andrea Fontana via Digitalmars-d <digitalmars-d@puremagic.com> wrote: > On Monday, 10 October 2016 at 23:26:53 UTC, Manu wrote: >> >> I'm not sure why it matters what format the colour you have is... >> Strings are in the form #RRGGBB, or #AARRGGBB. That is all. >> It's the standard I've seen used everywhere ever, including the web, >> which is a pretty good precedent :P > > > If the web is a good precedent (CSS4 specs): > "The first 6 digits are interpreted identically to the 6-digit notation. The > last pair of digits, interpreted as a hexadecimal number, specifies the > alpha channel of the color, where 00 represents a fully transparent color > and ff represent a fully opaque color." > > https://drafts.csswg.org/css-color/#hex-notation > > CSS3 doesn't support hex string with alpha but they suggest you to use > rgba() function. I think argb() doesn't exists instead. > https://www.w3.org/TR/2011/REC-css3-color-20110607/#rgba-color > > Chrome 52 supports it: https://googlechrome.github.io/samples/css-alpha-channel/ > > Android instead: > https://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String) > "Parse the color string, and return the corresponding color-int. If the > string cannot be parsed, throws an IllegalArgumentException exception. > Supported formats are: #RRGGBB #AARRGGBB [...]" > > Please notice that on PNG file format rgba is quite common (also on bmp with > semi-official apha support) > PNG: http://www.libpng.org/pub/png/book/chapter08.html Oh dear... thanks for digging that up. I didn't know the web had a standard for alpha. Certainly 0xAARRGGBB has been used in windows code for as long as I've been programming... but now there's a competing #RRGGBBAA version... How to resolve this? I guess, go with the web? I should probably change it to the CSS4 way. |
October 11, 2016 Re: color lib | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On Tuesday, 11 October 2016 at 12:14:37 UTC, Manu wrote: > Oh dear... thanks for digging that up. > I didn't know the web had a standard for alpha. Certainly 0xAARRGGBB > has been used in windows code for as long as I've been programming... > but now there's a competing #RRGGBBAA version... > How to resolve this? I guess, go with the web? I should probably > change it to the CSS4 way. My idea is still to use a template: colorFromString!"rgba" or colorFromString!"argb" (please notice that AFAIK, the second most used way is actually "abgr" rather than "argb" - because of byte-order) And I think it's a good idea to set template argument to some default. MS is not sure about this, anyway. Read carefully this: https://msdn.microsoft.com/en-us/library/windows/desktop/ms534427(v=vs.85).aspx VS: https://msdn.microsoft.com/en-us/library/ee505694(v=winembedded.60).aspx VS: https://msdn.microsoft.com/it-it/library/windows/desktop/dd183449(v=vs.85).aspx OpenGL use rgba (and abgr?) directX argb: https://www.opengl.org/wiki/Image_Format https://www.opengl.org/wiki/Direct3D_Compatibility Andrea |
Copyright © 1999-2021 by the D Language Foundation