Constructor
new SVGBuilder()
Initialises a new SVGBuilder instance with an empty SVG element.
- Source:
Classes
Members
svg :SVGSVGElement
The SVG element being built.
Type:
- SVGSVGElement
- Source:
Methods
addShape(shapeElement) → {SVGElement}
Adds a shape or element to the SVG element.
Parameters:
Name | Type | Description |
---|---|---|
shapeElement |
SVGElement | The SVG element to be added. |
- Source:
Returns:
- The current instance for chaining.
- Type
- SVGElement
build() → {SVGSVGElement}
Finalises and returns the constructed SVG element.
- Source:
Returns:
The built SVG element.
- Type
- SVGSVGElement
clear()
Clears all child elements from the SVG element.
- Source:
setBackgroundColor(colour) → {SVGElement}
Sets the background colour of the SVG element using CSS.
Parameters:
Name | Type | Description |
---|---|---|
colour |
string | The background colour (e.g., "red" or "#ff0000"). |
- Source:
Returns:
The current instance for chaining.
- Type
- SVGElement
setHeight(height) → {SVGBuilder}
Sets the height of the SVG element.
Parameters:
Name | Type | Description |
---|---|---|
height |
string | number | The height of the SVG (e.g., "100px" or 100). |
- Source:
Returns:
The current instance for chaining.
- Type
- SVGBuilder
setViewBox(viewBox) → {SVGElement}
Sets the viewBox attribute of the SVG element.
Parameters:
Name | Type | Description |
---|---|---|
viewBox |
string | The viewBox value (e.g., "0 0 100 100"). |
- Source:
Returns:
The current instance for chaining.
- Type
- SVGElement
setWidth(width) → {SVGBuilder}
Sets the width of the SVG element.
Parameters:
Name | Type | Description |
---|---|---|
width |
string | number | The width of the SVG (e.g., "100px" or 100). |
- Source:
Returns:
The current instance for chaining.
- Type
- SVGBuilder