aboutsummaryrefslogtreecommitdiffstats
path: root/examples/fo/advanced/rounded-corners.fo
blob: d8df05922dc654e5e03d75c9844ecb64379ca789 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?xml version="1.0" encoding="ISO-8859-1"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
  <fo:layout-master-set>
    <fo:simple-page-master master-name="main" page-width="21cm" page-height="29.7cm" margin-top="5mm">
      <fo:region-body margin-bottom="30pt" margin-right="60pt" margin-left="60pt" margin-top="30pt"/>
      <fo:region-after extent="4in"/>
    </fo:simple-page-master>
  </fo:layout-master-set>
  <fo:page-sequence master-reference="main">
    <fo:flow flow-name="xsl-region-body" font-size="12pt">
      <fo:block font-size="14pt" font-weight="bold">
			        Examples using Rounded Corners
      </fo:block>
      <fo:block margin="20pt 0 40pt 0">
        <fo:block>The "border-radius" property in the http://xmlgraphics.apache.org/fop/extensions namespace is a shorthand property for setting appropriate values for "border-*-radius-*" (see below), and is used to specify round corners on block areas.  The property takes one or two values:
        </fo:block>
        <fo:block-container margin="10 20pt 20pt 20pt">
          <fo:block border-style="solid" border-width="10" border-color="#00f" fox:border-radius="20pt" padding="20pt" text-align="center" margin-bottom="10pt"> Circular corners are specified when 'border-radius' is set to a single value.  This value is the radius of the outer quadrant of the corner.</fo:block>
          <fo:block border-style="solid" border-width="10" border-color="#00f" fox:border-radius="20pt 40pt" padding="20pt" text-align="center" margin-bottom="10pt">Quarter-ellipse corners can be generated by setting two values for the property.  The first value is the radius in the Inline Progression Direction.  The second value is the radius in the Block Progression Direction.
          </fo:block>
        </fo:block-container>
      </fo:block>
      <fo:block margin="20pt 0 40pt 0">
        <fo:block>To specify the corner radii of two adjacent border segments, A and B, the properties border-A-radius-B and border-B-radius-A are set.  The value border-A-radius-B is the radius of the A-B corner in the direction perpendicular to segment A.
        </fo:block>
        <fo:table border-collapse="separate" margin-top="10pt">
          <fo:table-column column-width="200pt"/>
          <fo:table-column column-width="200pt"/>
          <fo:table-body>
            <fo:table-row>
              <fo:table-cell>
                <fo:block margin-left="50pt" border-style="solid" border-width="50pt 0 0 50pt" border-color="#00f" fox:border-before-radius-start="100pt" fox:border-start-radius-before="100pt" height="100pt">
                  <fo:block padding="50pt"/>
                </fo:block>
              </fo:table-cell>
              <fo:table-cell>
                <fo:block margin-left="50pt" border-style="solid" border-width="50pt 0 0 50pt" border-color="#00f" fox:border-before-radius-start="100pt" fox:border-start-radius-before="200pt" height="100pt">
                  <fo:block padding="50pt"/>
                </fo:block>
              </fo:table-cell>
            </fo:table-row>
          </fo:table-body>
        </fo:table>
      </fo:block>
      <fo:block margin="20pt">
        <fo:block border-style="solid" background-color="#aaf" border-width="10" border-color="#00f" fox:border-radius="50pt" padding="20pt" text-align="center" margin-bottom="20pt">Backgrounds are cropped&#8230;</fo:block>
        <fo:block break-after="page" border-style="solid" background-color="#aaf" border-width="0" border-color="#00f" fox:border-radius="50pt" padding="20pt" text-align="center" margin-bottom="20pt">&#8230;even with zero width borders.</fo:block>
      </fo:block>
      <fo:block>There are two canonical cases for rounded corners distinguished by the following condition:  The width of each border segment is less than the corner radius perpendicular to that segment.  This is demonstrated in Case <fo:inline font-style="italic">I</fo:inline> when this condition is <fo:inline font-style="italic">true</fo:inline> and Case <fo:inline font-style="italic">II</fo:inline> when <fo:inline font-style="italic">false</fo:inline>.</fo:block>
      <fo:table border-collapse="separate" margin-bottom="25pt">
        <fo:table-column column-width="200pt"/>
        <fo:table-column column-width="200pt"/>
        <fo:table-body>
          <fo:table-row>
            <fo:table-cell height="100pt">
              <fo:block margin-left="50pt" border-style="solid" border-width="70pt 0 0 70pt" border-color="#00f" fox:border-before-radius-start="100pt" fox:border-start-radius-before="100pt" height="100pt">
                <fo:block padding="50pt" text-align="center">
                  <fo:inline font-style="italic">I</fo:inline>
                </fo:block>
              </fo:block>
            </fo:table-cell>
            <fo:table-cell height="100pt">
              <fo:block margin-left="50pt" border-style="solid" border-width="70pt 0 0 70pt" border-color="#00f" fox:border-before-radius-start="50pt" fox:border-start-radius-before="50pt" height="100pt">
                <fo:block padding="50pt" text-align="center">
                  <fo:inline font-style="italic">II</fo:inline>
                </fo:block>
              </fo:block>
            </fo:table-cell>
          </fo:table-row>
        </fo:table-body>
      </fo:table>
      <fo:table border-collapse="separate" margin="40pt 0 20pt 0" break-after="page">
        <fo:table-column column-width="150pt"/>
        <fo:table-column column-width="150pt"/>
        <fo:table-column column-width="150pt"/>
        <fo:table-body>
          <fo:table-row>
            <fo:table-cell number-columns-spanned="3">
              <fo:block margin-bottom="20pt">The border segments join at a line that coincides with the one that interesects the inner and outer corners of the equivalent rectangular corner.  This is clearly demonstrated below where rounded borders are overlayed on top of rectangular borders.</fo:block>
            </fo:table-cell>
          </fo:table-row>
          <fo:table-row>
            <fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="50pt" height="100pt">
              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-radius-start="50pt" fox:border-start-radius-before="50pt" border-before-width="50pt" border-start-width="50pt" height="100pt">
                <fo:block margin-bottom="100pt"/>
              </fo:block>
            </fo:table-cell>
            <fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="50pt" height="100pt">
              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-radius-start="100pt" fox:border-start-radius-before="100pt" border-before-width="50pt" border-start-width="50pt" height="100pt">
                <fo:block margin-bottom="100pt"/>
              </fo:block>
            </fo:table-cell>
            <fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="50pt" height="100pt">
              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-radius-start="100pt" fox:border-start-radius-before="150pt" border-before-width="50pt" border-start-width="50pt" height="100pt">
                <fo:block margin-bottom="100pt"/>
              </fo:block>
            </fo:table-cell>
          </fo:table-row>
          <fo:table-row>
            <fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="100pt" height="100pt">
              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-radius-start="50pt" fox:border-start-radius-before="50pt" border-before-width="50pt" border-start-width="100pt" height="100pt">
                <fo:block margin-bottom="100pt"/>
              </fo:block>
            </fo:table-cell>
            <fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="100pt" height="100pt">
              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-radius-start="100pt" fox:border-start-radius-before="100pt" border-before-width="50pt" border-start-width="100pt" height="100pt">
                <fo:block margin-bottom="100pt"/>
              </fo:block>
            </fo:table-cell>
            <fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="100pt" height="100pt">
              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-radius-start="100pt" fox:border-start-radius-before="150pt" border-before-width="50pt" border-start-width="100pt" height="100pt">
                <fo:block margin-bottom="100pt"/>
              </fo:block>
            </fo:table-cell>
          </fo:table-row>
        </fo:table-body>
      </fo:table>
      <fo:block margin="20pt 0 40pt 0">
          <fo:block>        </fo:block>
        <fo:block-container margin="10 20pt 20pt 20pt">
            <fo:block border-style="solid" border-width="10" border-color="#00f" fox:border-radius="2000pt" padding="20pt" text-align="center" margin-bottom="10pt">If border radii are specified that would produce overlapping curves (as is the case for the block containg <fo:inline font-style="italic">this</fo:inline> text), then all border radii are proportionally reduced until none of them overlap.  This is in accordance to the procedure described at http://www.w3.org/TR/css3-background/#corner-overlap.</fo:block>
        </fo:block-container>
      </fo:block>
    </fo:flow>
  </fo:page-sequence>
</fo:root>