Chapter 4: Basic figures lines and shapes
Rect, circle and ellipse
- the co-ordinates for the bottom left hand corner,
- its width and height,
- the x and y co-ordinates of the point where its center should be,
- its radius
- fill, which tells the parser if the shape should be filled in or not, and
- stroke which tells it if the shape should have its outline displayed.
EXAMPLE 3
Tabs
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE document SYSTEM "../rml.dtd">
<document filename="example_3.pdf">
<template>
<pageTemplate id="main">
<pageGraphics>
<!-- set the font and fill colour for the title. -->
<fill color="red"/>
<setFont name="Helvetica" size="24"/>
<!-- Use drawCentredString to place a title on the page -->
<drawCentredString x="297.5" y="800">Simple Text and Graphics with RML.</drawCentredString>
<fill color="red"/>
<!-- look at the output - though a fill color is set, no fill is produced, -->
<!-- since fill is set to "no" for the circle -->
<circle x="127.5" y="672.75" radius="1 in" fill="no" stroke="yes"/>
<fill color="green"/>
<stroke color="black"/>
<circle x="297.5" y="672.75" radius="1 in" fill="yes" stroke="no"/>
<fill color="blue"/>
<stroke color="black"/>
<circle x="467.5" y="672.75" radius="1 in" fill="yes" stroke="yes"/>
<fill color="black"/>
<setFont name="Helvetica" size="9"/>
<drawCentredString x="127.5" y="567.5">Circle - with stroke, but no fill.</drawCentredString>
<drawCentredString x="297.5" y="567.5">Circle - with fill, but no stroke.</drawCentredString>
<drawCentredString x="467.5" y="567.5">Circle - with both stroke and fill.</drawCentredString>
<fill color="red"/>
<ellipse x="77" y="382.25" width="110" height="170" fill="no" stroke="yes"/>
<fill color="green"/>
<stroke color="black"/>
<ellipse x="247" y="382.25" width="110" height="170" fill="yes" stroke="no"/>
<fill color="blue"/>
<stroke color="black"/>
<ellipse x="417" y="382.25" width="110" height="170" fill="yes" stroke="yes"/>
<fill color="black"/>
<drawCentredString x="127.5" y="357">Ellipse - with stroke, but no fill.</drawCentredString>
<drawCentredString x="297.5" y="357">Ellipse - with fill, but no stroke.</drawCentredString>
<drawCentredString x="467.5" y="357">Ellipse - with both stroke and fill.</drawCentredString>
<rect x="84.5" y="214.3" width="1 in" height="1.15 in" fill="no" stroke="yes"/>
<fill color="green"/>
<stroke color="black"/>
<rect x="254.5" y="214.3" width="1 in" height="1.15 in" fill="yes" stroke="no"/>
<fill color="blue"/>
<stroke color="black"/>
<rect x="424.5" y="214.3" width="1 in" height="1.15 in" fill="yes" stroke="yes"/>
<fill color="black"/>
<drawCentredString x="127.5" y="199.1">Rect - with stroke, but no fill.</drawCentredString>
<drawCentredString x="297.5" y="199.1">Rect - with fill, but no stroke.</drawCentredString>
<drawCentredString x="467.5" y="199.1">Rect - with both stroke and fill.</drawCentredString>
<rect x="84.5" y="56.5" width="1 in" height="1.15 in" fill="no" stroke="yes" round="0.15 in"/>
<fill color="green"/>
<stroke color="black"/>
<rect x="254.5" y="56.5" width="1 in" height="1.15 in" fill="yes" stroke="no" round="0.15 in"/>
<fill color="blue"/>
<stroke color="black"/>
<rect x="424.5" y="56.5" width="1 in" height="1.15 in" fill="yes" stroke="yes" round="0.15 in"/>
<fill color="black"/>
<drawCentredString x="127.5" y="41.25">Rect - with stroke and round, but no fill.</drawCentredString>
<drawCentredString x="297.5" y="41.25">Rect - with fill and round, but no stroke.</drawCentredString>
<drawCentredString x="467.5" y="41.25">Rect - with stroke, fill and round.</drawCentredString>
</pageGraphics>
<frame id="first" x1="0.5in" y1="0.5in" width="20cm" height="28cm"/>
</pageTemplate>
</template>
<stylesheet>
</stylesheet>
<story>
<para></para>
</story>
</document>
Fill and stroke
<fill color="olivedrab"/>
<stroke color="khaki"/>
Lines and lineMode
<lines>
2.5in 10.5in 3.5in 10.5in
</lines>
<lines>
2.5in 10.5in 3.5in 10.5in
2.5in 10.25in 3.5in 10.25in
2.5in 10in 3.5in 10in
</lines>
<lines>
2.5in 10.5in 3.5in 10.5in 2.5in 10.25in 3.5in 10.25in 2.5in 10in 3.5in 10in
</lines>
Figure
Figure
EXAMPLE 4
Tabs
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE document SYSTEM "../rml.dtd">
<document filename="example_4.pdf">
<template>
<pageTemplate id="main">
<pageGraphics>
<fill color="red"/>
<setFont name="Helvetica" size="24"/>
<drawCentredString x="297.5" y="800">Lines in RML.</drawCentredString>
<!-- notice that each of these "empty" tags are teminated with a slash -->
<lineMode width="1"/>
<lines>1in 10.5in 2in 10.5in
2in 10.5in 1.5in 10in
1.5in 10in 1.5in 10.75in
</lines>
<fill color="black"/>
<setFont name="Helvetica" size="9"/>
<drawCentredString x="1.5 in" y="9.75 in">width = 1</drawCentredString>
<lineMode width="5"/>
<lines>2.5in 10.5in 3.5in 10.5in
3.5in 10.5in 3in 10in
3in 10in 3in 10.75in
</lines>
<drawCentredString x="3 in" y="9.75 in">width = 5</drawCentredString>
<lineMode width="10"/>
<lines>4in 10.5in 5in 10.5in
5in 10.5in 4.5in 10in
4.5in 10in 4.5in 10.75in
</lines>
<drawCentredString x="4.5 in" y="9.75 in">width = 10</drawCentredString>
<lineMode width="15"/>
<lines>5.5in 10.5in 6.5in 10.5in
6.5in 10.5in 6in 10in
6in 10in 6in 10.75in
</lines>
<drawCentredString x="6 in" y="9.75 in">width = 15</drawCentredString>
<!-- examples for the 'join' attribute to 'LineMode' -->
<lineMode width="5"/>
<lines>1in 9in 2in 9in
2in 9in 1.5in 8.5in
1.5in 8.5in 1.5in 9.25in
</lines>
<fill color="black"/>
<setFont name="Helvetica" size="9"/>
<drawCentredString x="1.5 in" y="8.25 in">width=10</drawCentredString>
<!-- options for 'join' are "round", "mitered", or "bevelled" -->
<lineMode width="5" join="round"/>
<lines>2.5in 9in 3.5in 9in
3.5in 9in 3in 8.5in
3in 8.5in 3in 9.25in
</lines>
<drawCentredString x="3 in" y="8.25 in">width=5, join=round</drawCentredString>
<lineMode width="5" join="mitered"/>
<lines>4in 9in 5in 9in
5in 9in 4.5in 8.5in
4.5in 8.5in 4.5in 9.25in
</lines>
<drawCentredString x="4.5 in" y="8.25 in">width=5, join=mitered</drawCentredString>
<lineMode width="5" join="bevelled"/>
<lines>5.5in 9in 6.5in 9in
6.5in 9in 6in 8.5in
6in 8.5in 6in 9.25in
</lines>
<drawCentredString x="6 in" y="8.25 in">width=5, join=bevelled</drawCentredString>
<!-- examples for the 'cap' attribute to 'LineMode' -->
<lineMode width="10"/>
<lines>1in 7.5in 2in 7.5in
2in 7.5in 1.5in 7in
1.5in 7in 1.5in 7.75in
</lines>
<fill color="black"/>
<setFont name="Helvetica" size="9"/>
<drawCentredString x="1.5 in" y="6.75 in">width=10</drawCentredString>
<!-- options for 'cap' are "default", "round", or "square" -->
<lineMode width="10" cap="default"/>
<lines>2.5in 7.5in 3.5in 7.5in
3.5in 7.5in 3in 7in
3in 7in 3in 7.75in
</lines>
<drawCentredString x="3 in" y="6.75 in">width=10, cap=default</drawCentredString>
<lineMode width="10" cap="round"/>
<lines>4in 7.5in 5in 7.5in
5in 7.5in 4.5in 7in
4.5in 7in 4.5in 7.75in
</lines>
<drawCentredString x="4.5 in" y="6.75 in">width=10, cap=round</drawCentredString>
<lineMode width="10" cap="square"/>
<lines>5.5in 7.5in 6.5in 7.5in
6.5in 7.5in 6in 7in
6in 7in 6in 7.75in
</lines>
<drawCentredString x="6 in" y="6.75 in">width=10, cap=square</drawCentredString>
<lineMode width="5" cap="default"/>
<!-- examples for the 'miterLimit' attribute to 'LineMode' -->
<lineMode width="5" join="mitered"/>
<lines>1in 6in 2in 6in
2in 6in 1.5in 5.5in
1.5in 5.5in 1.5in 6.25in
</lines>
<fill color="black"/>
<setFont name="Helvetica" size="9"/>
<drawCentredString x="1.5 in" y="5.25 in">width=5, join=mitered</drawCentredString>
<lineMode width="5" join="mitered" miterLimit="10"/>
<lines>2.5in 6in 3.5in 6in
3.5in 6in 3in 5.5in
3in 5.5in 3in 6.25in
</lines>
<drawCentredString x="3 in" y="5.25 in">width=5, join=mitered</drawCentredString>
<drawCentredString x="3 in" y="5.1 in">miterLimit=10</drawCentredString>
<lineMode width="10" join="mitered"/>
<lines>4in 6in 5in 6in
5in 6in 4.5in 5.5in
4.5in 5.5in 4.5in 6.25in
</lines>
<drawCentredString x="4.5 in" y="5.25 in">width=10, join=mitered</drawCentredString>
<lineMode width="10" join="mitered" miterLimit="20"/>
<lines>5.5in 6in 6.5in 6in
6.5in 6in 6in 5.5in
6in 5.5in 6in 6.25in
</lines>
<drawCentredString x="6 in" y="5.25 in">width=10, join=mitered</drawCentredString>
<drawCentredString x="6 in" y="5.1 in">miterLimit=20</drawCentredString>
<!-- examples for the 'dash' attribute to 'LineMode' -->
<lineMode width="2"/>
<lines>1in 4.5in 2in 4.5in
2in 4.5in 1.5in 4in
1.5in 4in 1.5in 4.75in
</lines>
<fill color="black"/>
<setFont name="Helvetica" size="9"/>
<drawCentredString x="1.5 in" y="3.75 in">width=2</drawCentredString>
<!-- options for 'dash' are sequences of numbers -->
<lineMode width="2" dash="5,5"/>
<lines>2.5in 4.5in 3.5in 4.5in
3.5in 4.5in 3in 4in
3in 4in 3in 4.75in
</lines>
<drawCentredString x="3 in" y="3.75 in">width=2, dash=5,5</drawCentredString>
<lineMode width="2" dash="2,10"/>
<lines>4in 4.5in 5in 4.5in
5in 4.5in 4.5in 4in
4.5in 4in 4.5in 4.75in
</lines>
<drawCentredString x="4.5 in" y="3.75 in">width=2, dash=2,10</drawCentredString>
<lineMode width="2" dash="5,5,2,10"/>
<lines>5.5in 4.5in 6.5in 4.5in
6.5in 4.5in 6in 4in
6in 4in 6in 4.75in
</lines>
<drawCentredString x="6 in" y="3.75 in">width=2, dash=5,5,2,10</drawCentredString>
</pageGraphics>
<frame id="first" x1="72" y1="72" width="451" height="698"/>
</pageTemplate>
</template>
<stylesheet>
</stylesheet>
<story>
<para></para>
</story>
</document>