Skip to main content

Class: Renderer

Defined in: packages/blockly/core/renderers/thrasos/renderer.ts:20

The thrasos renderer. This is a more modern take on the legacy geras renderer.

Thrasos is the ancient Greek spirit of boldness.

Extends​

Properties index​

PropertyDescription
constants_The renderer's constant provider.
name-
overridesRendering constant overrides, passed in through options.

Methods index​

MethodDescription
getClassNameGets the class name that identifies this renderer.
initInitialize the renderer.
refreshDomRefresh the renderer after a theme change.
disposeDispose of this renderer. Delete all DOM elements that this renderer and its constants created.
makeConstants_Create a new instance of the renderer's constant provider.
makeDrawer_Create a new instance of the renderer's drawer.
makePathObjectCreate a new instance of a renderer path object.
getConstantsGet the current renderer's constant provider. We assume that when this is called, the renderer has already been initialized.
shouldHighlightConnectionDetermine whether or not to highlight a connection.
orphanCanConnectAtEndChecks if an orphaned block can connect to the "end" of the topBlock's block-clump. If the clump is a row the end is the last input. If the clump is a stack, the end is the last next connection. If the clump is neither, then this returns false.
makeRenderInfo_Create a new instance of the renderer's render info object.

Constructors​

Constructor​

new Renderer(name): Renderer;

Defined in: packages/blockly/core/renderers/thrasos/renderer.ts:24

Parameters​

ParameterTypeDescription
namestringThe renderer name.

Returns​

Renderer

Overrides​

Renderer.constructor

Properties​

constants_​

protected constants_: ConstantProvider;

Defined in: packages/blockly/core/renderers/common/renderer.ts:27

The renderer's constant provider.

Inherited from​

Renderer.constants_


name​

protected name: string;

Defined in: packages/blockly/core/renderers/common/renderer.ts:29

Inherited from​

Renderer.name


overrides​

protected overrides: object | null = null;

Defined in: packages/blockly/core/renderers/common/renderer.ts:34

Rendering constant overrides, passed in through options.

Inherited from​

Renderer.overrides

Methods​

getClassName()​

getClassName(): string;

Defined in: packages/blockly/core/renderers/common/renderer.ts:48

Gets the class name that identifies this renderer.

Returns​

string

The CSS class name.

Inherited from​

Renderer.getClassName


init()​

init(theme, opt_rendererOverrides?): void;

Defined in: packages/blockly/core/renderers/common/renderer.ts:58

Initialize the renderer.

Parameters​

ParameterTypeDescription
themeThemeThe workspace theme object.
opt_rendererOverrides?{ [rendererConstant: string]: any; }Rendering constant overrides.

Returns​

void

Inherited from​

Renderer.init


refreshDom()​

refreshDom(
svg,
theme,
injectionDivIfIsParent?
): void;

Defined in: packages/blockly/core/renderers/common/renderer.ts:108

Refresh the renderer after a theme change.

Parameters​

ParameterTypeDescription
svgSVGElementThe root of the workspace's SVG.
themeThemeThe workspace theme object.
injectionDivIfIsParent?HTMLElementThe div containing the parent workspace and all related workspaces and block containers, if this renderer is for the parent workspace. CSS variables representing SVG patterns will be scoped to this container. Child workspaces should not override the CSS variables created by the parent and thus do not need access to the injection div.

Returns​

void

Inherited from​

Renderer.refreshDom


dispose()​

dispose(): void;

Defined in: packages/blockly/core/renderers/common/renderer.ts:130

Dispose of this renderer. Delete all DOM elements that this renderer and its constants created.

Returns​

void

Inherited from​

Renderer.dispose


makeConstants_()​

protected makeConstants_(): ConstantProvider;

Defined in: packages/blockly/core/renderers/common/renderer.ts:141

Create a new instance of the renderer's constant provider.

Returns​

ConstantProvider

The constant provider.

Inherited from​

Renderer.makeConstants_


makeDrawer_()​

protected makeDrawer_(block, info): Drawer;

Defined in: packages/blockly/core/renderers/common/renderer.ts:163

Create a new instance of the renderer's drawer.

Parameters​

ParameterTypeDescription
blockBlockSvgThe block to render.
infoRenderInfoAn object containing all information needed to render this block.

Returns​

Drawer

The drawer.

Inherited from​

Renderer.makeDrawer_


makePathObject()​

makePathObject(root, style): IPathObject;

Defined in: packages/blockly/core/renderers/common/renderer.ts:174

Create a new instance of a renderer path object.

Parameters​

ParameterTypeDescription
rootSVGElementThe root SVG element.
styleBlockStyleThe style object to use for colouring.

Returns​

IPathObject

The renderer path object.

Inherited from​

Renderer.makePathObject


getConstants()​

getConstants(): ConstantProvider;

Defined in: packages/blockly/core/renderers/common/renderer.ts:184

Get the current renderer's constant provider. We assume that when this is called, the renderer has already been initialized.

Returns​

ConstantProvider

The constant provider.

Inherited from​

Renderer.getConstants


shouldHighlightConnection()​

shouldHighlightConnection(connection): boolean;

Defined in: packages/blockly/core/renderers/common/renderer.ts:194

Determine whether or not to highlight a connection.

Parameters​

ParameterTypeDescription
connectionRenderedConnectionThe connection to determine whether or not to highlight.

Returns​

boolean

True if we should highlight the connection.

Inherited from​

Renderer.shouldHighlightConnection


orphanCanConnectAtEnd()​

protected orphanCanConnectAtEnd(
topBlock,
orphanBlock,
localType
): boolean;

Defined in: packages/blockly/core/renderers/common/renderer.ts:210

Checks if an orphaned block can connect to the "end" of the topBlock's block-clump. If the clump is a row the end is the last input. If the clump is a stack, the end is the last next connection. If the clump is neither, then this returns false.

Parameters​

ParameterTypeDescription
topBlockBlockSvgThe top block of the block clump we want to try and connect to.
orphanBlockBlockSvgThe orphan block that wants to find a home.
localTypenumberThe type of the connection being dragged.

Returns​

boolean

Whether there is a home for the orphan or not.

Inherited from​

Renderer.orphanCanConnectAtEnd


makeRenderInfo_()​

protected makeRenderInfo_(block): RenderInfo;

Defined in: packages/blockly/core/renderers/thrasos/renderer.ts:34

Create a new instance of the renderer's render info object.

Parameters​

ParameterTypeDescription
blockBlockSvgThe block to measure.

Returns​

RenderInfo

The render info object.

Overrides​

Renderer.makeRenderInfo_