ImageAspectRatio.svg 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
  3. "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
  4. <svg width="450px" height="300px" version="1.1"
  5. xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  6. <desc>Example PreserveAspectRatio - illustrates preserveAspectRatio attribute</desc>
  7. <rect x="1" y="1" width="448" height="298"
  8. fill="none" stroke="blue"/>
  9. <g font-size="9">
  10. <text x="10" y="30">SVG to fit</text>
  11. <g transform="translate(20,40)"><image xlink:href="Snowman.png" preserveAspectRatio="xMinYMin meet" width="29" height="39" /></g>
  12. <text x="10" y="110">Viewport 1</text>
  13. <g transform="translate(10,120)"><rect x='.5' y='.5' width='49' height='29'
  14. fill='none' stroke='blue'/></g>
  15. <text x="10" y="180">Viewport 2</text>
  16. <g transform="translate(20,190)"><rect x='.5' y='.5' width='29' height='59'
  17. fill='none' stroke='blue'/></g>
  18. <g id="meet-group-1" transform="translate(100, 60)">
  19. <text x="0" y="-30">--------------- meet ---------------</text>
  20. <g><text y="-10">xMin*</text><rect x='.5' y='.5' width='49' height='29'
  21. fill='none' stroke='blue'/>
  22. <image xlink:href="Snowman.png" preserveAspectRatio="xMinYMin meet" width="50" height="30" /></g>
  23. <g transform="translate(70,0)"><text y="-10">xMid*</text><rect x='.5' y='.5' width='49' height='29'
  24. fill='none' stroke='blue'/>
  25. <image xlink:href="Snowman.png" preserveAspectRatio="xMidYMid meet" width="50" height="30" /></g>
  26. <g transform="translate(0,70)"><text y="-10">xMax*</text><rect x='.5' y='.5' width='49' height='29'
  27. fill='none' stroke='blue'/>
  28. <image xlink:href="Snowman.png" preserveAspectRatio="xMaxYMax meet" width="50" height="30" /></g>
  29. </g>
  30. <g id="meet-group-2" transform="translate(250, 60)">
  31. <text x="0" y="-30">---------- meet ----------</text>
  32. <g><text y="-10">*YMin</text><rect x='.5' y='.5' width='29' height='59'
  33. fill='none' stroke='blue'/>
  34. <image xlink:href="Snowman.png" preserveAspectRatio="xMinYMin meet" width="30" height="60" /></g>
  35. <g transform="translate(50, 0)"><text y="-10">*YMid</text><rect x='.5' y='.5' width='29' height='59'
  36. fill='none' stroke='blue'/>
  37. <image xlink:href="Snowman.png" preserveAspectRatio="xMidYMid meet" width="30" height="60" /></g>
  38. <g transform="translate(100, 0)"><text y="-10">*YMax</text><rect x='.5' y='.5' width='29' height='59'
  39. fill='none' stroke='blue'/>
  40. <image xlink:href="Snowman.png" preserveAspectRatio="xMaxYMax meet" width="30" height="60" /></g>
  41. </g>
  42. <g id="slice-group-1" transform="translate(100, 220)">
  43. <text x="0" y="-30">---------- slice ----------</text>
  44. <g><text y="-10">xMin*</text><rect x='.5' y='.5' width='29' height='59'
  45. fill='none' stroke='blue'/>
  46. <image xlink:href="Snowman.png" preserveAspectRatio="xMinYMin slice" width="30" height="60" /></g>
  47. <g transform="translate(50,0)"><text y="-10">xMid*</text><rect x='.5' y='.5' width='29' height='59'
  48. fill='none' stroke='blue'/>
  49. <image xlink:href="Snowman.png" preserveAspectRatio="xMidYMid slice" width="30" height="60" /></g>
  50. <g transform="translate(100,0)"><text y="-10">xMax*</text><rect x='.5' y='.5' width='29' height='59'
  51. fill='none' stroke='blue'/>
  52. <image xlink:href="Snowman.png" preserveAspectRatio="xMaxYMax slice" width="30" height="60" /></g>
  53. </g>
  54. <g id="slice-group-2" transform="translate(250, 220)">
  55. <text x="0" y="-30">--------------- slice ---------------</text>
  56. <g><text y="-10">*YMin</text><rect x='.5' y='.5' width='49' height='29'
  57. fill='none' stroke='blue'/>
  58. <image xlink:href="Snowman.png" preserveAspectRatio="xMinYMin slice" width="50" height="30" /></g>
  59. <g transform="translate(70,0)"><text y="-10">*YMid</text><rect x='.5' y='.5' width='49' height='29'
  60. fill='none' stroke='blue'/>
  61. <image xlink:href="Snowman.png" preserveAspectRatio="xMidYMid slice" width="50" height="30" /></g>
  62. <g transform="translate(140,0)"><text y="-10">*YMax</text><rect x='.5' y='.5' width='49' height='29'
  63. fill='none' stroke='blue'/>
  64. <image xlink:href="Snowman.png" preserveAspectRatio="xMaxYMax slice" width="50" height="30" /></g>
  65. </g>
  66. </g>
  67. </svg>