Category:SVG simplification by cloning
Cloning is a mighty instrument for generation of repeated objects (SVG fragments) with reduced effort.
The SVG "use" element can be provided with any required transformation attribute, as translate, scale, rotate, skew.
Only for cloning the xmlns:xlink namespace definition is required
A useful description can be found at de:Wikibook:Transformations.
Especially rotations will lead to very odd coordinate values, while clone-transfomations avoid that. For very simple objects with no need for high accuracy cloning can be avoided, see Das Pentagramm als manuelle SVG-Grafik (de); but when exactness and perfect symmetry is desired, only cloning can care for that easily.
Accurate construction
[edit]The following code generates a perfectly symmetrical five-pointed star (like ):
<?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" xmlns:xlink="http://www.w3.org/1999/xlink"> <path id="c" fill="#FF0" d="m72,100 28-85 28,85"/> <use xlink:href="#c" transform="rotate(72 100,100)"/> <use xlink:href="#c" transform="rotate(144 100,100)"/> <use xlink:href="#c" transform="rotate(216 100,100)"/> <use xlink:href="#c" transform="rotate(288 100,100)"/> </svg>
(with three instead of four transformations when cascaded)
This is a lot of coding instructions for such a simple structure.
The same picture is drawn much shorter by the path
<?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" width="200" height="200"> <path fill="#FF0" d="m51,168 49-152 49,152-129-94h160"/> </svg>
bearing suffient exactness.
Cascaded cloning
[edit]Large numbers of repeated objects (SVG fragments) can be generated with repetitive use of cloning; it is possible always to double the count with each use. The number increases in a geometric progression, first doubling an object to two instances, then 4, 8, 16, 32, 64, 128, 256, 1024... (a typical example)
This can be very helpful to generate e.g. fractal structures. This category contains selected examples where the method of nested cloning helped to create multiple occurences of objects.
Cloning for symmetry check (mirroring)
[edit]During development of hand edited SVG, temporary cloning may be a help for checking whether an object is really accurat.
As an example, the mirrored red path shows that the black path is correctly drawn:
<?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" width="260" xmlns:xlink="http://www.w3.org/1999/xlink" height="300"> <path fill="none" stroke="#000" stroke-width="5" d="m5,5h250l-10,10v220c0,69-99,30-115,60-16-30-115,9-115-59V15z"/> <path fill="none" stroke="#F00" stroke-width="2" id="r" d="m5,5h250l-10,10v220c0,69-99,30-115,60"/> <use xlink:href="#r" transform="matrix(-1,0,0,1,260,0)"/> </svg>
Another example for mirroring is e.g. the code for file BSicon CSTRag.svg.
Examples
[edit]Haigerloch sketch
[edit]The first version did not use any cloning, each element of the sketch is drawn for itself.
- Every one of the 14 cubes is coded in a primitive manner like
<g id="g2510" style="fill:#000000;stroke:none" /> <g id="g2534" style="fill:#ff0000;stroke:none" /> <g transform="matrix(0.1491359,0,0,0.1406997,91.406269,63.033462)" id="g3498"> <path d="M -177.89576,71.34841 L -109.02632,117.34031 L -64.211774, 48.135815 L -133.08122,2.1439186 L -177.89576,71.34841" id="path3500" style="fill:#acacac;fill-opacity:1;stroke:#ff0000;stroke-width: 0.60093284;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0" /> <path style="fill:#575757;fill-opacity:1;fill-rule:evenodd;stroke: #00ff00;stroke-width:0.60093284;stroke-linecap:butt;stroke-linejoin: miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M -201.72291,84.7638 L -178.09589,71.367102 L -133.11653, 2.1071298 L -156.94923,15.622398 L -201.72291,84.7638 z" id="path3502" /> <path style="fill:#7f7f7f;fill-opacity:1;fill-rule:evenodd;stroke: #0000ff;stroke-width:0.60093284;stroke-linecap:butt;stroke-linejoin: miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M -201.72291,84.7638 L -132.73915,130.70408 L -108.9643, 117.27815 L -178.03805,71.277778 L -201.72291,84.7638 z" id="path3504" /> </g> </g> </g>
needing about 1300 bytes, repeated 13 times with other transformation for the other cubes.
The second version draws this cube only once, with
<g stroke="#000" stroke-linejoin="bevel" stroke-width=".1"> <path fill="#AAA" d="m29,15-17-11-11,17 17,11"/> <path fill="#777" d="m29,15-17-11 6-3 17,11"/> <path fill="#555" d="m29,15-11,17 6-3 11-17z"/> </g>
needing about 212 bytes. All further occurrrencies are cloned, in a cascading manner.
- There are 46 ellipses in the first drawing, every one of them is coded like
<path sodipodi:type="arc" style="opacity:1;fill:#575757;fill-opacity:1;stroke-width:2.5; stroke-miterlimit:4;stroke-dasharray:5, 5;stroke-dashoffset:0" id="path3359" sodipodi:cx="17.296402" sodipodi:cy="5.2840905" sodipodi:rx="0.72443181" sodipodi:ry="0.69128788" d="M 18.020834,5.2840905 A 0.72443181,0.69128788 0 1 1 16.57197, 5.2840905 A 0.72443181,0.69128788 0 1 1 18.020834,5.2840905 z" transform="matrix(-0.9662745,0,0,-0.6369863,117.49973,129.66582)" />
The simplified drawing omits these ellipses, replacing them by the linecap='round' attribute, which seems quite enough accuracy for this simple sketch.
Media in category "SVG simplification by cloning"
The following 116 files are in this category, out of 116 total.
-
11 of hearts.svg 208 × 303; 1 KB
-
1o5dots.svg 64 × 12; 466 bytes
-
4-regular matchstick graph with 60 vertices.svg 344 × 344; 618 bytes
-
5proc s.svg 450 × 450; 1 KB
-
5whiteStar.svg 151 × 140; 423 bytes
-
6whiteStar.svg 151 × 150; 394 bytes
-
7-segment.svg 960 × 800; 2 KB
-
7사단.svg 500 × 500; 595 bytes
-
Abe no Seimei Hann (No background and black color drawing).svg 688 × 688; 424 bytes
-
Aegishjalmr.svg 500 × 500; 913 bytes
-
Alternattiva Demokratika.svg 512 × 512; 495 bytes
-
Ashoka Chakra.svg 500 × 500; 709 bytes
-
Asian Games Gold medal blank.svg 300 × 300; 603 bytes
-
Astigmatismus-Sonne.svg 130 × 130; 646 bytes
-
Auroville symbol.svg 98 × 98; 470 bytes
-
Bandeira do Tocantins.svg 512 × 358; 505 bytes
-
Black Sun.svg 500 × 500; 824 bytes
-
Blason-gueules-escarboucle-or.svg 600 × 660; 2 KB
-
Blason-hermine-plein.svg 600 × 660; 1 KB
-
BlueGear3.svg 212 × 212; 672 bytes
-
Cantor dust clone.svg 729 × 729; 621 bytes
-
Cantor dust.svg 783 × 783; 622 bytes
-
Card back 02.svg 208 × 303; 446 bytes
-
Centered hexagonal = 1 + 6triangular.svg 576 × 496; 648 bytes
-
Chemistrybondstar.svg 622 × 594; 434 bytes
-
Chinese-army Wuhan flag (1911-1928) 18 dots.svg 780 × 520; 899 bytes
-
Chinese-army Wuhan flag (1911-1928) 19 dots.svg 780 × 520; 935 bytes
-
Civil Flag of Serbia variant.svg 675 × 450; 209 bytes
-
Clock 06-00.svg 500 × 500; 702 bytes
-
Clock 09-18.svg 500 × 500; 750 bytes
-
COA Christiern af Oeland.svg 550 × 600; 566 bytes
-
Coa Illustration Elements Plant Chrysanthemum.svg 300 × 300; 511 bytes
-
Color square cm.svg 3,000 × 3,000; 2 KB
-
DistribEixampleBCN.svg 602 × 446; 666 bytes
-
DrSuper super super super.svg 18,143 × 15,712; 1 KB
-
DST begin.svg 250 × 250; 719 bytes
-
Emblem of Daejeon.svg 220 × 220; 395 bytes
-
End CEST.svg 250 × 250; 942 bytes
-
EPP-EVP-Logo-German-2011.svg 794 × 387; 9 KB
-
Eye icon 04.svg 728 × 253; 586 bytes
-
F22 1 1.svg 600 × 600; 619 bytes
-
Flag of Belarusian Steamship Line.svg 300 × 150; 307 bytes
-
Flag of Biaroza-Kartuskaja.svg 600 × 300; 1 KB
-
Flag of Des Moines, Iowa.svg 650 × 325; 475 bytes
-
Flag of Mahiloŭ.svg 900 × 450; 7 KB
-
Flag of Orocovis.svg 600 × 400; 677 bytes
-
Flag of the Chechen Republic.svg 450 × 300; 2 KB
-
Flag of the U.S..svg 512 × 269; 635 bytes
-
Flag of Uruguay.svg 512 × 341; 5 KB
-
Flag Thai Admiral of the Fleet.svg 500 × 500; 3 KB
-
Forschungsreaktor Haigerloch Gitter.svg 512 × 471; 842 bytes
-
Frame-01.svg 724 × 724; 591 bytes
-
Gennji kuruma (No background and Black color drawing).svg 688 × 688; 615 bytes
-
GER-FRA 2016-07-07.svg 512 × 708; 3 KB
-
Hachiyounitsuki.svg 864 × 864; 433 bytes
-
Hdp middenvlak.svg 302 × 332; 406 bytes
-
Hex board 11x11.svg 470 × 296; 2 KB
-
HexaFlake 5th Iteration Center.svg 720 × 720; 1 KB
-
DEU Hoechst am Main COA.svg 625 × 643; 1 KB
-
Honma clans family crest circle (No background and Black color drawing).svg 688 × 688; 549 bytes
-
How to use icon.svg 40 × 37; 482 bytes
-
Icons8 flat services.svg 48 × 48; 534 bytes
-
Inflorescences Spike Kwiatostan Kłos.svg 100 × 500; 532 bytes
-
Japanese Crest Kagome.svg 688 × 688; 721 bytes
-
Japanese Crest Kawarijuunihiashi.svg 688 × 688; 497 bytes
-
Kanji - 興x4.svg 360 × 360; 448 bytes
-
Kawarijuunihiashi (No background and Black color drawing).svg 688 × 688; 478 bytes
-
Korean Traffic sign (Rotary - Mandatory sign).svg 400 × 400; 563 bytes
-
Kuomintang Emblem.svg 600 × 600; 457 bytes
-
Kuyo.svg 250 × 250; 407 bytes
-
Kyokkou (No background and Black color drawing).svg 688 × 688; 703 bytes
-
Kätzchen (inflorescence).svg 190 × 360; 724 bytes
-
La Neuveville-coat of arms.svg 512 × 612; 1 KB
-
Legenda zabytek techniki.svg 128 × 128; 531 bytes
-
Logo Grand Site de France sans texte.svg 360 × 416; 361 bytes
-
Croix-de-Malte.svg 600 × 660; 856 bytes
-
MFrey LED Matrix.svg 999 × 999; 659 bytes
-
Migi mitsudomoe.svg 688 × 688; 349 bytes
-
Mitu Yama (No background and Black color drawing).svg 688 × 688; 330 bytes
-
National Cockade of Uruguay (civilian).svg 600 × 600; 833 bytes
-
Nibelle - Composition de la population.svg 256 × 256; 626 bytes
-
Noto Emoji KitKat 1f505.svg 128 × 128; 454 bytes
-
Ohene aniwa.svg 750 × 750; 589 bytes
-
Oota Kikyou (No background and Black color drawing).svg 688 × 688; 517 bytes
-
Op-art-4-sided-spiral-tunnel-8.svg 768 × 768; 766 bytes
-
Optical illusion 03 pg.svg 1,740 × 1,150; 744 bytes
-
Optical-illusion-diamonds-C.svg 800 × 600; 778 bytes
-
P-pentomino Symmetry.svg 375 × 200; 482 bytes
-
Peroxisome.svg 620 × 620; 4 KB
-
Polygon-032VC.svg 1,050 × 1,050; 517 bytes
-
Portuguese EU presidency 2021.svg 460 × 460; 644 bytes
-
Rio de Janeiro 2016 Summer Olympics bid icon (blue) 00s.svg 450 × 450; 568 bytes
-
Rio de Janeiro 2016 Summer Olympics bid icon (orange) 00.svg 450 × 450; 553 bytes
-
Rio de Janeiro 2016 Summer Olympics bid icon-s.svg 450 × 450; 554 bytes
-
ROK recycling symbol.svg 220 × 230; 372 bytes
-
Russia-2C Flag of Border Guard district commanders 2008.svg 900 × 600; 958 bytes
-
Sept cercles dans un.svg 420 × 420; 511 bytes
-
Septimani iuniores shield pattern.svg 500 × 500; 877 bytes
-
Shield Trinity (blank).svg 400 × 360; 490 bytes
-
SierpinskiTriangle.svg 744 × 644; 2 KB
-
Simple wave pattern.svg 1,500 × 1,120; 532 bytes
-
Sol de Mayo-Bandera de Uruguay.svg 767 × 767; 2 KB
-
Stroke pattern.svg 700 × 700; 656 bytes
-
Teilchenmodell Feststoff.svg 600 × 270; 1 KB
-
Teilchenmodell Gas.svg 700 × 490; 1 KB
-
Template-protection-shackle-brackets.svg 512 × 512; 559 bytes
-
Tor Snowflake logo.svg 60 × 60; 372 bytes
-
TriSquare36.svg 512 × 256; 373 bytes
-
United States Gay Pride flag.svg 1,234 × 708; 887 bytes
-
Very good resistance to light.svg 250 × 250; 453 bytes
-
Wakatsuki ju roku hachiju ken kiku (No background and Black color drawing).svg 688 × 688; 481 bytes
-
Wappen Friedensdorf.svg 544 × 614; 659 bytes
-
Wikipedia progress icon.svg 451 × 451; 685 bytes
-
Yatsuhiashi (No background and Black color drawing).svg 688 × 688; 438 bytes
-
Êzîdxan Protection Force.svg 900 × 600; 589 bytes
-
大日本帝國陸軍 軍旗.svg 376 × 259; 485 bytes