File: stroke-dashes-hit-at-high-scale.svg

package info (click to toggle)
firefox 144.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,637,504 kB
  • sloc: cpp: 7,576,692; javascript: 6,430,831; ansic: 3,748,119; python: 1,398,978; xml: 628,810; asm: 438,679; java: 186,194; sh: 63,212; makefile: 19,159; objc: 13,086; perl: 12,986; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (27 lines) | stat: -rw-r--r-- 1,426 bytes parent folder | download | duplicates (26)
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
<svg id="svg" xmlns="http://www.w3.org/2000/svg" xmlns:h="http://www.w3.org/1999/xhtml" viewBox="0 0 36 36" width="600" height="600">
  <title>Strokes w/dashes are properly hit-tested, even at large scale factors</title>
  <h:script src="/resources/testharness.js"/>
  <h:script src="/resources/testharnessreport.js"/>
  <metadata>
    <h:link rel="help" href="https://svgwg.org/svg2-draft/shapes.html#CircleElement"/>
    <h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#StrokeProperties"/>
  </metadata>
  <circle id="circle" cx="6" cy="10" r="5" stroke="blue" stroke-width="1" stroke-dasharray="10 21.4159" fill="none"/>
  <script>
  <![CDATA[
    test(function() {
      let svg = document.getElementById("svg");
      let circle = document.getElementById("circle");
      let hitTest = function(x, y) {
        return document.elementFromPoint(
                x * svg.width.baseVal.value / svg.viewBox.baseVal.width,
                y * svg.height.baseVal.value / svg.viewBox.baseVal.height);
      }
      assert_equals(hitTest(11, 10), circle, "hit-test the beginning of the dash (t=0)");
      assert_equals(hitTest(8.70, 14.21), circle, "hit-test the middle of the dash (t=5)");
      assert_equals(hitTest(4.10, 14.63), circle, "hit-test the end of the dash (t=9.8)");
      assert_equals(hitTest(3.74, 14.46), svg, "hit-test past the end of the dash (t=10.2)");
    });
  ]]>
  </script>
</svg>