Optimizing Design: Transparency

Optimizing Design: Transparency

eb graphics files are rectangular due to their pixel structure and file formats … yet we often see non-rectangular graphics on Web pages. There are two ways to make a graphic appear to have freeform shapes.

The simplest method to give the effect of transparency is to set a color for the parts of the graphic you want perceived as transparent to match the background color of the Web page. You aren’t really making the image transparent, but you’ll have the effect when you use it on the page. If you are using a JPEG image this is the only way you can create the effect of transparency.

For example, if you have green triangle and you want it to appear to be free-floating on a yellow page, you would fill the rest of the rectangular file containing the triangle with yellow. When this graphic is place on the page with the yellow background the rectangle will not appear:

The drawback to this, of course, is if you change the color of your page’s background you’ll suddenly have your image appearing in a box of the old page color! But if you know the color is fixed and you want a quick and simple solution, this can do the trick.

For a quick solution or for JPEG files, emulate the effect of transparency by creating the graphic with a background the same color as your page.

GIF/PNG Transparency
Transparency sets one of the indexed colors in the file to be transparent instead of a displayable color.

Only GIFs and PNGs can have a transparent area. GIF and PNG files are made of a fixed set of indexed colors. The transparency feature lets you tell one of those indexed colors to be transparent and let the background of the Web page show through. The alpha channel is somewhat analogous to a mask in print production.

For example, because the triangle has a transparent background, it can be placed on any page or table cell and the page or cell color will show through:

Alpha Channel
Each pixel in the GIF or PNG file can be one of a set of indexed colors. There can be as many as 255 indexed colors in a GIF or PNG file. The colors are described by three color channels: red, green, and blue. Each of the indexed colors is made of some percentage of these three colors.

In addition, the file formats support a fourth channel, the alpha channel. The alpha channel can record places in your image which are “background” and set that index color to have a transparent value.

If you are working with a graphic and have set the file background to “transparent” you have, in effect, set an alpha channel value. When you export that file as a transparent GIF/PNG, that “color” will be transparent.

You can also set a particular indexed color to be transparent. For example, if your graphics file has a black background, you can set black to be the indexed transparency color; everything that is black wiil be transparent.

Creating Transparency
Image editing programs such as Fireworks and Photoshop export transparent GIFs. Here’s an example of the Fireworks export box:

Exporting GIFs from Fireworks allows 3 options for transparency:

No Transparency:

Make specific color transparent:
Use alpha channel values:

Anti-alias Transparency
Anti-aliased and other edge effects require special note in transparency.

It is important to note that if your graphic has an antialiased edge, or an edge which is feathered or otherwise treated with effects, transparency won’t work quite the way you expect in a GIF file:

This antialiased text is set against a black table cell. When the text was created in the graphics program, the background was transparent. Antialiasing used light colors to create the illusion of smooth rounded edged, adding in white and pale pinks. Against a black background, these antialiased pixels produce a halo effect.
This is the same text, created the same way?except that it is not anti-aliased. There is no halo effect.

One workaround for this is the create the background against the color you expect to be using the image. When the anti-aliasing or other effect is processed, the colors used to create the effect will be those of the background:

Same text, created on a black ground and anti-aliased.
But you wouldn’t use this file against a white background?same halo effect, but in black instead of white!

One of the nice things about PNG files is that they support a true 8 bit alpha channel?which means anti-aliasing and special effects issues are far less of problem with PNGs than they are with GIFs.

It isn’t just anti-aliased text that creates a problem?drop shadow and other graphic effects create the same halo:

Artifacts occur when the original file has anti-aliased edges, like this drop shadow. Some of the original background color of the image file will be blended into the drop shadow, making an undesirable result when placed on a different background.
To avoid artifacts, create your graphic on a background that is the same color as the background of your Web page, and then specify that color as the transparent color. A fail-safe way to do this open your page in Navigator or Explorer and take a snapshot. Open the snapshot in Photoshop, and use the eyedropper tool to select the background color. In the graphic file, fill the background layer with this color. This may not look very good, but once it’s exported with the background color selected as the transparency color, it will look fine on your Web page. lizard

When creating anti-aliased or special effect edges, be aware of the page in which you are using them, and index against a matching color as you create the graphic.

devx-admin

devx-admin

Share the Post:
Chinese 5G Limitation

Germany Considers Limiting Chinese 5G Tech

A recent report has put forth the possibility that Germany’s Federal Ministry of the Interior and Community may consider limiting the use of Chinese 5G

Modern Warfare

The Barak Tank is Transforming Modern Warfare

The Barak tank is a groundbreaking addition to the Israeli Defense Forces’ arsenal, significantly enhancing their combat capabilities. This AI-powered military vehicle is expected to

AI Cheating Growth

AI Plagiarism Challenges Shake Academic Integrity

As generative AI technologies like ChatGPT become increasingly prevalent among students and raise concerns about widespread cheating, prominent universities have halted their use of AI

US Commitment

US Approves Sustainable Battery Research

The US Department of Energy has revealed a $325 million commitment in the research of innovative battery types, designed to enable solar and wind power

Netanyahu Musk AI

Netanyahu and Musk Discuss AI Future

On September 22, 2023, Israeli Prime Minister Benjamin Netanyahu met with entrepreneur Elon Musk in San Francisco prior to attending the United Nations. In a

Chinese 5G Limitation

Germany Considers Limiting Chinese 5G Tech

A recent report has put forth the possibility that Germany’s Federal Ministry of the Interior and Community may consider limiting the use of Chinese 5G technology by local network providers

Modern Warfare

The Barak Tank is Transforming Modern Warfare

The Barak tank is a groundbreaking addition to the Israeli Defense Forces’ arsenal, significantly enhancing their combat capabilities. This AI-powered military vehicle is expected to transform the way modern warfare

AI Cheating Growth

AI Plagiarism Challenges Shake Academic Integrity

As generative AI technologies like ChatGPT become increasingly prevalent among students and raise concerns about widespread cheating, prominent universities have halted their use of AI detection software, such as Turnitin’s

US Commitment

US Approves Sustainable Battery Research

The US Department of Energy has revealed a $325 million commitment in the research of innovative battery types, designed to enable solar and wind power as continuous, 24-hour energy sources.

Netanyahu Musk AI

Netanyahu and Musk Discuss AI Future

On September 22, 2023, Israeli Prime Minister Benjamin Netanyahu met with entrepreneur Elon Musk in San Francisco prior to attending the United Nations. In a live-streamed discussion, Netanyahu lauded Musk

Urban Gardening

Creating Thriving Cities Through Urban Gardening

The rising popularity of urban gardening is receiving increased recognition for its numerous advantages, as demonstrated in a recent study featured in the Environmental Research Letters journal. Carried out by

What You Need to Know About Cloud Security Strategies

What You Need to Know About Cloud Security Strategies

Today, many businesses are adopting cloud computing services. As a result, it’s important to recognize that security measures for data in the cloud are different from those in traditional on-premises

Romanian Energy Security

Eastern Europe is Achieving Energy Security

Canada and Romania have solidified their commitment to energy security and independence from Russian energy exports by signing a $3-billion export development agreement. The deal is centered on constructing two

Seamless Integration

Unlocking Seamless Smart Home Integration

The vision of an intelligently organized and interconnected smart home that conserves time, energy, and resources has long been desired by many homeowners. However, this aspiration has often been hindered

New Algorithm

MicroAlgo’s Groundbreaking Algorithm

MicroAlgo Inc. has revealed the creation of a knowledge-augmented backtracking search algorithm, developed through extensive research in evolutionary computational techniques. The algorithm is designed to boost problem-solving effectiveness, precision, and

Poland Energy Future

Westinghouse Builds Polish Power Plant

Westinghouse Electric Company and Bechtel have come together to establish a formal partnership in order to design and construct Poland’s inaugural nuclear power plant at the Lubiatowo-Kopalino site in Pomerania.

EV Labor Market

EV Industry Hurting For Skilled Labor

The United Auto Workers strike has highlighted the anticipated change towards a future dominated by electric vehicles (EVs), a shift which numerous people think will result in job losses. However,

Soaring EV Quotas

Soaring EV Quotas Spark Battle Against Time

Automakers are still expected to meet stringent electric vehicle (EV) sales quotas, despite the delayed ban on new petrol and diesel cars. Starting January 2023, more than one-fifth of automobiles

Affordable Electric Revolution

Tesla Rivals Make Bold Moves

Tesla, a name synonymous with EVs, has consistently been at the forefront of the automotive industry’s electric revolution. The products that Elon Musk has developed are at the forefront because

Sunsets' Technique

Inside the Climate Battle: Make Sunsets’ Technique

On February 12, 2023, Luke Iseman and Andrew Song from the solar geoengineering firm Make Sunsets showcased their technique for injecting sulfur dioxide (SO₂) into the stratosphere as a means

AI Adherence Prediction

AI Algorithm Predicts Treatment Adherence

Swoop, a prominent consumer health data company, has unveiled a cutting-edge algorithm capable of predicting adherence to treatment in people with Multiple Sclerosis (MS) and other health conditions. Utilizing artificial

Personalized UX

Here’s Why You Need to Use JavaScript and Cookies

In today’s increasingly digital world, websites often rely on JavaScript and cookies to provide users with a more seamless and personalized browsing experience. These key components allow websites to display

Geoengineering Methods

Scientists Dimming the Sun: It’s a Good Thing

Scientists at the University of Bern have been exploring geoengineering methods that could potentially slow down the melting of the West Antarctic ice sheet by reducing sunlight exposure. Among these

why startups succeed

The Top Reasons Why Startups Succeed

Everyone hears the stories. Apple was started in a garage. Musk slept in a rented office space while he was creating PayPal with his brother. Facebook was coded by a

Bold Evolution

Intel’s Bold Comeback

Intel, a leading figure in the semiconductor industry, has underperformed in the stock market over the past five years, with shares dropping by 4% as opposed to the 176% return

Semiconductor market

Semiconductor Slump: Rebound on the Horizon

In recent years, the semiconductor sector has faced a slump due to decreasing PC and smartphone sales, especially in 2022 and 2023. Nonetheless, as 2024 approaches, the industry seems to

Elevated Content Deals

Elevate Your Content Creation with Amazing Deals

The latest Tech Deals cater to creators of different levels and budgets, featuring a variety of computer accessories and tools designed specifically for content creation. Enhance your technological setup with

Learn Web Security

An Easy Way to Learn Web Security

The Web Security Academy has recently introduced new educational courses designed to offer a comprehensible and straightforward journey through the intricate realm of web security. These carefully designed learning courses