Blockly.blockRendering. MarkerSvg
Class for a marker.
Constructor
MarkerSvg
new MarkerSvg(workspace, constants, marker)
Parameter |
|
---|---|
workspace |
The workspace the marker belongs to. Value must not be null. |
constants |
The constants for the renderer. Value must not be null. |
marker |
The marker to draw. Value must not be null. |
Properties
colour_
string
The colour of the marker.
constants_
Blockly.blockRendering.ConstantProvider
The constants necessary to draw the marker.
currentMarkerSvg
Element
The current SVG element for the marker.
markerBlock_
nullable SVGPathElement
markerInput_
nullable SVGPathElement
markerSvg_
SVGGElement
The root SVG group containing the marker.
markerSvgLine_
nullable SVGRectElement
markerSvgRect_
nullable SVGRectElement
svgGroup_
nullable SVGGElement
Methods
applyColour_
applyColour_(_curNode)
Apply the marker's colour.
Parameter |
|
---|---|
_curNode |
The node that we want to draw the marker for. Value must not be null. |
createDom
createDom() returns SVGElement
Create the DOM element for the marker.
- Returns
-
non-null SVGElement
The marker controls SVG group.
createDomInternal_
createDomInternal_() returns Element
Create the marker SVG.
- Returns
-
Element
The SVG node created.
dispose
dispose()
Dispose of this marker.
draw
draw(oldNode, curNode)
Update the marker.
Parameter |
|
---|---|
oldNode |
The previous node the marker was on or null. |
curNode |
The node that we want to draw the marker for. |
getBlinkProperties_
getBlinkProperties_() returns Object
Get the properties to make a marker blink.
- Returns
-
non-null Object
The object holding attributes to make the marker blink.
getMarker
getMarker() returns Blockly.Marker
Get the marker.
- Returns
-
non-null Blockly.Marker
The marker to draw for.
getSvgRoot
getSvgRoot() returns SVGElement
Return the root node of the SVG or null if none exists.
- Returns
-
SVGElement
The root SVG node.
hide
hide()
Hide the marker.
isCursor
isCursor() returns boolean
True if the marker should be drawn as a cursor, false otherwise. A cursor is drawn as a flashing line. A marker is drawn as a solid line.
- Returns
-
boolean
True if the marker is a cursor, false otherwise.
positionBlock_
positionBlock_(width, markerOffset, markerHeight)
Position the marker for a block. Displays an outline of the top half of a rectangle around a block.
Parameter |
|
---|---|
width |
number The width of the block. |
markerOffset |
number The extra padding for around the block. |
markerHeight |
number The height of the marker. |
positionInput_
positionInput_(connection)
Position the marker for an input connection. Displays a filled in puzzle piece.
Parameter |
|
---|---|
connection |
The connection to position marker around. Value must not be null. |
positionLine_
positionLine_(x, y, width)
Move and show the marker at the specified coordinate in workspace units. Displays a horizontal line.
Parameter |
|
---|---|
x |
number The new x, in workspace units. |
y |
number The new y, in workspace units. |
width |
number The new width, in workspace units. |
positionOutput_
positionOutput_(width, height, connectionShape)
Position the marker for an output connection. Displays a puzzle outline and the top and bottom path.
Parameter |
|
---|---|
width |
number The width of the block. |
height |
number The height of the block. |
connectionShape |
Object The shape object for the connection. Value must not be null. |
positionPrevious_
positionPrevious_(width, markerOffset, markerHeight, connectionShape)
Position the marker for a previous connection. Displays a half rectangle with a notch in the top to represent the previous connection.
Parameter |
|
---|---|
width |
number The width of the block. |
markerOffset |
number The offset of the marker from around the block. |
markerHeight |
number The height of the marker. |
connectionShape |
Object The shape object for the connection. Value must not be null. |
positionRect_
positionRect_(x, y, width, height)
Move and show the marker at the specified coordinate in workspace units. Displays a filled in rectangle.
Parameter |
|
---|---|
x |
number The new x, in workspace units. |
y |
number The new y, in workspace units. |
width |
number The new width, in workspace units. |
height |
number The new height, in workspace units. |
setParent_
setParent_(newParent)
Attaches the SVG root of the marker to the SVG group of the parent.
Parameter |
|
---|---|
newParent |
The workspace, field, or block that the marker SVG element should be attached to. Value must not be null. |
showAtLocation_
showAtLocation_(curNode)
Update the marker's visible state based on the type of curNode..
Parameter |
|
---|---|
curNode |
The node that we want to draw the marker for. Value must not be null. |
showCurrent_
showCurrent_()
Show the current marker.
showWithBlock_
showWithBlock_(curNode)
Position and display the marker for a block.
Parameter |
|
---|---|
curNode |
The node to draw the marker for. Value must not be null. |
showWithCoordinates_
showWithCoordinates_(curNode)
Position and display the marker for a workspace coordinate. This is a horizontal line.
Parameter |
|
---|---|
curNode |
The node to draw the marker for. Value must not be null. |
showWithField_
showWithField_(curNode)
Position and display the marker for a field. This is a box around the field.
Parameter |
|
---|---|
curNode |
The node to draw the marker for. Value must not be null. |
showWithInput_
showWithInput_(curNode)
Position and display the marker for an input. This is a puzzle piece.
Parameter |
|
---|---|
curNode |
The node to draw the marker for. Value must not be null. |
showWithNext_
showWithNext_(curNode)
Position and display the marker for a next connection. This is a horizontal line.
Parameter |
|
---|---|
curNode |
The node to draw the marker for. Value must not be null. |
showWithOutput_
showWithOutput_(curNode)
Position and display the marker for an output connection.
Parameter |
|
---|---|
curNode |
The node to draw the marker for. Value must not be null. |
showWithPrevious_
showWithPrevious_(curNode)
Position and display the marker for a previous connection.
Parameter |
|
---|---|
curNode |
The node to draw the marker for. Value must not be null. |
showWithStack_
showWithStack_(curNode)
Position and display the marker for a stack. This is a box with extra padding around the entire stack of blocks.
Parameter |
|
---|---|
curNode |
The node to draw the marker for. Value must not be null. |