blob: 7e5b4ed8b7220223b07f30f594994c090ffd6cd0 [file]
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- ========================================================================= -->
<!-- This test file checks that the various combinations of units and viewbox -->
<!-- work in Batik for patternRegions -->
<!-- -->
<!-- @author vhardy@eng.sun.com -->
<!-- @version $Id$ -->
<!-- ========================================================================= -->
<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="body" width="450" height="500" viewBox="0 0 450 500">
<title>Pattern Region Test, B</title>
<text x="225" y="50" class="title">
patternRegion, x, y, width, height, viewBox
</text>
<!-- ============================================================= -->
<!-- Test content -->
<!-- ============================================================= -->
<g id="testContent" >
<defs>
<!-- ============================================== -->
<!-- For all the following patterns: -->
<!-- -->
<!-- patternUnits : default (objectBoundingBox) -->
<!-- patternContentUnits : default (userSpaceOnUse) -->
<!-- patternTransform: default (identity) -->
<!-- preserveAspectRatio: default (xMidyMid meet) -->
<!-- overflow : default (hidden) -->
<!-- -->
<!-- Because of the default preserveAspectRatio -->
<!-- value, the following patterns should be -->
<!-- centered in the pattern region. -->
<!-- ============================================== -->
<!-- ============================================== -->
<!-- The pattern content fits exactly in the -->
<!-- pattern region. -->
<!-- .2 * 100 = 20 userSpaceUnits -->
<!-- .4 * 50 = 20 userSpaceUnits -->
<!-- viewBox matches the pattern content's bounds -->
<!-- ============================================== -->
<pattern id="patternExactFit" x="0" y="0" width=".2" height=".4"
viewBox="0 0 20 20">
<use xlink:href="patternRegionA.svg#patternContent" />
</pattern>
<!-- ============================================== -->
<!-- The pattern content is offset along the x axis -->
<!-- .2 * 100 = 20 userSpaceUnits -->
<!-- .4 * 50 = 20 userSpaceUnits -->
<!-- viewBox is offset to the left. This causes the -->
<!-- pattern content to be translated to the right -->
<!-- when centered in the viewPort. -->
<!-- ============================================== -->
<pattern id="patternTranslateRegionX"
x="0" y="0"
width=".2" height=".4"
viewBox="-5 0 20 20" overflow="hidden">
<use xlink:href="patternRegionA.svg#patternContent" />
</pattern>
<!-- ============================================== -->
<!-- The pattern content is offset along the y axis -->
<!-- .2 * 100 = 20 userSpaceUnits -->
<!-- .4 * 50 = 20 userSpaceUnits -->
<!-- viewBox is offset to the top. This causes the -->
<!-- pattern content to be translated to the bottom -->
<!-- when centered in the viewPort. -->
<!-- ============================================== -->
<pattern id="patternTranslateRegionY"
x="0" y="0"
width=".2" height=".4"
viewBox="0 -5 20 20">
<use xlink:href="patternRegionA.svg#patternContent" />
</pattern>
<!-- ============================================== -->
<!-- The pattern content is offset along the both -->
<!-- both axis. -->
<!-- .2 * 100 = 20 userSpaceUnits -->
<!-- .4 * 50 = 20 userSpaceUnits -->
<!-- viewBox is offset to the top/left. This causes -->
<!-- the pattern content to be translated to the -->
<!-- bottom when centered in the viewPort. -->
<!-- ============================================== -->
<pattern id="patternTranslateRegionXY"
x="0" y="0"
width=".2" height=".4"
viewBox="-10 -10 20 20">
<use xlink:href="patternRegionA.svg#patternContent" />
</pattern>
<!-- ============================================== -->
<!-- In the following tests, the -->
<!-- preserveAspectRatio attribute is set to none. -->
<!-- ============================================== -->
<!-- ============================================== -->
<!-- The pattern content fits exactly in the -->
<!-- pattern region. -->
<!-- .2 * 100 = 20 userSpaceUnits -->
<!-- .4 * 50 = 20 userSpaceUnits -->
<!-- viewBox matches the pattern content's bounds -->
<!-- ============================================== -->
<pattern id="patternExactFitPANone" x="0" y="0" width=".2" height=".4"
viewBox="0 0 20 20"
preserveAspectRatio="none">
<use xlink:href="patternRegionA.svg#patternContent" />
</pattern>
<!-- ============================================== -->
<!-- Half of the pattern content is stretched along -->
<!-- the x axis. -->
<!-- .2 * 100 = 20 userSpaceUnits -->
<!-- .4 * 50 = 20 userSpaceUnits -->
<!-- ============================================== -->
<pattern id="patternStretchX"
x="0" y="0"
width=".2" height=".4"
viewBox="5 0 10 20"
preserveAspectRatio="none">
<use xlink:href="patternRegionA.svg#patternContent" />
</pattern>
<!-- ============================================== -->
<!-- Half of the pattern content is stretched along -->
<!-- the y axis. -->
<!-- ============================================== -->
<pattern id="patternStretchY"
x="0" y="0"
width=".2" height=".4"
viewBox="0 5 20 10"
preserveAspectRatio="none">
<use xlink:href="patternRegionA.svg#patternContent" />
</pattern>
<!-- ============================================== -->
<!-- The pattern content is stretched along both -->
<!-- axis. -->
<!-- ============================================== -->
<pattern id="patternStretchXY"
x="0" y="0"
width=".2" height=".4"
viewBox="5 5 10 10"
preserveAspectRatio="none">
<use xlink:href="patternRegionA.svg#patternContent" />
</pattern>
</defs>
<g transform="translate(30, 90)" >
<text class="legend" style="text-anchor:start" x="0" y="-5">Pattern (4 times actual size)</text>
<use xlink:href="patternRegionA.svg#patternContent" transform="scale(4, 4)" />
</g>
<g transform="translate(30, 200)">
<g>
<text class="legend" style="text-anchor:start" x="0" y="-5">Exact Fit in patternRegion</text>
<rect x="0" y="0" width="100" height="50" fill="url(#patternExactFit)" stroke="black"/>
<rect x="0" y="0" width="20" height="20" stroke="white" fill="none" />
</g>
<g transform="translate(0, 70)">
<text class="legend" style="text-anchor:start" x="0" y="-5">pattern content offset to the right</text>
<rect x="0" y="0" width="100" height="50" fill="url(#patternTranslateRegionX)" stroke="black"/>
<rect x="0" y="0" width="20" height="20" stroke="white" fill-opacity=".12" stroke-width="3"/>
<rect x="5" y="0" width="15" height="20" stroke="red" fill="none"/>
</g>
<g transform="translate(0, 140)">
<text class="legend" style="text-anchor:start" x="0" y="-5">pattern content offset to the bottom</text>
<rect x="0" y="0" width="100" height="50" fill="url(#patternTranslateRegionY)" stroke="black"/>
<rect x="0" y="0" width="20" height="20" stroke="white" fill-opacity=".12" stroke-width="3"/>
<rect x="0" y="5" width="20" height="15" stroke="red" fill="none"/>
</g>
<g transform="translate(0, 210)">
<text class="legend" style="text-anchor:start" x="0" y="-5">pattern content offset to the bottom/right</text>
<rect x="0" y="0" width="100" height="50" fill="url(#patternTranslateRegionXY)" stroke="black"/>
<rect x="0" y="0" width="20" height="20" stroke="white" fill-opacity=".12" stroke-width="3"/>
<rect x="10" y="10" width="10" height="10" stroke="red" fill="none"/>
</g>
</g>
<g transform="translate(255, 200)">
<g>
<text class="legend" style="text-anchor:start" x="0" y="-5">Exact Fit in patternRegion</text>
<rect x="0" y="0" width="100" height="50" fill="url(#patternExactFitPANone)" stroke="black"/>
<rect x="0" y="0" width="20" height="20" stroke="white" fill-opacity=".12" />
</g>
<g transform="translate(0, 70)">
<text class="legend" style="text-anchor:start" x="0" y="-5">pattern content X stretch</text>
<rect x="0" y="0" width="100" height="50" fill="url(#patternStretchX)" stroke="black"/>
<rect x="0" y="0" width="20" height="20" stroke="white" fill-opacity=".12" />
</g>
<g transform="translate(0, 140)">
<text class="legend" style="text-anchor:start" x="0" y="-5">pattern content Y stretch</text>
<rect x="0" y="0" width="100" height="50" fill="url(#patternStretchY)" stroke="black"/>
<rect x="0" y="0" width="20" height="20" stroke="white" fill-opacity=".12" />
</g>
<g transform="translate(0, 210)">
<text class="legend" style="text-anchor:start" x="0" y="-5">pattern content X/Y stretch</text>
<rect x="0" y="0" width="100" height="50" fill="url(#patternStretchXY)" stroke="black"/>
<rect x="0" y="0" width="20" height="20" stroke="white" fill-opacity=".12" />
</g>
</g>
</g>
<!-- ============================================================= -->
<!-- Batik sample mark -->
<!-- ============================================================= -->
<use xlink:href="../../../batikLogo.svg#Batik_Tag_Box" />
</svg>