non-scaling-stroke-006.html (2148B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>non-scaling-stroke with scaling from viewBox and preserveAspectRatio=none</title> 4 <link rel="help" href="https://svgwg.org/svg2-draft/painting.html#PaintingVectorEffects"> 5 <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com"> 6 <link rel="match" href="non-scaling-stroke-006-ref.html"> 7 <style> 8 svg { 9 border: 1px solid black; 10 } 11 svg.wide { 12 width: 150px; 13 height: 100px; 14 } 15 svg.thin { 16 width: 100px; 17 height: 150px; 18 } 19 rect { 20 fill: transparent; 21 stroke: blue; 22 stroke-width: 10px; 23 vector-effect: non-scaling-stroke; 24 } 25 </style> 26 <!-- These only vary in the viewBox's size. This variability shouldn't result 27 in them rendering any differently from each other, because the rect 28 geometry attributes are all relative to the viewBox size, and we have a 29 non-scaling stroke which should be the same thickness regardless of 30 viewBox-imposed scaling factor. --> 31 <svg class="wide" preserveAspectRatio="none" viewBox="0 0 10 10"> 32 <rect x="10%" y="20%" width="50%" height="60%"></rect> 33 </svg> 34 <svg class="wide" preserveAspectRatio="none" viewBox="0 0 50 50"> 35 <rect x="10%" y="20%" width="50%" height="60%"></rect> 36 </svg> 37 <svg class="wide" preserveAspectRatio="none" viewBox="0 0 100 100"> 38 <rect x="10%" y="20%" width="50%" height="60%"></rect> 39 </svg> 40 <svg class="wide" preserveAspectRatio="none" viewBox="0 0 500 500"> 41 <rect x="10%" y="20%" width="50%" height="60%"></rect> 42 </svg> 43 <br> 44 <!-- Same setup as above, but now with a tall-and-thin css box. These 45 should all render the same as each other:--> 46 <svg class="thin" preserveAspectRatio="none" viewBox="0 0 10 10"> 47 <rect x="10%" y="20%" width="50%" height="60%"></rect> 48 </svg> 49 <svg class="thin" preserveAspectRatio="none" viewBox="0 0 50 50"> 50 <rect x="10%" y="20%" width="50%" height="60%"></rect> 51 </svg> 52 <svg class="thin" preserveAspectRatio="none" viewBox="0 0 100 100"> 53 <rect x="10%" y="20%" width="50%" height="60%"></rect> 54 </svg> 55 <svg class="thin" preserveAspectRatio="none" viewBox="0 0 500 500"> 56 <rect x="10%" y="20%" width="50%" height="60%"></rect> 57 </svg>