Degas is an SVG drawing library.
npm i @cgl2/degas --save
Creates a new instance of SVGRef, given a width and height.
Kind: global function
See: #SVGRef for more on drawing operations.
Param | Type | Description |
---|---|---|
width | number |
the total needed width for the canvas |
height | number |
the total needed height for the canvas |
SVG Ref is the base class for all SVG drawing.
You obtain an SVGRef instance by calling the method degas.createSVG(width, height)
. From there, you call the methods of the returned object to add drawing operations, moving to points, createing lines, circles and rectangles, and drawing text within the bounds of the width and height passed in initially.
When you've finished drawing, call the method svg()
to apply these changes, and return an SVG string representing your drawing operations.
Kind: global function
Returns an SVG string representing all operations currently applied to the SVGRef
Kind: instance method of SVGRef
. Clears any existing state from the current ref.
Kind: instance method of SVGRef
Sets the fill color.
Kind: instance method of SVGRef
Param | Type | Description |
---|---|---|
color | string |
rgb, rgba, or hex color string |
Sets the stroke color.
Kind: instance method of SVGRef
Param | Type | Description |
---|---|---|
color | string |
rgb, rgba, or hex color string |
Sets the stroke width
Kind: instance method of SVGRef
Param | Type | Description |
---|---|---|
width | number |
the width, in pixels, for the updated stroke. |
Begins a new SVGCircle element.
Kind: instance method of SVGRef
Param | Type | Description |
---|---|---|
centerX | number |
the x center |
centerY | number |
the y center |
radius | number |
the radius of the circle |
Ends a circle.
Kind: instance method of SVGRef
. Begins a new SVGRect element
Kind: instance method of SVGRef
Param | Type | Description |
---|---|---|
x | number |
the X coordinate |
y | number |
the Y coordinate |
width | number |
the width for the rect |
height | number |
the height for the rect |
Ends the current rect
Kind: instance method of SVGRef
Begins a a new SVGText node
Kind: instance method of SVGRef
Param | Type | Description |
---|---|---|
x | number |
the X coordinate |
y | number |
the Y coordinate |
text | string |
the contents of the text node |
options | Object |
options to control display. Valid options include fontFamily, fontSize, fontWeight, and textAnchor. All are tied to their CSS counterparts. |
Ends the current SVGText node
Kind: instance method of SVGRef
Begins a new SVGPath node
Kind: instance method of SVGRef
Moves the current node to a given point. Applicable to SVGPath.
Kind: instance method of SVGRef
Param | Type | Description |
---|---|---|
x | number |
the X coordinate |
y | number |
the Y coordinate |
Adds a line to a given point. Applicable to SVGPath.
Kind: instance method of SVGRef
Param | Type | Description |
---|---|---|
x | number |
the X coordinate |
y | number |
the Y coordinate |
Ends the current SVGPath node.
Kind: instance method of SVGRef
Ends the current element. This can be generically applied to all SVGRef subclasses.
Kind: instance method of SVGRef