Svg-Draw
Small js svg editor without dependencies.
Supported element types:
- rect
- ellipse
- circle
- line
- polygon
- polyline
- group
- text
Element properties:
type: ElementType; // rect, ellipse, circle, line, polygon, polyline, group
domId?: string; // dom element id
class?: string; // dom element class
x?: number; // not used for groups
y?: number; // not used for groups
width?: number; // not used for groups
height?: number; // not used for groups
points?: string; // used for polygon and polyline
children?: Partial[]; // used for group
fill?: string;
stroke?: string;
text?: string; // used for text
fontSize?: number; // used for text
Actions
addElement - create new element and add it to svg
setElementParameters - set element parameters
addElementParameters - adds values for element parameters (used for x, y, width and height)
removeElement - remove element from svg
Example
; const svgContainer = document;if !svgContainer throw 'svgContainer not found';if !svgContainer instanceof SVGSVGElement throw 'svgContainer are not instanse of SVGSVGElement'; const svgEditor = ;const svgAddElement = ;const svgSetElementParameters = ;const svgAddElementParameters = ;const svgRemoveElement = ; const rect = ; ; ; ;
Advanced exapmle in example\example.ts