Skip to main content

Class: Decorations

core/Decorations.Decorations

Constructors

constructor

new Decorations(graph)

Parameters

NameType
graphGraph

Defined in

core/Decorations.ts:45

Properties

decorationChangeListeners

Private decorationChangeListeners: DecorationChangeListener[] = []

Defined in

core/Decorations.ts:41


decorationMap

decorationMap: DecorationMap

Defined in

core/Decorations.ts:38


decorations

decorations: NamedDecoration[]

Defined in

core/Decorations.ts:37


disposables

Private disposables: Disposable[] = []

Defined in

core/Decorations.ts:42


extensionContext

Private extensionContext: ExtensionContext

Defined in

core/Decorations.ts:43


hatStyleMap

Private hatStyleMap: Record<HatStyleName, HatStyle>

Defined in

core/Decorations.ts:39


hatStyleNames

hatStyleNames: HatStyleName[]

Defined in

core/Decorations.ts:40

Methods

constructColoredSvgDataUri

Private constructColoredSvgDataUri(originalSvg, color): Uri

Parameters

NameType
originalSvgstring
colorstring

Returns

Uri

Defined in

core/Decorations.ts:241


constructDecorations

Private constructDecorations(fontMeasurements): void

Parameters

NameType
fontMeasurementsFontMeasurements

Returns

void

Defined in

core/Decorations.ts:95


constructHatStyleMap

Private constructHatStyleMap(): void

Returns

void

Defined in

core/Decorations.ts:177


destroyDecorations

Private destroyDecorations(): void

Returns

void

Defined in

core/Decorations.ts:83


dispose

dispose(): void

Returns

void

Defined in

core/Decorations.ts:344


getViewBoxDimensions

Private getViewBoxDimensions(rawSvg): Object

Parameters

NameType
rawSvgstring

Returns

Object

NameType
originalViewBoxHeightnumber
originalViewBoxWidthnumber

Defined in

core/Decorations.ts:328


init

init(extensionContext): Promise<void>

Parameters

NameType
extensionContextExtensionContext

Returns

Promise<void>

Defined in

core/Decorations.ts:62


processSvg

Private processSvg(fontMeasurements, shape, scaleFactor, hatVerticalOffsetEm): Object

Creates an SVG from the hat SVG that pads, offsets and scales it to end up in the right size / place relative to the character it will be placed over. This image may or may not be helpful.

Parameters

NameTypeDescription
fontMeasurementsFontMeasurementsInfo about the user's font
shape"default" | "ex" | "fox" | "wing" | "hole" | "frame" | "curve" | "eye" | "play" | "bolt" | "crosshairs"The hat shape to process
scaleFactornumberHow much to scale the hat
hatVerticalOffsetEmnumberHow far off top of characters should hats be

Returns

Object

An object with the new SVG and its measurements

NameType
svgstring
svgHeightPxnumber
svgWidthPxnumber

Defined in

core/Decorations.ts:269


recomputeDecorationStyles

Private recomputeDecorationStyles(): Promise<void>

Returns

Promise<void>

Defined in

core/Decorations.ts:89


registerDecorationChangeListener

registerDecorationChangeListener(listener): () => void

Register to be notified when decoration styles are updated, for example if the user enables a new hat style

Parameters

NameTypeDescription
listenerDecorationChangeListenerA function to be called when decoration styles are updated

Returns

fn

A function that can be called to unsubscribe from notifications

▸ (): void

Returns

void

Defined in

core/Decorations.ts:75