Home Reference Source Repository
import CanvasDrawer from 'minimap/lib/mixins/canvas-drawer.js'
public class | source

CanvasDrawer

Extends:

mixto~Mixin → CanvasDrawer

The CanvasDrawer mixin is responsible for the rendering of a Minimap in a canvas element.

This mixin is injected in the MinimapElement prototype, so all these methods are available on any MinimapElement instance.

Member Summary

Public Members
public

backLayer: CanvasLayer

The canvas layer for decorations below the text.

public

frontLayer: CanvasLayer

The canvas layer for decorations above the text.

public

tokensLayer: CanvasLayer

The main canvas layer where lines are rendered.

Method Summary

Public Methods
public

Returns the background color for the passed-in decoration object.

public

Returns the default text color for an editor content.

public

getFrontCanvas(): HTMLCanvasElement

Returns the uppermost canvas in the MinimapElement.

public

Returns the opacity value to use when rendering the Minimap text.

public

Returns the text color for the passed-in token object.

public

Initializes the canvas elements needed to perform the Minimap rendering.

public

Performs an update of the rendered Minimap based on the changes registered in the instance.

Public Members

public backLayer: CanvasLayer source

The canvas layer for decorations below the text.

public frontLayer: CanvasLayer source

The canvas layer for decorations above the text.

public tokensLayer: CanvasLayer source

The main canvas layer where lines are rendered.

Public Methods

public getDecorationColor(decoration: Decoration): string source

Returns the background color for the passed-in decoration object.

The color value is read from the DOM by creating a node structure that match the decoration scope property unless the decoration provides its own color property.

Params:

NameTypeAttributeDescription
decoration Decoration

the decoration to get the color for

Return:

string

the CSS color for the provided decoration

public getDefaultColor(): string source

Returns the default text color for an editor content.

The color value is directly read from the TextEditorView computed styles.

Return:

string

a CSS color

public getFrontCanvas(): HTMLCanvasElement source

Returns the uppermost canvas in the MinimapElement.

Return:

HTMLCanvasElement

the html canvas element

public getTextOpacity(): Number source

Returns the opacity value to use when rendering the Minimap text.

Return:

Number

the text opacity value

public getTokenColor(token: Object): string source

Returns the text color for the passed-in token object.

The color value is read from the DOM by creating a node structure that match the token scope property.

Params:

NameTypeAttributeDescription
token Object

a TextEditor token

Return:

string

the CSS color for the provided token

public initializeCanvas() source

Initializes the canvas elements needed to perform the Minimap rendering.

public updateCanvas() source

Performs an update of the rendered Minimap based on the changes registered in the instance.