Skip to content

@fabwcie/free-drawing / utils/frame

utils/frame ​

Classes ​

Frame ​

Defined in: packages/free-drawing/src/utils/frame.ts:32

Frame: area with a title above it, its shapes are moved with it and cut at its edges. Group of its box, its title and a group of its shapes (cut), its box is its client rect (transformer, selection, snapping, export): title and shapes out of it are not counted.

Extends

  • Group

Constructors ​

Constructor ​

new Frame(config?): Frame

Defined in: node_modules/konva/lib/Node.d.ts:124

Parameters
config? ​

GroupConfig

Returns

Frame

Inherited from

Group.constructor

Properties ​

frame ​

readonly frame: true = true

Defined in: packages/free-drawing/src/utils/frame.ts:34

Not a group of shapes (types)

Methods ​

getClientRect() ​

getClientRect(config?): IRect

Defined in: packages/free-drawing/src/utils/frame.ts:42

Box of the frame, title and shapes out of it not counted (transformer, selection, snapping, export), drawn rect for konva drawing (cache)

Parameters
config? ​

GetClientRectConfig = {}

konva options: relativeTo (absolute by default), skipTransform (own coordinates)

Returns

IRect

box of the frame, rect of everything drawn for konva drawing

Overrides

Group.getClientRect

Variables ​

frameParts ​

const frameParts: object

Defined in: packages/free-drawing/src/utils/frame.ts:13

Parts of a frame (not drawing shapes)

Type Declaration

box

box: string = 'drawer-frame-box'

Name of the border rectangle (hit on border only)

content

content: string = 'drawer-frame-content'

Name of the group of shapes of the frame, cut at the box edges

title

title: string = 'drawer-frame-title'

Name of the title text, above the box

Functions ​

createFrame() ​

createFrame(__namedParameters): Frame

Defined in: packages/free-drawing/src/utils/frame.ts:69

New frame of given box and name

Parameters

__namedParameters

IRect & object

Returns

Frame

frame with its box, title and empty content, not added to a layer


drawAbove() ​

drawAbove(shapes, layer): () => void

Defined in: packages/free-drawing/src/utils/frame.ts:211

Shapes of frames being moved drawn above the drawing, not cut at the edges of their frame: skipped by their frame, drawn by the draw layer after the drawing. Only drawn elsewhere: they stay in their frame (drawing saved, sent to collaborators, kept in history while moved), placed when dropped (placeInFrames)

Parameters

shapes

DrawingShape[]

shapes being moved (others ignored: of the drawing, frames, shapes of groups)

layer

Layer

draw layer

Returns

function drawing them in their frame again

() => void


findFrameAt() ​

findFrameAt(shape, frames): Frame | null

Defined in: packages/free-drawing/src/utils/frame.ts:277

Frame whose box contains the center of a shape (top one), null if none

Parameters

shape

DrawingShape

shape to place (drawn, dragged, transformed...)

frames

Frame[]

frames of the drawing, bottom first (hidden ones ignored, locked ones too unless the shape is in it)

Returns

Frame | null

topmost visible frame containing the shape center (absolute coordinates), null if none


frameTransform() ​

frameTransform(frame): object

Defined in: packages/free-drawing/src/utils/frame.ts:189

Position, rotation, scale and skew of a frame in the drawing, to place nodes like it (highlights)

Parameters

frame

Frame

frame of the draw layer

Returns

object

transform attributes of the frame

offsetX

offsetX: number

offsetY

offsetY: number

rotation

rotation: number

scaleX

scaleX: number

scaleY

scaleY: number

skewX

skewX: number

skewY

skewY: number

x

x: number

y

y: number


getDrawingShape() ​

getDrawingShape(node, layer): DrawingShape

Defined in: packages/free-drawing/src/utils/frame.ts:254

Drawing shape of a node of draw layer: the node itself, or its top group, in draw layer or in a frame (a part of a frame gives the frame)

Parameters

node

Node

node of the draw layer (hit shape, shape of a group...)

layer

Container

draw layer

Returns

DrawingShape

drawing shape containing the node, the node itself when it is one


getFrameContent() ​

getFrameContent(frame): Group

Defined in: packages/free-drawing/src/utils/frame.ts:96

Group of the shapes of a frame (cut at its box)

Parameters

frame

Frame

frame created by createFrame (or loaded)

Returns

Group

content group of the frame


getFrameOfTitle() ​

getFrameOfTitle(node): Frame | null

Defined in: packages/free-drawing/src/utils/frame.ts:156

Frame of a title, if it is one

Parameters

node

Node

any node (hit node, double clicked node...)

Returns

Frame | null

frame whose title is the node, null for other nodes


getFramePart() ​

getFramePart<T>(frame, name): T

Defined in: packages/free-drawing/src/utils/frame.ts:106

Part of a frame: its child of this name, not a shape of its content named so

Type Parameters

T

T extends Node<NodeConfig>

Parameters

frame

Group

frame created by createFrame (or loaded), or a copy of it

name

string

name of the part (frameParts)

Returns

T

the part


getFrameShapes() ​

getFrameShapes(frame): DrawingShape[]

Defined in: packages/free-drawing/src/utils/frame.ts:124

Shapes of a frame

Parameters

frame

Frame

frame whose shapes are read

Returns

DrawingShape[]

drawing shapes of its content, bottom first


getFrameTitle() ​

getFrameTitle(frame): Text

Defined in: packages/free-drawing/src/utils/frame.ts:115

Title text of a frame, above its box

Parameters

frame

Frame

frame created by createFrame (or loaded)

Returns

Text

title text node of the frame


getShapeFrame() ​

getShapeFrame(shape): Frame | null

Defined in: packages/free-drawing/src/utils/frame.ts:177

Frame holding a shape

Parameters

shape

DrawingShape

drawing shape

Returns

Frame | null

frame whose content holds the shape, null for a shape of the drawing


isFrame() ​

isFrame(node): node is Frame

Defined in: packages/free-drawing/src/utils/frame.ts:61

Node is a frame: to exclude frames from checks of groups of shapes (instanceof Group)

Parameters

node

Node<NodeConfig> | null | undefined

any node, or nothing

Returns

node is Frame

true for a frame


isShapesContainer() ​

isShapesContainer(node, layer): boolean

Defined in: packages/free-drawing/src/utils/frame.ts:168

Container of drawing shapes: draw layer, or content of a frame

Parameters

node

Node<NodeConfig> | null

node to check (parent of a shape), or nothing

layer

Container

draw layer

Returns

boolean

true for the draw layer or the content group of a frame


moveShapeTo() ​

moveShapeTo(shape, container): void

Defined in: packages/free-drawing/src/utils/frame.ts:299

Move a shape to another container (draw layer or content of a frame), at the same place on screen

Parameters

shape

DrawingShape

drawing shape to move

container

Container

new parent: draw layer or content group of a frame (nothing done when already its parent)

Returns

void


setFrameLabel() ​

setFrameLabel(frame, label): void

Defined in: packages/free-drawing/src/utils/frame.ts:146

Name of frame: its title

Parameters

frame

Frame

frame to rename

label

string

new name, set as label attribute and title text

Returns

void


setFrameSize() ​

setFrameSize(frame, width, height): void

Defined in: packages/free-drawing/src/utils/frame.ts:134

Size of frame: its box, cut of its shapes, title above it

Parameters

frame

Frame

frame to resize

width

number

new width, in frame coordinates

height

number

new height, in frame coordinates

Returns

void


withFrameShapes() ​

withFrameShapes(shapes): DrawingShape[]

Defined in: packages/free-drawing/src/utils/frame.ts:267

Drawing shapes and shapes of frames, from bottom to top (shapes of a frame after it)

Parameters

shapes

DrawingShape[]

Drawing shapes (of draw layer)

Returns

DrawingShape[]

the shapes, each frame followed by its shapes