Skip to content

editorGlobalsOrnamentSvgCreator

Class: OrnamentSvgCreator

Hierarchy

  • OrnamentSvgCreator

Index

Methods

Methods

Static Private _createSvg

_createSvg(content: string, height: number, width: number, viewBox: string): string

Defined in src/modules/kyub.core.plateOrnaments/src/OrnamentGenerator/OrnamentSvgCreator.ts:122

Parameters:

Name Type Default
content string -
height number -
width number -
viewBox string ""

Returns: string


Static Private _createTextSvg

_createTextSvg(text: string): string

Defined in src/modules/kyub.core.plateOrnaments/src/OrnamentGenerator/OrnamentSvgCreator.ts:111

Creates an svg with a single text element inside. size depends on the text content but for reasonable size (single word), it will fit into 5cm

Parameters:

Name Type Description
text string should be short and fit into one line

Returns: string


Static Private _getFillForPolygon

_getFillForPolygon(darkness: number): string

Defined in src/modules/kyub.core.plateOrnaments/src/OrnamentGenerator/OrnamentSvgCreator.ts:91

Computes the greyscale color for the given darkness of a polygon.

Parameters:

Name Type Description
darkness number the darkness of the polygon between 0 and 1.

Returns: string

an rgb color greyscale representation of the darkness.


Static Private _getPolygonString

_getPolygonString(points: Vector2[], isCutout: boolean, darkness?: number): string

Defined in src/modules/kyub.core.plateOrnaments/src/OrnamentGenerator/OrnamentSvgCreator.ts:80

Generates an SVG string for a single polygon.

Parameters:

Name Type Description
points Vector2[] the points of the polygon.
isCutout boolean wether the polygon is a cutout or not
darkness? number the darkness of the polygon if it is a cutout as a number between 0 and 1.

Returns: string

an SVG polygon string.


Static Private _kyubCoordinatesToSvgCoordinates

_kyubCoordinatesToSvgCoordinates(points: Vector2[]): Vector2[]

Defined in src/modules/kyub.core.plateOrnaments/src/OrnamentGenerator/OrnamentSvgCreator.ts:102

Tries to estimate the mm size by assuming a 72 dpi conversion factor. {@see Drawable#getPhysicalSize()} Also inverts the y coordinates to convert the coordinates to svg coordinates. This operate on points as reference so the original input will change as well!

Parameters:

Name Type
points Vector2[]

Returns: Vector2[]


Static Private _toQrSvg

_toQrSvg(url: string): string

Defined in src/modules/kyub.core.plateOrnaments/src/OrnamentGenerator/OrnamentSvgCreator.ts:137

Parameters:

Name Type
url string

Returns: string


Static generateFullNameSVG

generateFullNameSVG(): string

Defined in src/modules/kyub.core.plateOrnaments/src/OrnamentGenerator/OrnamentSvgCreator.ts:20

Returns: string


Static generateModelLinkQRSVG

generateModelLinkQRSVG(): string

Defined in src/modules/kyub.core.plateOrnaments/src/OrnamentGenerator/OrnamentSvgCreator.ts:15

Returns: string


Static generatePolygonsSVG

generatePolygonsSVG(polygons: Array‹object›, aabb: AABB): string

Defined in src/modules/kyub.core.plateOrnaments/src/OrnamentGenerator/OrnamentSvgCreator.ts:43

Generates an SVG for a list of polygons and its aabb. The resulting SVG will have a symmetrical viewbox around the center.

Parameters:

Name Type Description
polygons Array‹object› An array of polygon objects that each have a list of points, a boolean that states if it is a cutout or not and an optional darkness each. - Cutouts have isCutout = true and no darkness. - Engravings have isCutout = true and a darkness between 0 and 1.
aabb AABB The aabb of all the polygons. This is used for calculating the size of the viewbox.

Returns: string

an svg that represents the given polygons.


Static generateTextSVG

generateTextSVG(text: string): string

Defined in src/modules/kyub.core.plateOrnaments/src/OrnamentGenerator/OrnamentSvgCreator.ts:31

Parameters:

Name Type
text string

Returns: string


Static generateUserNameSVG

generateUserNameSVG(): string

Defined in src/modules/kyub.core.plateOrnaments/src/OrnamentGenerator/OrnamentSvgCreator.ts:26

Returns: string


Static generateUserProfileLinkQRSVG

generateUserProfileLinkQRSVG(): string

Defined in src/modules/kyub.core.plateOrnaments/src/OrnamentGenerator/OrnamentSvgCreator.ts:10

Returns: string