Blockly.blockRendering. Renderer
Constructor
Renderer
new Renderer(name)
The base class for a block renderer.
Parameter |
|
---|---|
name |
string The renderer name. |
- Implements
- Blockly.IRegistrable
Properties
constants_
non-null Blockly.blockRendering.ConstantProvider
constants_
non-null Blockly.blockRendering.ConstantProvider
name
string
The renderer name.
overrides
nullable Object
Rendering constant overrides, passed in through options.
Methods
createDom
createDom(svg, theme)
Create any DOM elements that this renderer needs.
Parameter |
|
---|---|
svg |
SVGElement The root of the workspace's SVG. Value must not be null. |
theme |
The workspace theme object. Value must not be null. |
dispose
dispose()
Dispose of this renderer. Delete all DOM elements that this renderer and its constants created.
getClassName
getClassName() returns string
Gets the class name that identifies this renderer.
- Returns
-
string
The CSS class name.
getConnectionPreviewMethod
getConnectionPreviewMethod(closest, local, topBlock) returns Blockly.InsertionMarkerManager.PREVIEW_TYPE
Chooses a connection preview method based on the available connection, the current dragged connection, and the block being dragged.
Parameter |
|
---|---|
closest |
The available connection. Value must not be null. |
local |
The connection currently being dragged. Value must not be null. |
topBlock |
The block currently being dragged. Value must not be null. |
- Returns
-
non-null Blockly.InsertionMarkerManager.PREVIEW_TYPE
The preview type to display.
getConstants
getConstants() returns Blockly.blockRendering.ConstantProvider
Get the current renderer's constant provider. We assume that when this is called, the renderer has already been initialized.
- Returns
-
non-null Blockly.blockRendering.ConstantProvider
The constant provider.
init
init(theme, opt_rendererOverrides)
Initialize the renderer.
Parameter |
|
---|---|
theme |
The workspace theme object. Value must not be null. |
opt_rendererOverrides |
Optional Object Rendering constant overrides. |
makeConstants_
makeConstants_() returns Blockly.blockRendering.ConstantProvider
Create a new instance of the renderer's constant provider.
- Returns
-
non-null Blockly.blockRendering.ConstantProvider
The constant provider.
makeDebugger_
makeDebugger_() returns Blockly.blockRendering.Debug
Create a new instance of the renderer's debugger.
- Returns
-
non-null Blockly.blockRendering.Debug
The renderer debugger.
makeDrawer_
makeDrawer_(block, info) returns Blockly.blockRendering.Drawer
Create a new instance of the renderer's drawer.
Parameter |
|
---|---|
block |
The block to render. Value must not be null. |
info |
Blockly.blockRendering.RenderInfo An object containing all information needed to render this block. Value must not be null. |
- Returns
-
non-null Blockly.blockRendering.Drawer
The drawer.
makeMarkerDrawer
makeMarkerDrawer(workspace, marker) returns Blockly.blockRendering.MarkerSvg
Create a new instance of the renderer's marker drawer.
Parameter |
|
---|---|
workspace |
The workspace the marker belongs to. Value must not be null. |
marker |
The marker. Value must not be null. |
- Returns
-
non-null Blockly.blockRendering.MarkerSvg
The object in charge of drawing the marker.
makePathObject
makePathObject(root, style) returns Blockly.blockRendering.IPathObject
Create a new instance of a renderer path object.
Parameter |
|
---|---|
root |
SVGElement The root SVG element. Value must not be null. |
style |
The style object to use for colouring. Value must not be null. |
- Returns
-
non-null Blockly.blockRendering.IPathObject
The renderer path object.
makeRenderInfo_
makeRenderInfo_(block) returns Blockly.blockRendering.RenderInfo
Create a new instance of the renderer's render info object.
Parameter |
|
---|---|
block |
The block to measure. Value must not be null. |
- Returns
-
non-null Blockly.blockRendering.RenderInfo
The render info object.
orphanCanConnectAtEnd
orphanCanConnectAtEnd(topBlock, orphanBlock, localType) returns boolean
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.
Parameter |
|
---|---|
topBlock |
The top block of the block clump we want to try and connect to. Value must not be null. |
orphanBlock |
The orphan block that wants to find a home. Value must not be null. |
localType |
number The type of the connection being dragged. |
- Returns
-
boolean
Whether there is a home for the orphan or not.
refreshDom
refreshDom(svg, theme)
Refresh the renderer after a theme change.
Parameter |
|
---|---|
svg |
SVGElement The root of the workspace's SVG. Value must not be null. |
theme |
The workspace theme object. Value must not be null. |
render
render(block)
Render the block.
Parameter |
|
---|---|
block |
The block to render. Value must not be null. |
shouldHighlightConnection
shouldHighlightConnection(_conn) returns boolean
Determine whether or not to highlight a connection.
Parameter |
|
---|---|
_conn |
The connection to determine whether or not to highlight. |
- Returns
-
boolean
True if we should highlight the connection.