Skip to content

chrisladd/degas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Degas

Degas

Degas is an SVG drawing library.

Installation

npm i @cgl2/degas --save

Usage

createSVG(width, height)

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

SVGRef()

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

svgRef.svg()

Returns an SVG string representing all operations currently applied to the SVGRef

Kind: instance method of SVGRef

svgRef.clear()

. Clears any existing state from the current ref.

Kind: instance method of SVGRef

svgRef.setFillColor(color)

Sets the fill color.

Kind: instance method of SVGRef

Param Type Description
color string rgb, rgba, or hex color string

svgRef.setStrokeColor(color)

Sets the stroke color.

Kind: instance method of SVGRef

Param Type Description
color string rgb, rgba, or hex color string

svgRef.setStrokeWidth(width)

Sets the stroke width

Kind: instance method of SVGRef

Param Type Description
width number the width, in pixels, for the updated stroke.

svgRef.beginCircle(centerX, centerY, radius)

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

svgRef.endCircle()

Ends a circle.

Kind: instance method of SVGRef

svgRef.beginRect(x, y, width, height)

. 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

svgRef.endRect()

Ends the current rect

Kind: instance method of SVGRef

svgRef.beginText(x, y, text, options)

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.

svgRef.endText()

Ends the current SVGText node

Kind: instance method of SVGRef

svgRef.beginPath()

Begins a new SVGPath node

Kind: instance method of SVGRef

svgRef.moveToPoint(x, y)

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

svgRef.addLineToPoint(x, y)

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

svgRef.endPath()

Ends the current SVGPath node.

Kind: instance method of SVGRef

svgRef.end()

Ends the current element. This can be generically applied to all SVGRef subclasses.

Kind: instance method of SVGRef

About

Degas is an SVG drawing library.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published