Tidy up of viewBox code

This commit is contained in:
Curtis Hard
2022-06-12 17:26:07 +01:00
parent 3efea34d76
commit df7ceb3df1
8 changed files with 230 additions and 201 deletions
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" width="432" height="270" viewBox="0 .5 16 10" stroke-dasharray="1">
<circle fill="#0F0" r="99"/>
<path stroke="#00F" d="m1,1h15m0,2H1m0,2h15m0,2H1m0,2h15"/>
<path stroke="#F00" d="m0,2h15m0,2H0m0,2h15m0,2H0m0,2h15"/>
</svg>

After

Width:  |  Height:  |  Size: 285 B

@@ -0,0 +1,84 @@
<svg viewBox="-1 -1 162 92" xmlns="http://www.w3.org/2000/svg">
<defs>
<path id="smiley" d="M50,10 A40,40,1,1,1,50,90 A40,40,1,1,1,50,10 M30,40 Q36,35,42,40 M58,40 Q64,35,70,40 M30,60 Q50,75,70,60 Q50,75,30,60" />
<style>
path {
fill: yellow;
stroke: black;
stroke-width: 8px;
stroke-linecap: round;
stroke-linejoin: round;
}
</style>
</defs>
<!-- (width>height) meet -->
<svg viewBox="0 0 100 100" width="20" height="10"
preserveAspectRatio="xMidYMid meet" x="0" y="0">
<use href="#smiley" />
</svg>
<svg viewBox="0 0 100 100" width="20" height="10"
preserveAspectRatio="xMinYMid meet" x="25" y="0">
<use href="#smiley" />
</svg>
<svg viewBox="0 0 100 100" width="20" height="10"
preserveAspectRatio="xMaxYMid meet" x="50" y="0">
<use href="#smiley" />
</svg>
<!-- (width>height) slice -->
<svg viewBox="0 0 100 100" width="20" height="10"
preserveAspectRatio="xMidYMin slice" x="0" y="15">
<use href="#smiley" />
</svg>
<svg viewBox="0 0 100 100" width="20" height="10"
preserveAspectRatio="xMidYMid slice" x="25" y="15">
<use href="#smiley" />
</svg>
<svg viewBox="0 0 100 100" width="20" height="10"
preserveAspectRatio="xMidYMax slice" x="50" y="15">
<use href="#smiley" />
</svg>
<!-- (width<height) meet -->
<svg viewBox="0 0 100 100" width="10" height="25"
preserveAspectRatio="xMidYMin meet" x="75" y="0">
<use href="#smiley" />
</svg>
<svg viewBox="0 0 100 100" width="10" height="25"
preserveAspectRatio="xMidYMid meet" x="90" y="0">
<use href="#smiley" />
</svg>
<svg viewBox="0 0 100 100" width="10" height="25"
preserveAspectRatio="xMidYMax meet" x="105" y="0">
<use href="#smiley" />
</svg>
<!-- (width<height) slice -->
<svg viewBox="0 0 100 100" width="10" height="25"
preserveAspectRatio="xMinYMid slice" x="120" y="0">
<use href="#smiley" />
</svg>
<svg viewBox="0 0 100 100" width="10" height="25"
preserveAspectRatio="xMidYMid slice" x="135" y="0">
<use href="#smiley" />
</svg>
<svg viewBox="0 0 100 100" width="10" height="25"
preserveAspectRatio="xMaxYMid slice" x="150" y="0">
<use href="#smiley" />
</svg>
<!-- none -->
<svg viewBox="0 0 100 100" width="160" height="60"
preserveAspectRatio="none" x="0" y="30">
<use href="#smiley" />
</svg>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

+5
View File
@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 135 74">
<path d="M9,0h117v24h9v50h-135v-50h9z" fill="#d60000"/>
<path d="M12,3h111v24h8v44h-15v-16l-58,3l-21-1l-18-2v16h-15v-44h15v15l12,3l4,2h20l39-2h21v-17l-11,8l-92-17" fill="#eb1a22"/>
<path d="M15-1h17v9l40-23l9,19h-8v4l-4-4h-11l-12,10l8,11l25-9l25,20l10,4l1,5h-21l-2-3l-2,1l-13-11l-22,15l6,27h-17v-3l-3-1l-6-23l-4-2l-12-19h-4l2,2v4l-3-2v7l-7-3v-16l12-5l-3-5z" fill="#FFF"/>
</svg>

After

Width:  |  Height:  |  Size: 447 B