Category:SVG simplification by viewBox
The SVG viewBox
attribute enables to use another coordinate system.
Two of its advantages are helpful to simplify:
- scaling to another size may allow the use of shorter coordinate values, and/or of the implied-valued
stroke-width="1"
; example: . - shifting an often needed point (e.g. the center of circles, or transform-rotations) to
x=y=0
avoids the repeated declaration of that point; example: .
Explanation: The implied values for a not declared viewBox are "0 0 <width> <height>"
.viewBox="-200 -150 600 400"
means: the image is drawn with a width of 600 and a height of 400; the origin where x=y=0 is 200 px right of the image's left border (-200 ≤ x ≤ 400), and 150 px below of the top border (-150 ≤ y ≤ 250).
During the process of simplification of an existing SVG drawing, it may be useful to scale the display to another size.
This is easy to maintain with a temporary change of e.g.
width="50" height="60"
to width="1000" height="1200" viewBox="0 0 50 60"
, without altering the width/height-relation.[clarification needed]
- To get a reasonable unit system for definitions, a 2nd
svg
-element may be introduced, e.g. within the document <svg … width="10cm" height="12cm" viewBox="3 4 15 18" … >
by inserting somewhere<svg x="3" y="4" width="15" height="18" viewBox="0 0 360 432">
to edit within the real dimensions 360 × 432 of the graphic.
To get the real values an existing SVG drawing with a transforming viewBox, a transform statement can be used. To overwrite e.g.
<svg ... width="w1" height="h1" viewBox="tx ty w2 h2">
, after a transform instruction
<g transform="translate(tx ty)scale(w2/w1 h2/h1)">
the viewBox transformations are reset till the corresponding </g>
.
See the example Transform example.svg
Recommended sizes: The document size (width and height) determines the default dimensions of its image.
While a size too small may hide picture details, a size too large requires zoom out activities to see the entire image.
- Values not exceeding a width of 600 and a height of 400 are a good choice
Media in category "SVG simplification by viewBox"
The following 33 files are in this category, out of 33 total.
-
10x10 checkered board transparent.svg 500 × 500; 255 bytes
-
1330px Rainbow flag 12 colours black bordered.svg 1,330 × 665; 634 bytes
-
Alternattiva Demokratika.svg 512 × 512; 495 bytes
-
Astigmatismus-Sonne.svg 130 × 130; 646 bytes
-
Bandera del Comtat d'Empúries.svg 900 × 600; 216 bytes
-
British Air force fin flash WWI.svg 600 × 600; 278 bytes
-
Centered hexagonal = 1 + 6triangular.svg 576 × 496; 648 bytes
-
Chess Board.svg 810 × 810; 229 bytes
-
Commons logo icon.svg 640 × 860; 598 bytes
-
Construction sheet of Flag of the People's Republic of China.svg 900 × 600; 1 KB
-
DST begin.svg 250 × 250; 719 bytes
-
EBU Colorbars HD.svg 1,920 × 1,080; 393 bytes
-
EBU Colorbars.svg 768 × 576; 405 bytes
-
End CEST.svg 250 × 250; 942 bytes
-
Esoteric Taijitu.svg 468 × 468; 290 bytes
-
F1 yellow flag with red stripes.svg 512 × 384; 153 bytes
-
Flag of Qatar.svg 1,400 × 550; 310 bytes
-
Flag of Tere-Kholsky District.svg 1,200 × 800; 1 KB
-
Flag of the Puerto Rican Independence Party.svg 800 × 500; 191 bytes
-
Germany Gay flag.svg 600 × 360; 512 bytes
-
L-tromino-dissection.svg 700 × 700; 429 bytes
-
Nationalist air force black roundel.svg 602 × 602; 165 bytes
-
Polygon-032VC.svg 1,050 × 1,050; 517 bytes
-
Roundel of Switzerland.svg 600 × 600; 189 bytes
-
Roundel of the Slovenian Air Force.svg 600 × 600; 229 bytes
-
Russian 9 segment digits.svg 164 × 25; 320 bytes
-
Simpler Ellipse Circle.svg 860 × 460; 226 bytes
-
Stomachion canonique.SVG 122 × 122; 473 bytes
-
Svg example6s.svg 1,000 × 600; 312 bytes
-
Urantia three-concentric-blue-circles-on-white symbol.svg 424 × 424; 197 bytes
-
Venn Diagram ABCD.svg 600 × 600; 580 bytes
-
Volga White Army.svg 300 × 300; 195 bytes
-
Wang tiles.svg 500 × 130; 1 KB