WebDwarf Tutorials banner
WebDwarf logo
Rendering and Shading
Rendering and Shading
Left arrow
Rounded rectangle
Fill example
Rendering is the act of drawing an image or text on your screen. Ultimately of course, you are concerned about rendering on your visitor's screen.

Use shading to add color and  transparency to shapes and titles. In this tutorial, we cover:

Gradient fill (or shading) example
Gradient fill button operation
Color endpoint buttons
Fill-type buttons -- Flat, Lin, Cyl and Rad
Color picker eyedropper
Multiple custom colors
More examples of gradient fills
Transparency
Anti-aliasing (smoothing)
Re-rendering
Include Background
Image format and transparency



Gradient fill (or shading) example

A gradient fill has two endpoints, and the color changes gradually and evenly as you move from one endpoint to the other. Here is a simple example showing a gradient fill of a rectangle:




Gradient fill button operation

In the Quick Editor > Shading tab are a number of buttons. They have two positions -- on or off. In the "On" state they become darker to show they are selected. "Off" -- they are lighter. This makes more sense if you think of the "On" button as depressed and so in more shadow than an unselected one. (But is the reverse of some other buttons you may have seen.)



Color endpoint buttons

The first two buttons are labeled 1 and 2, for color 1 and color 2, the colors of the two endpoints. The color 1 button will become active when the shading supports 2 colors -- anything other than a flat color. 
Rectangle button
Gradient fill
Quick Editor button
Quick Editor Shading tab
Shaded Title
If they are labelled Cnt (Contrast) and Brt (Brightness), it may be because you may have an image selected -- they don't allow gradient fills. Try making a title like our "Shaded Title" just above.

To set the endpoint colors, select a button, either 1 or 2, then adjust the sliders for the color to associate with that endpoint.


 
Fill-type buttons -- Flat, Lin Cyl and Rad

Below the color endpoint buttons, are four more buttons. You can select only one at a time:
Quick Editor Shading tab
Flat shading
Linear shading 1
Linear shading 2
Cylindrical shading 1
Cylindrical shading 2
Radial shading
Flat
Linear
Linear
Cylindrical
Cylindrical
Radial
Shaded Title
Create a title like the Shaded Title above and try these buttons, while adjusting the color sliders. These are also called RGB sliders, short for for Red, Green, Blue.

The bottom slider, Trans,  is used to adjust transparency. Use it to adjust the transparency of either or both colors 1 and 2.

For color adjustment, use the left/right keyboard arrows to nudge the slider, type the values into the adjacent edit box or use the eyedropper.

For linear and cylindrical shading, adding 90.00 or 270.00 degrees of rotation to the object via the Quick Editor > Object tab will change the direction of the graduation -- shown in the examples above.

Other options are 180.00 degrees of rotation to provide a complete reversal of the graduation. This has a similar end result to using the Flip button in the Quick Editor > Shading tab.

See also:
Transparency for images
Transparency for shapes


Color picker eyedropper
Quick Editor button
Color picker eyedropper

The eyedropper that shows in the Quick Editor > Shading tab (and is often grayed out) is a feature that is shared by the Text editors. To use the color picker eyedropper:
Color picker eyedropper
Multiple custom colors

The color dialog (e.g. Quick Editor > Shading tab > Pick) is a Windows standard, used in many other programs. It acts the same there too. It is fairly easy to use, but it is not clear how to select more than one custom color.

To set custom colors:
  1. Click the button Define Custom Colors
  2. Click the custom color box you want to change -- it should have a little rectangle around it
  3. In the large color window on the right, click the hue you want
  4. This changes the vertical color band at the far right showing the luminances of that hue
  5. Move the triangular slider to the luminance you want or click in the vertical color band
  6. The box marked Color|Solid should change as you do these steps
  7. Click Add To Custom Colors
The trap is that if the triangular slider is set "no luminance" (slider at its lowest) you can click anywhere in the large color window and nothing seems to happen. Any hue at zero luminance is black!

You can set a sequence of custom colors by looping through the steps 2 to 7. Each Add To click will fill out the next custom color in sequence -- continuing on from the color box selected in Step 2.


More examples of gradient fills

The first two examples also show rotation.
Linear shading
Cylindrical shading
Radial shading
Linear
Cylindrical
Radial
Shading
In the Gradient fill section, we discussed using the controls in the Quick Editor > Shading tab. Create a polygon like the arrow polygon on the left; then:

Outlines
Select the Quick Editor > Outline tab. Adjust the Line Width and color:
Left arrow
Quick Editor button
Left arrow
Transparent Flat Shaded Title
Transparency

Adding transparency makes an object look transparent by letting some of the background show through:
  1. Create a black title like the Flat Shaded Title above
  2. Select the Quick Editor > Shading tab
  3. The title has a color already assigned to it: black
  4. Adjust the Transparency between 0 and 100 to see the effect
  5. Select Linear shading and adjust the color 1 and color 2 transparency settings
  6. Move the title so that it is on top of a blue rectangle like that on the right.
See also:
Adding transparency to an image
Titles tutorial


Quick Editor button
Anti-aliasing (smoothing)

When you have an object that is running diagonally across your screen, you may see jagged edges. This is called aliasing -- if you have a sharp transition between two colors, your computer has to choose one or the other. It is possible to smooth out the transition by adding some extra pixels of intermediate colors around the transition. This is called anti-aliasing, and we're about to do it right now:

Quick Editor button
Re-rendering

Rendering
is the act of drawing objects on your screen. Re-rendering is the act of modifying an object in some way, then drawing it again. In practice, this means that the re-rendered object will require an image file in order to be displayed.

One common application of re-rendering is to make a permanent group of two or more related images, then place re-render on for the group. This produces one larger image file instead of two or more smaller files -- often more economical.  The shadowed title at the top of this page has this treatment.

For more complicated shapes as we have been using here, re-rendering on or off makes no difference to the resulting image file -- one is always produced.

However, for straight flat-color rectangles, if you put Anti-Alias and Re-Render  off, no new image file is produced.
Include Background

If Include Background is on, (Options > Project Options)  anything in the background will be drawn into the picture to simulate transparency. In two cases you can't turn Include Background on:
If Include Background is off, the background will be not be drawn into the picture. One of two things will happen instead:
Image format and transparency

PNG 8 and GIF are the only formats that can use transparency that will work on all browsers. Regular PNG (PNG 24) does support transparency but since not all browsers respect it, we do not use it that way.  PNG 32 supports 256 levels of tranparency.

PNG 8 and GIF are 8 bits-per-pixel formats. That means they can only have a maximum of 256 colors so you may see some loss of color on larger images.

If you import a full color image and then change it to GIF or PNG-8, WebDwarf will choose the best 256 colors. That will minimize the loss of color.

For GIF and PNG 8, true transparency won't show until you preview or publish. Preview and look at the images against the bricks and see how they differ from their workpage appearance. In each case, the image immediately below is an exact clone -- an identical image using the same image file.

Notice the improvement with PNG 32 on the right.
 
PNG 8
GIF
PNG 32
PNG 8
GIF
PNG 32
PNG 8 (same image file)
GIF (same image file)
PNG 32 (same image file)
PNG 8 and GIF show an issue with anti-alias too. The bottom images are anti-aliased against a white background, so pick up a halo of white around the logo part of the image. This is not a problem when the same image is used against a pale background. However, when placed against a much darker background, the bricks in this case, the anti-alias shows. If this is a problem, one solution is to use another anti-aliased image, this one anti-aliased against the colored background.

Another solution is to use the PNG 32 format.

See also:
Image tutorial


< Tutorials Home
Virtual Mechanics Logo
WebDwarf
®

Tutorials
Quick Editor: outline and color
Not anti-aliased
Anti-aliased
  1. Create a rotated title like one of those on the left
  2. Open the Quick Editor > Object tab
  3. Make sure the Anti-Alias box is checked. You can see the effect of anti-aliasing in the workpage by checking and un-checking the High Render box
  4. When High Render is selected, the workpage may appear sluggish on slower machines. It is OK to work with high render off. It affects only your workpage -- it has no effect when you publish or preview
  5. Turn High Render off and rotate the rotated title observing the aliasing jaggies. Turn High Render on to see the effect of anti-aliasing.
The downside of anti-aliasing is that it can make smaller objects look fuzzy. If in doubt, try it both on and off -- pick the one that give the best results.

Also, you are anti-aliasing against a particular background, often white -- you may have problems if you then use the same image against a colored background. Example.

See also:
Anti-aliasing images
Anti-aliasing titles