| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>067 SVG geometry and paint</title>
- <style>
- body { background: #ffffff; color: #202020; font-family: sans-serif;
- margin: 12px; font-size: 18px; }
- .pane { float: left; width: 200px; height: 140px; margin-right: 20px;
- background: #eeeeee; }
- .icon { fill: currentColor; color: #008000; }
- #result { clear: both; background: #ffc8c8; color: #000000; padding: 8px;
- margin-top: 12px; }
- </style>
- </head>
- <body>
- <h1>067 — SVG geometry and paint</h1>
- <p>Filled curves, arcs, circles, groups with transforms, <use> of a
- symbol, fill-rule, strokes and gradient paint. Expected: a blue disc, a
- red ring with a hole, a green chevron, a black stroked zigzag and a
- mid-blue square (the average of its gradient stops).</p>
- <div class="pane">
- <svg width="200" height="140" viewBox="0 0 200 140">
- <defs>
- <linearGradient id="g1"><stop offset="0" stop-color="#0000ff"/>
- <stop offset="1" style="stop-color:#000080"/></linearGradient>
- <symbol id="chev" viewBox="0 0 24 24">
- <path d="M9 5l7 7-7 7-1.4-1.4L13.2 12 7.6 6.4z"/>
- </symbol>
- </defs>
- <circle id="disc" cx="35" cy="35" r="25" fill="#2040c0"/>
- <g fill="#c02020" transform="translate(100 35)">
- <path id="ring" fill-rule="evenodd"
- d="M0-25a25 25 0 1 1 0 50a25 25 0 1 1 0-50zM0-12a12 12 0 1 0 0 24a12 12 0 1 0 0-24z"/>
- </g>
- <use class="icon" href="#chev" x="140" y="10" width="50" height="50"/>
- <polyline id="zig" points="10,120 40,80 70,120 100,80" fill="none"
- stroke="#000000" stroke-width="4"/>
- <rect id="grad" x="130" y="80" width="50" height="50" fill="url(#g1)"/>
- </svg>
- </div>
- <p><span id="c1" style="color:#2040c0">blue</span>
- <span id="c2" style="color:#c02020">red</span></p>
- <div id="result">checking...</div>
- <script>
- setTimeout(function () {
- function F(id, p) { return getComputedStyle(document.getElementById(id))[p]; }
- var disc = F('disc', 'fill'), ring = F('ring', 'fill'),
- zig = F('zig', 'fill'), zs = F('zig', 'stroke'),
- bg = F('disc', 'backgroundColor');
- var ok = disc === F('c1', 'color') && ring === F('c2', 'color') &&
- zig === 'none' && zs === 'rgb(0, 0, 0)' &&
- bg === 'rgba(0, 0, 0, 0)';
- var r = document.getElementById('result');
- if (r) {
- r.style.background = ok ? '#c8f0c8' : '#ffc8c8';
- r.textContent = (ok ? 'SVGPAINT-OK ' : 'SVGPAINT-FAIL ') + disc + ' ' +
- ring + ' ' + zig + '/' + zs + ' bg=' + bg;
- }
- }, 300);
- </script>
- </body>
- </html>
|