See the 2022 Blockly Developer Summit site here.

Namespace: svgMath

Methods

getDocumentScroll

static

getDocumentScroll() returns Blockly.utils.Coordinate

Gets the document scroll distance as a coordinate object. Copied from Closure's goog.dom.getDocumentScroll.

Returns

non-null Blockly.utils.Coordinate Object with values 'x' and 'y'.

getInjectionDivXY

static

getInjectionDivXY(element) returns Blockly.utils.Coordinate

Return the coordinates of the top-left corner of this element relative to the div Blockly was injected into.

Parameter

element

Element

SVG element to find the coordinates of. If this is not a child of the div Blockly was injected into, the behaviour is undefined.

Value must not be null.

Returns

non-null Blockly.utils.Coordinate Object with .x and .y properties.

getRelativeXY

static

getRelativeXY(element) returns Blockly.utils.Coordinate

Return the coordinates of the top-left corner of this element relative to its parent. Only for SVG elements and children (e.g. rect, g, path).

Parameter

element

Element

SVG element to find the coordinates of.

Value must not be null.

Returns

non-null Blockly.utils.Coordinate Object with .x and .y properties.

getViewportBBox

package   static

getViewportBBox() returns Blockly.utils.Rect

Get the position of the current viewport in window coordinates. This takes scroll into account.

Returns

non-null Blockly.utils.Rect An object containing window width, height, and scroll position in window coordinates.

is3dSupported

static

is3dSupported() returns boolean

Check if 3D transforms are supported by adding an element and attempting to set the property.

Returns

boolean True if 3D transforms are supported.

screenToWsCoordinates

static

screenToWsCoordinates(ws, screenCoordinates) returns Blockly.utils.Coordinate

Converts screen coordinates to workspace coordinates.

Parameter

ws

Blockly.WorkspaceSvg

The workspace to find the coordinates on.

Value must not be null.

screenCoordinates

Blockly.utils.Coordinate

The screen coordinates to be converted to workspace coordinates

Value must not be null.

Returns

non-null Blockly.utils.Coordinate The workspace coordinates.

svgSize

static

svgSize(svg) returns Blockly.utils.Size

Returns the dimensions of the specified SVG image.

Parameter

svg

SVGElement

SVG image.

Value must not be null.

Deprecated
Use workspace.getCachedParentSvgSize. (2021 March 5)
Returns

non-null Blockly.utils.Size Contains width and height properties.