util.svg
Hierarchy
util.svg.baseutil.svg.base3dutil.svgRequires
Files
SVG Utility
Parameters
- rootElem : Element
- rootAttr : Object
Methods
Defined By
Instance methods implements svg image file download used by canvas ...implements svg image file download used by canvas
Parameters
- name : Object
return custom element ...return custom element
Parameters
- name : String
- attr : Object
- callback : Function
Returns
exportCanvas( canvas )convert svg image to canvas ...convert svg image to canvas
Parameters
- canvas : Canvas
getTextSize( text ) : Objectcaculate real pixel size of text element ...caculate real pixel size of text element
Parameters
- text : String
target text
Returns
- Object
- width : Integer
text element's width (px)
- height : Integer
text element's height(px)
size( ) : Objectif arguments.length is 2, set attribute width, height to root element
if arguments.length is zero, return svg size ...if arguments.length is 2, set attribute width, height to root element
if arguments.length is zero, return svg size
Returns
- Object
implements svg image file download used by canvas ...
implements svg image file download used by canvas
Parameters
- name : Object
return custom element ...
return custom element
Parameters
- name : String
- attr : Object
- callback : Function
Returns
exportCanvas( canvas )
convert svg image to canvas ...
convert svg image to canvas
Parameters
- canvas : Canvas
getTextSize( text ) : Object
caculate real pixel size of text element ...
caculate real pixel size of text element
Parameters
- text : String
target text
Returns
- Object
- width : Integer
text element's width (px)
- height : Integer
text element's height(px)
- width : Integer
size( ) : Object
if arguments.length is 2, set attribute width, height to root element
if arguments.length is zero, return svg size ...
if arguments.length is 2, set attribute width, height to root element if arguments.length is zero, return svg size
Returns
- Object
Defined By
Static methods create nested elements by json
SVG.create({
tag : "pattern",
attr : { x : 0, y : 0, width : 20, height : 2...create nested elements by json
SVG.create({
tag : "pattern",
attr : { x : 0, y : 0, width : 20, height : 20 },
children : [
{ tag : 'rect', attr : {width : 20, height : 20, fill : 'black', stroke : 'blue', 'stroke-width' : 2 } ,
{ tag : 'rect', attr : {width : 20, height : 20, fill : 'black', stroke : 'blue', 'stroke-width' : 2 } ,
{ tag : 'rect', attr : {width : 20, height : 20, fill : 'black', stroke : 'blue', 'stroke-width' : 2 } ,
{ tag : 'rect', attr : {width : 20, height : 20, fill : 'black', stroke : 'blue', 'stroke-width' : 2 }
]
});
is equals to
<pattern x="0" y="0" width="20" height="20">
<rect width="20" height="20" fill="black" stroke="blue" stroke-width="2" />
<rect width="20" height="20" fill="black" stroke="blue" stroke-width="2" />
<rect width="20" height="20" fill="black" stroke="blue" stroke-width="2" />
<rect width="20" height="20" fill="black" stroke="blue" stroke-width="2" />
</pattern>
Parameters
- obj : Object
json literal
- type : String
svg element name
- attr : Object
svg element's attributes
- children : Array (optional)
svg element's children
Defaults to: null
Returns
create nested elements by json
SVG.create({
tag : "pattern",
attr : { x : 0, y : 0, width : 20, height : 2...
create nested elements by json
SVG.create({
tag : "pattern",
attr : { x : 0, y : 0, width : 20, height : 20 },
children : [
{ tag : 'rect', attr : {width : 20, height : 20, fill : 'black', stroke : 'blue', 'stroke-width' : 2 } ,
{ tag : 'rect', attr : {width : 20, height : 20, fill : 'black', stroke : 'blue', 'stroke-width' : 2 } ,
{ tag : 'rect', attr : {width : 20, height : 20, fill : 'black', stroke : 'blue', 'stroke-width' : 2 } ,
{ tag : 'rect', attr : {width : 20, height : 20, fill : 'black', stroke : 'blue', 'stroke-width' : 2 }
]
});
is equals to
<pattern x="0" y="0" width="20" height="20">
<rect width="20" height="20" fill="black" stroke="blue" stroke-width="2" />
<rect width="20" height="20" fill="black" stroke="blue" stroke-width="2" />
<rect width="20" height="20" fill="black" stroke="blue" stroke-width="2" />
<rect width="20" height="20" fill="black" stroke="blue" stroke-width="2" />
</pattern>
Parameters
- obj : Object
json literal
- type : String
svg element name
- attr : Object
svg element's attributes
- children : Array (optional)
svg element's children
Defaults to:
null
- type : String