Example: The Sierpinski Triangle


image of a circle
Your browser did not display the SVG image. It is showing a standard image as a fallback.

Source code:

Source of sierpinski-triangle.svg:Hide line numbers
01: <svg version="1.1" baseProfile="full"
02:      width="600px" height="600px" viewBox="0 0 600 600"
03:      xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
04: 
05: <defs>
06:    <polygon id="Triangle" points="0,0 600,0 0,600" fill="blue"/>   
07:    <g id="Image1">
08:       <use xlink:href="#Triangle" transform="scale(0.5)"/>
09:       <use xlink:href="#Triangle" transform="translate(300,0) scale(0.5)"/>
10:       <use xlink:href="#Triangle" transform="translate(0,300) scale(0.5)"/>
11:    </g>
12:    <g id="Image2">
13:       <use xlink:href="#Image1" transform="scale(0.5)"/>
14:       <use xlink:href="#Image1" transform="translate(300,0) scale(0.5)"/>
15:       <use xlink:href="#Image1" transform="translate(0,300) scale(0.5)"/>
16:    </g>
17:    <g id="Image3">
18:       <use xlink:href="#Image2" transform="scale(0.5)"/>
19:       <use xlink:href="#Image2" transform="translate(300,0) scale(0.5)"/>
20:       <use xlink:href="#Image2" transform="translate(0,300) scale(0.5)"/>
21:    </g>
22:    <g id="Image4">
23:       <use xlink:href="#Image3" transform="scale(0.5)"/>
24:       <use xlink:href="#Image3" transform="translate(300,0) scale(0.5)"/>
25:       <use xlink:href="#Image3" transform="translate(0,300) scale(0.5)"/>
26:    </g>
27:    <g id="Image5">
28:       <use xlink:href="#Image4" transform="scale(0.5)"/>
29:       <use xlink:href="#Image4" transform="translate(300,0) scale(0.5)"/>
30:       <use xlink:href="#Image4" transform="translate(0,300) scale(0.5)"/>
31:    </g>
32: </defs>
33: 
34: <use xlink:href="#Image5"/>
35: 
36: </svg>
37: 

This presentation is part of a SVG Tutorial for Mathematics Students.


© 2013 by W. Patrick Hooper. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. Creative Commons License Valid XHTML 1.0 Strict Valid CSS!