Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
SVG construction example
Last updated at 2:41 pm UTC on 5 May 2017
Execute the follwing code in a workspace to create a SVG file.

 | doc elem elem2 elem3 |
 
   doc := XMLDocument new.
   elem := XMLElement
               named: #svg
               attributes:
                 (Dictionary new
				at: 'xmlns' put: 'http://www.w3.org/2000/svg';
                      at: 'width' put: '14cm';
                      at: 'height' put: '8cm';
                      at: 'viewbox' put: '0 0 1200 400';
                    yourself).
  elem2 :=  XMLElement
               named: #rect
               attributes:
                 (Dictionary new
                      at: 'fill' put: 'green';
                      at: 'height' put: '200';
                      at: 'width' put: '400';
                      at: 'x' put: '50';
                      at: 'y' put: '50';
                      at: 'stroke' put: 'red';
                      at: 'stroke-width' put: '6';
                    yourself).
 elem3 :=  XMLElement
               named: #text
               attributes:
                 (Dictionary new
                      at: 'font-size' put: '80';
                      at: 'stroke' put: 'none';
                      at: 'fill' put: 'white';
                      at: 'x' put: '80';
                      at: 'y' put: '150';
                    yourself).
  elem3 addElement: (XMLStringNode string: 'Squeak').

  elem addElement: elem2;
        addElement: elem3.
  doc addElement: elem.
  doc version: '1.0'.
  doc printOn: (FileDirectory default newFileNamed: '../../firstImage.svg')



Result

 <?xml  version="1.0" encoding="UTF-8" ?>
 <svg height="8cm" viewbox="0 0 1200 400" width="14cm" xmlns="http://www.w3.org/2000/svg">
 <rect fill="green" height="200" stroke="red" stroke-width="6" width="400" x="50" y="50"/> 
 <text fill="white" font-size="80" stroke="none" x="80" y="150">Squeak</text></svg>

 
  
 Squeak