It is possible to use semi-transparent colors, also known as alpha channel colors, in page layouts. These work in all modern browsers: Chrome, Edge, Firefox, and Safari, along with their mobile cousins.
These are not simply pale versions of the regular colors; they will, in fact, allow background colors or images to "shine through." Therefore, a semi-transparent red on a blue background will appear purple.
Skins must be modified to make use of semi-transparent colors. If a skin has not been so modified, and you specify a semi-transparent color in the user interface, the skin will ignore your choice, and use the corresponding opaque color, instead.
If a skin has been modified to allow the selection of semi-transparent colors, the user interface will look something like this:
The text field shows the hex value of the color. The traditional hex value for red, for example, is #ff0000. The alpha channel hex field has eight characters, rather than six. The format in jAlbum is #AARRGGBB, where the first two characters indicate the degree of transparency, with 00 being completely transparent (invisible) and ff being completely opaque. A value of 3f would be 75% transparent, a value of 7f would be 50% transparent, and a value of bf would be 25% transparent. So, a hex value of #7fff0000 would be a 50% transparent red.
The color swatch has been programmed to show a checkboard pattern if you have selected a semi-transparent color, and a solid color if you have selected an opaque color.
There are several other ways to specify a semi-transparent color. If you click on the color swatch and then choose the HSV or HSL tab, there is a Transparency slider with percentage values. Moving the slider to the right makes the color more transparent.
On the RGB and CMYK tabs, there is an Alpha slider with alpha channel values. This operates in the opposite sense; moving it to the left makes the color more transparent.
Oddly, the Color Code field on the RGB tab does not show the full eight-digit color code with the alpha channel value in it.
You can use any of these sliders to adjust the transparency of the color you've chosen.
Edited by: jGromit on 05-Feb-2020 17:54 - update long overdue
Re: Semi-transparent colors
in response to: JeffTucker
For skin developers, incorporating transparent colors into a skin is not particularly difficult. Anticipating how it will alter the look and feel of a page is another matter, of course.
Setting up the user interface involves a simple alteration. Instead of:
JColorSelector boxColor = new JColorSelector("Box", new JSmartTextField(6));
JColorSelector boxColor = new JAlphaColorSelector("Box", new JSmartTextField(7));
Because the hex code is now a total of nine characters instead of seven, you need to make the text field a bit bigger. Placing it in the user interface layout remains exactly the same, as does doing things like copying colors from one field to another. In short, you can treat the boxColor variable exactly the same way you did before.
Calling the color in your CSS involves a bigger change. Instead of:
One caution: the old jAlbum filters generally don't behave well when fed color codes for semi-transparent colors. The XBorderFilter, for example, creates new JPG files with the borders incorporated into them, but there's no such thing as transparency in a JPG, so the filter can't possibly deal with semi-transparent colors correctly. Experiment.
All current browsers now support alpha channel colors in their hex form¹, so in theory, converting the hex string to an rgba string is no longer needed. In short, you should be able to use this in your CSS:
But there's a catch. All browsers have adopted alpha channel colors in the form #RRGGBBAA, with the transparency indicated by the last two positions, rather than the first two.
So, as long as jAlbum continues to use the #AARRGGBB format, the hex codes for semi-transparent colors have to be converted to rgba values.
¹Support was introduced in Edge in mid-January, 2020, in version 79 of the browser. But as of this post, Microsoft has not pushed out the new version of Edge, so many users will not have it yet.