| 1 |
<?xml version="1.0" standalone="no"?> |
| 2 |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN" |
| 3 |
"http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd"> |
| 4 |
|
| 5 |
<!-- |
| 6 |
|
| 7 |
Licensed to the Apache Software Foundation (ASF) under one or more |
| 8 |
contributor license agreements. See the NOTICE file distributed with |
| 9 |
this work for additional information regarding copyright ownership. |
| 10 |
The ASF licenses this file to You under the Apache License, Version 2.0 |
| 11 |
(the "License"); you may not use this file except in compliance with |
| 12 |
the License. You may obtain a copy of the License at |
| 13 |
|
| 14 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 15 |
|
| 16 |
Unless required by applicable law or agreed to in writing, software |
| 17 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 18 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 |
See the License for the specific language governing permissions and |
| 20 |
limitations under the License. |
| 21 |
|
| 22 |
--> |
| 23 |
<!-- ====================================================================== --> |
| 24 |
<!-- Test of the dom SVGColor interface --> |
| 25 |
<!-- --> |
| 26 |
<!-- @author [email protected] --> |
| 27 |
<!-- @version $Id$ --> |
| 28 |
<!-- ====================================================================== --> |
| 29 |
|
| 30 |
<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> |
| 31 |
|
| 32 |
<svg id="body" width="450" height="500" viewBox="0 0 450 500" |
| 33 |
onload="onload()" |
| 34 |
xmlns="http://www.w3.org/2000/svg" |
| 35 |
xmlns:xlink="http://www.w3.org/1999/xlink" > |
| 36 |
<title>Test DOM SVGColor Interface</title> |
| 37 |
|
| 38 |
<text x="50%" y="45" class="title">Test DOM SVGColor Interface</text> |
| 39 |
|
| 40 |
<script type="text/ecmascript"><![CDATA[ |
| 41 |
var UNIT_NUMBER =1; |
| 42 |
var UNIT_PERCENT=2; |
| 43 |
function onload() { |
| 44 |
test(); |
| 45 |
} |
| 46 |
|
| 47 |
function showFill(id, suff) { |
| 48 |
var elem = document.getElementById(id); |
| 49 |
var fill = elem.style.getPropertyCSSValue("fill"); |
| 50 |
var tb = document.getElementById(id+suff); |
| 51 |
tb.appendChild(document.createTextNode(fill.getCssText())); |
| 52 |
return fill; |
| 53 |
} |
| 54 |
|
| 55 |
function test() { |
| 56 |
var fill, r, g, b; |
| 57 |
|
| 58 |
fill = showFill("r1", ".b"); |
| 59 |
fill.setCssText("gold"); |
| 60 |
showFill("r1", ".a"); |
| 61 |
|
| 62 |
fill = showFill("r2", ".b"); |
| 63 |
fill.setCssText("gold"); |
| 64 |
showFill("r2", ".a"); |
| 65 |
|
| 66 |
fill = showFill("r3", ".b"); |
| 67 |
r = fill.getRed(); r.setCssText("50"); |
| 68 |
showFill("r3", ".a"); |
| 69 |
|
| 70 |
fill = showFill("r4", ".b"); |
| 71 |
r = fill.getRed(); r.setFloatValue(UNIT_NUMBER, 50); |
| 72 |
showFill("r4", ".a"); |
| 73 |
|
| 74 |
fill = showFill("r5", ".b"); |
| 75 |
r = fill.getRed(); r.setFloatValue(UNIT_PERCENT, 50); |
| 76 |
showFill("r5", ".a"); |
| 77 |
|
| 78 |
fill = showFill("r6", ".b"); |
| 79 |
g = fill.getGreen(); g.setCssText("50"); |
| 80 |
showFill("r6", ".a"); |
| 81 |
|
| 82 |
fill = showFill("r7", ".b"); |
| 83 |
g = fill.getGreen(); g.setFloatValue(UNIT_NUMBER, 50); |
| 84 |
showFill("r7", ".a"); |
| 85 |
|
| 86 |
fill = showFill("r8", ".b"); |
| 87 |
g = fill.getGreen(); g.setFloatValue(UNIT_PERCENT, 50); |
| 88 |
showFill("r8", ".a"); |
| 89 |
|
| 90 |
fill = showFill("r9", ".b"); |
| 91 |
b = fill.getBlue(); b.setCssText("50"); |
| 92 |
showFill("r9", ".a"); |
| 93 |
|
| 94 |
fill = showFill("r10", ".b"); |
| 95 |
b = fill.getBlue(); b.setFloatValue(UNIT_NUMBER, 50); |
| 96 |
showFill("r10", ".a"); |
| 97 |
|
| 98 |
fill = showFill("r11", ".b"); |
| 99 |
b = fill.getBlue(); b.setFloatValue(UNIT_PERCENT, 50); |
| 100 |
showFill("r11", ".a"); |
| 101 |
} |
| 102 |
]]></script> |
| 103 |
|
| 104 |
<g id="test-content"> |
| 105 |
<g transform="translate(10, 50)"> |
| 106 |
<rect id="r1" x="0" y="0" width="75" height="40" |
| 107 |
style="fill:crimson"/> |
| 108 |
<text x="80" y="15">Before: <tspan id="r1.b"/></text> |
| 109 |
<text x="80" y="35">After: <tspan id="r1.a"/></text> |
| 110 |
</g> |
| 111 |
|
| 112 |
<g transform="translate(10, 100)"> |
| 113 |
<rect id="r2" x="0" y="0" width="75" height="40" |
| 114 |
style="fill:rgb(255, 0, 0)"/> |
| 115 |
<text x="80" y="15">Before: <tspan id="r2.b"/></text> |
| 116 |
<text x="80" y="35">After: <tspan id="r2.a"/></text> |
| 117 |
</g> |
| 118 |
|
| 119 |
<g transform="translate(10, 150)"> |
| 120 |
<rect id="r3" x="0" y="0" width="75" height="40" |
| 121 |
style="fill:rgb(255, 0, 128)"/> |
| 122 |
<text x="80" y="15">Before: <tspan id="r3.b"/></text> |
| 123 |
<text x="80" y="35">After: <tspan id="r3.a"/></text> |
| 124 |
</g> |
| 125 |
|
| 126 |
<g transform="translate(10, 200)"> |
| 127 |
<rect id="r4" x="0" y="0" width="75" height="40" |
| 128 |
style="fill:rgb(255, 0, 128)"/> |
| 129 |
<text x="80" y="15">Before: <tspan id="r4.b"/></text> |
| 130 |
<text x="80" y="35">After: <tspan id="r4.a"/></text> |
| 131 |
</g> |
| 132 |
|
| 133 |
<g transform="translate(10, 250)"> |
| 134 |
<rect id="r5" x="0" y="0" width="75" height="40" |
| 135 |
style="fill:rgb(255, 0, 128)"/> |
| 136 |
<text x="80" y="15">Before: <tspan id="r5.b"/></text> |
| 137 |
<text x="80" y="35">After: <tspan id="r5.a"/></text> |
| 138 |
</g> |
| 139 |
|
| 140 |
<g transform="translate(10, 300)"> |
| 141 |
<rect id="r6" x="0" y="0" width="75" height="40" |
| 142 |
style="fill:rgb(255, 0, 128)"/> |
| 143 |
<text x="80" y="15">Before: <tspan id="r6.b"/></text> |
| 144 |
<text x="80" y="35">After: <tspan id="r6.a"/></text> |
| 145 |
</g> |
| 146 |
|
| 147 |
<g transform="translate(10, 350)"> |
| 148 |
<rect id="r7" x="0" y="0" width="75" height="40" |
| 149 |
style="fill:rgb(255, 0, 128)"/> |
| 150 |
<text x="80" y="15">Before: <tspan id="r7.b"/></text> |
| 151 |
<text x="80" y="35">After: <tspan id="r7.a"/></text> |
| 152 |
</g> |
| 153 |
|
| 154 |
<g transform="translate(10, 400)"> |
| 155 |
<rect id="r8" x="0" y="0" width="75" height="40" |
| 156 |
style="fill:rgb(255, 0, 128)"/> |
| 157 |
<text x="80" y="15">Before: <tspan id="r8.b"/></text> |
| 158 |
<text x="80" y="35">After: <tspan id="r8.a"/></text> |
| 159 |
</g> |
| 160 |
|
| 161 |
<g transform="translate(225, 50)"> |
| 162 |
<rect id="r9" x="0" y="0" width="75" height="40" |
| 163 |
style="fill:rgb(255, 0, 128)"/> |
| 164 |
<text x="80" y="15">Before: <tspan id="r9.b"/></text> |
| 165 |
<text x="80" y="35">After: <tspan id="r9.a"/></text> |
| 166 |
</g> |
| 167 |
|
| 168 |
<g transform="translate(225, 100)"> |
| 169 |
<rect id="r10" x="0" y="0" width="75" height="40" |
| 170 |
style="fill:rgb(255, 0, 128)"/> |
| 171 |
<text x="80" y="15">Before: <tspan id="r10.b"/></text> |
| 172 |
<text x="80" y="35">After: <tspan id="r10.a"/></text> |
| 173 |
</g> |
| 174 |
|
| 175 |
<g transform="translate(225, 150)"> |
| 176 |
<rect id="r11" x="0" y="0" width="75" height="40" |
| 177 |
style="fill:rgb(255, 0, 128)"/> |
| 178 |
<text x="80" y="15">Before: <tspan id="r11.b"/></text> |
| 179 |
<text x="80" y="35">After: <tspan id="r11.a"/></text> |
| 180 |
</g> |
| 181 |
|
| 182 |
</g> |
| 183 |
</svg> |