ShapeLibrary constructor.
One or more shape sets to include in the library.
Optional
options: ShapeLibraryOptionsOptions for the library.
Also we keep a list of all compiled icons, but here we've stripped the category out. we use this in the event that some data doesn't have a category. then it's a lucky dip. the user gets the first icon with a matching id.
map of compiled icons. the keys of this map are set IDs. The values are maps of icon ids to compiled definitions.
Private
_applyGets a compiled version of the given shape, creating and caching it if it does not already exist.
Shape type.
Optional
category: stringCategory to use. Defaults to the ID of the first category provided in the shape list.
Returns a tag definition that can be used in a Surface's tags
declaration. Note that this method
returns an object containing the tag's implementation, but not the name of the tag. You can call the tag whatever you like.
Optional
strokeWidth: numberOptional
includeLabel: booleanGets the template for the given shape type in the given set. If no template is resolved then we return DEFAULT_TEMPLATE (and log the issue to the console).
Shape type
Name of set. If not provided, the value of DEFAULT_SET
is used as the set name.
Render the given data with the appropriate template. A fill
value is set on the resulting element,
and the vector-effect
attribute is set to 'non scaling stroke', ie. when the shape is scaled due to
the element dimensions differing from the viewbox, the stroke does not change.
Optional
strokeWidth: numberStroke width to use. This is passed to the underlying template and is taken into account by the shape template (or at least, it should be, because it has a bearing on the quality of the result)
Optional
typeParameter: stringOptional key to use to look up an object's type. When not provided, the typeParameter
from the class is used.
Optional
categoryParameter: stringOptional key to use to look up an object's category. When not provided, the categoryParameter
from the class is used.
Render a label element for the given data - an SVG text element.
Data to extract label from
Optional
labelProperty: stringName of the property that provides the label. Defaults to "label"
Optional
strokeWidth: stringOptional stroke width, defaults to 0.25px
Default ShapeLibrary implementation. Use one of these to manage a set of shapes for rendering into your vertices and/or for rendering as a palette from which the user can drag new objects.