In this course we will create a partial transparent PNG file to be used
as logo on
web pages. The logo will have a width of 210 pixels and a height
of 62 pixels (same size as the logos in the upper left and upper
right corner of this document).
In the table below the logo is placed in four table cells using
different background colors.
![]() This table cell has a white background. |
![]() This table cell has a lightred background. |
![]() This table cell has a lightgreen background. |
![]() This table cell has a lightblue background. |
First we prepare the logo basics in jFig, later we convert the
testlogo.fig file to testlogo.svg using fig2vect. After applying
manual modifications to the SVG file we convert it to PNG using
the Batik rasterizer.
To follow the course you need:
Before we begin we have to calculate the dimensions of our Fig file.
Two conversions are run on the Fig file, it is converted to SVG using
fig2vect first, the SVG file is converted to PNG using the Batik
rasterizer. Both conversions should not result in distorsions, so
the Fig file, the SVG file and the final PNG file should have the same
width/height ratio.
The width/height ratio is given by the number of pixels, it is
210/62 which can be reduced to 105/31. So we will use 105 times
the smallest usable length unit (sulu) for the image width and 31 sulu
for the image height. Now we need to find the length of 1 sulu.
The fig2vect program calculates the image dimensions from the graphics
elements (except texts)
and uses PS points (72 per inch) for all output drivers.
If this calculation does not result in integer numbers, the image
is enlarged a little bit to have integer values for the bounding box.
We want to avoid this rounding operation, so we need to choose
image dimensions resulting directly in integer numbers after the conversion
to PS points. This means one sulu must correspond to an integer
number when expressed in PS points.
In jFig we want to use the magnetic grid which depends on the unit settings,
the zoom factor and the magnetic grid settings. As the fig2vect output
resolution is based on inches it is a good idea to set the units to
inches in jFig too. The magnetic grid steps are fractions of one
inch in this case, typically powers of 1/2. So the magnetic grid steps
are candidates to become a sulu, we have to check which candidates
can be expressed in integer numbers in all coordinate spaces involved:
| sulu candidate | length in jFig internal units (2400 per inch) |
length in Fig units (1200 per inch) |
length in PS points (72 per inch) |
|---|---|---|---|
| 1 inch | 2400 | 1200 | 72 |
| 1/2 inch | 1200 | 600 | 36 |
| 1/4 inch | 600 | 300 | 18 |
| 1/8 inch | 300 | 150 | 9 |
| 1/16 inch | 150 | 75 | 4.5 |
As seen in the table the smallest candidate fullfilling our demands
is 1/8 inch.
So we use 1 sulu = 1/8 inch. Our image width is
105/8 inch = 13+1/8 inch. The image height is
3+7/8 inch.
We use inches as units.
We set up a magnetic grid.
We create a rectangle...
...so we have to click once for the first corner point...
...and again for the opposite corner point.
To modify the rectangle's properties we click the ``Edit object''
button...
...and click on the object to edit.
In the ``Edit rectangle'' dialog box...
...we set the layer number to 999 (the bottom layer)...
...and click ``OK'' to apply the changes.
We zoom out to see the entire logo.
To add the text we click the ``Create text'' button.
Before we add the text...
...we change the default font...
...to Palatino bold and...
...change the text size...
...to 96 pt (a really huge text size).
We also change the text alignment...
...to centered.
Now we can click on the text anchor point...
...and type the text.
For the second text we only need to click the ``Create text'' button,
click the anchor position and type the text.
The text background is a rectangle, so we click
``Create rectangle'',...
...click on the first corner point...
...and on the opposite corner point.
The background of the other text is a similar rectangle, so we copy the
object by clicking teh ``Copy an object'' button...
...select the object to copy (the rectangle)...
...and choose the final position by cklicking the mouse.
To change the rectangle properties (i.e. color and layer)
we click the ``Edit object'' button...
...click on the rectangle to choose the object to edit and do
the changes in the dialog box.
To change the rectangle color we click in the color area...
...and choose a color from the palette.
To change the line width we click the ``Line width'' button...
...and choose a new line width from the list by pressing one of the
buttons.
To choose another fill color we click the ``Select fill color''
button...
...and choose a color from the palette.
To choose the fill style...
...we click on the ``Select fill pattern'' button
and choose ``PURE''.
To ensure the rectangle is shown behind the text we need to assign a higher
layer number to the rectangle. We click the ``Set layer'' button and...
...enter a layer number higher than the layer number of the texts (the
texts
have the default layer number 100, so we can use 200 here).
We use the ``OK'' button to apply the changes. The same procedure can be
used to change the other rectangles properties.
We want to group a text and a rectangle to apply move operations to both
objects equally. So we group them using the
``Create a compound object'' button.
We click on the left text to select it...
and on the rectangle belonging to this text...
...and finish the compound object selection by clicking the
right mouse button.
The same procedure is used to group the other text and the rectangle.
To move a text/rectangle group we click the ``Move object'' button,...
...click on the compound object to choose the object to move,
move the mouse to move the object and...
...click to specify the object position (and end the move operation).
We also move the other object to a position near the lower right
corner.
The distance of the magnetic grid points is too large, so we can not place
the rectangle directly in the lower right corner, so we choose a place next to
the intended position.
Zooming in and out also modifies the magnetic grid, so we zoom in.
We are still in ``move object'' mode, so we can select
the rectangle again...
...and move it to the final position...
...and release it there.
We zoom out again to see the entire logo.
To create the strokes we use the ``Create a polyline'' button.
We click once for the first point...
...once for the corner point...
...and we click the right mouse key on the final point.
To change the polyline line width we use the ``Edit an object''
button...
...and click on the polyline.
After changing the line width to 6 we click ``OK'' to apply the changes.
The other polyline should be a mirrored copy, so the use the
``Copy an object'' button...
...and click on the polyline to copy it...
...and place the copy outside the logo.
For mirroring we click the ``Mirror on x-axis'' button...
...and click on the new polyline.
Next we click the ``Mirror on y-axis'' button and...
...click the polyline again.
We zoom in and move the polyline...
...to the correct position.
Finally we need to change some properties of the background rectangle.
We use the ``Edit object'' button...
...and click on the background rectangle.
We change line color and background color to white, line width to 0,
fill pattern to ``NONE'' and layer number to 999.
To convert the testlogo.fig file to testlogo.svg we use
fig2vect options testlogo.fig testlogo.svg
The following options are needed:
If you create a configuration
[svg.logo] gs svg-font directory = /windows/p/urw-svg font scale factor = 0.92 wh specification = pixels verbose output = yes remove background rectangle = yes background rectangle color = white
in section 2 or 3 of the fig2vect.cfg configuration file it is sufficient
to run the fig2vect program using
fig2vect -lsvg.logo testlogo.fig testlogo.svg
Open testlogo.svg in your favourite text editor and replace
<svg width="945px" height="279px" viewBox="0 0 945 279"
by
<svg width="210px" height="62px" viewBox="0 0 945 279"
Run
java -jar /opt/batik-1.6/batik-squiggle.jar &
to start the Batik SVG viewer.
Use the "File / Open File..." menu item to open
testlogo.svg. After applying modifications (see next section)
to testlogo.svg we can refresh
the view using the "File / Reload Document" menu item
or the toolbar button.
To add some transparency gradients we need to edit the SVG file in a
text editor.
We need four transparency masks, a horizontal and a vertical one for
both the yellow and the red rectangle. Each of the masks needs one
gradient to specify transparency values.
We use the following names for the gradients and masks:
| Name | Usage |
|---|---|
| HG1 | horizontal gradient for the yellow rectangle |
| HM1 | horizontal mask for the yellow rectangle |
| VG1 | vertical gradient for the yellow rectangle |
| VM1 | vertical mask for the yellow rectangle |
| HG2 | horizontal gradient for the red rectangle |
| HM2 | horizontal mask for the red rectangle |
| VG2 | vertical gradient for the red rectangle |
| VM2 | vertical mask for the red rectangle |
<defs> <style type="text/css"><![CDATA[lines, so it looks like this:
<defs> <linearGradient id="HG1" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="432" y2="0" > <stop offset="0" stop-color="white" stop-opacity="0" /> <stop offset="0.1" stop-color="white" stop-opacity="1" /> <stop offset="0.9" stop-color="white" stop-opacity="1" /> <stop offset="1" stop-color="white" stop-opacity="0" /> </linearGradient> <mask id="HM1" maskUnits="userSpaceOnUse" x="0" y="0" width="432" height="144" > <rect x="0" y="0" width="432" height="144" fill="url(#HG1)" /> </mask> <linearGradient id="VG1" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="0" y2="144" > <stop offset="0" stop-color="white" stop-opacity="0" /> <stop offset="0.3" stop-color="white" stop-opacity="1" /> <stop offset="0.7" stop-color="white" stop-opacity="1" /> <stop offset="1" stop-color="white" stop-opacity="0" /> </linearGradient> <mask id="VM1" maskUnits="userSpaceOnUse" x="0" y="0" width="432" height="144" > <rect x="0" y="0" width="432" height="144" fill="url(#VG1)" /> </mask> <linearGradient id="HG2" gradientUnits="userSpaceOnUse" x1="513" y1="0" x2="945" y2="0" > <stop offset="0" stop-color="white" stop-opacity="0" /> <stop offset="0.1" stop-color="white" stop-opacity="1" /> <stop offset="0.9" stop-color="white" stop-opacity="1" /> <stop offset="1" stop-color="white" stop-opacity="0" /> </linearGradient> <mask id="HM2" maskUnits="userSpaceOnUse" x="513" y="135" width="432" height="144" > <rect x="513" y="135" width="432" height="144" fill="url(#HG2)" /> </mask> <linearGradient id="VG2" gradientUnits="userSpaceOnUse" x1="0" y1="135" x2="0" y2="279" > <stop offset="0" stop-color="white" stop-opacity="0" /> <stop offset="0.3" stop-color="white" stop-opacity="1" /> <stop offset="0.7" stop-color="white" stop-opacity="1" /> <stop offset="1" stop-color="white" stop-opacity="0" /> </linearGradient> <mask id="VM2" maskUnits="userSpaceOnUse" x="513" y="135" width="432" height="144" > <rect x="513" y="135" width="432" height="144" fill="url(#VG2)" /> </mask> <style type="text/css"><![CDATA[
<!-- line 17, layer 200 --> <rect x="0" y="0" width="432" height="144" class="cD" /> <!-- line 22, layer 200 --> <rect x="513" y="135" width="432" height="144" class="cC" />by
<!-- line 17, layer 200 --> <g mask="url(#HM1)"><g mask="url(#VM1)"> <rect x="0" y="0" width="432" height="144" class="cD" /></g></g> <!-- line 22, layer 200 --> <g mask="url(#HM2)"><g mask="url(#VM2)"> <rect x="513" y="135" width="432" height="144" class="cC" /></g></g>
Run
java -jar /opt/batik-1.6/batik-rasterizer.jar testlogo.svg
to convert the logo to PNG.