Skip to content

API > @blocksuite/blocks > Renderer

Class: Renderer ​

Implements ​

Constructors ​

constructor ​

new Renderer(): Renderer

Returns ​

Renderer

Defined In ​

packages/blocks/src/surface-block/renderer.ts:82

Properties ​

_center ​

private _center: object

Type declaration ​

\_center.x ​

x: number = 0

\_center.y ​

y: number = 0

Defined In ​

packages/blocks/src/surface-block/renderer.ts:78


_container ​

private _container: HTMLElement

Defined In ​

packages/blocks/src/surface-block/renderer.ts:71


_height ​

private _height: number = 0

Defined In ​

packages/blocks/src/surface-block/renderer.ts:75


_left ​

private _left: number = 0

Defined In ​

packages/blocks/src/surface-block/renderer.ts:72


_overlays ​

private _overlays: Set< Overlay >

Defined In ​

packages/blocks/src/surface-block/renderer.ts:70


_rafId ​

private _rafId: null | number = null

Defined In ​

packages/blocks/src/surface-block/renderer.ts:80


_shouldUpdate ​

private _shouldUpdate: boolean = false

Defined In ​

packages/blocks/src/surface-block/renderer.ts:79


_top ​

private _top: number = 0

Defined In ​

packages/blocks/src/surface-block/renderer.ts:73


_width ​

private _width: number = 0

Defined In ​

packages/blocks/src/surface-block/renderer.ts:74


_zoom ​

private _zoom: number = 1.0

Defined In ​

packages/blocks/src/surface-block/renderer.ts:77


canvas ​

canvas: HTMLCanvasElement

Defined In ​

packages/blocks/src/surface-block/renderer.ts:61


ctx ​

ctx: CanvasRenderingContext2D

Defined In ​

packages/blocks/src/surface-block/renderer.ts:62


gridManager ​

gridManager: GridManager

Defined In ​

packages/blocks/src/surface-block/renderer.ts:64


rc ​

rc: RoughCanvas

Defined In ​

packages/blocks/src/surface-block/renderer.ts:63


slots ​

slots: object

Type declaration ​

slots.viewportUpdated ​

viewportUpdated: Slot< {center: IVec; zoom: number;} >

Defined In ​

packages/blocks/src/surface-block/renderer.ts:66

Accessors ​

boundingClientRect ​

get boundingClientRect(): DOMRect

Defined In ​

packages/blocks/src/surface-block/renderer.ts:171

Implementation of ​

SurfaceViewport.boundingClientRect


center ​

get center(): object

Defined In ​

packages/blocks/src/surface-block/renderer.ts:124

Implementation of ​

SurfaceViewport.center


centerX ​

get centerX(): number

Defined In ​

packages/blocks/src/surface-block/renderer.ts:116

Implementation of ​

SurfaceViewport.centerX


centerY ​

get centerY(): number

Defined In ​

packages/blocks/src/surface-block/renderer.ts:120

Implementation of ​

SurfaceViewport.centerY


height ​

get height(): number

Defined In ​

packages/blocks/src/surface-block/renderer.ts:108

Implementation of ​

SurfaceViewport.height


left ​

get left(): number

Defined In ​

packages/blocks/src/surface-block/renderer.ts:96

Implementation of ​

SurfaceViewport.left


top ​

get top(): number

Defined In ​

packages/blocks/src/surface-block/renderer.ts:100

Implementation of ​

SurfaceViewport.top


translateX ​

get translateX(): number

Defined In ​

packages/blocks/src/surface-block/renderer.ts:138


translateY ​

get translateY(): number

Defined In ​

packages/blocks/src/surface-block/renderer.ts:142


viewportBounds ​

get viewportBounds(): Bound

Defined In ​

packages/blocks/src/surface-block/renderer.ts:162

Implementation of ​

SurfaceViewport.viewportBounds


viewportMaxXY ​

get viewportMaxXY(): object

Defined In ​

packages/blocks/src/surface-block/renderer.ts:154

Implementation of ​

SurfaceViewport.viewportMaxXY


viewportMinXY ​

get viewportMinXY(): object

Defined In ​

packages/blocks/src/surface-block/renderer.ts:146

Implementation of ​

SurfaceViewport.viewportMinXY


viewportX ​

get viewportX(): number

Defined In ​

packages/blocks/src/surface-block/renderer.ts:128

Implementation of ​

SurfaceViewport.viewportX


viewportY ​

get viewportY(): number

Defined In ​

packages/blocks/src/surface-block/renderer.ts:133

Implementation of ​

SurfaceViewport.viewportY


width ​

get width(): number

Defined In ​

packages/blocks/src/surface-block/renderer.ts:104

Implementation of ​

SurfaceViewport.width


zoom ​

get zoom(): number

Defined In ​

packages/blocks/src/surface-block/renderer.ts:112

Implementation of ​

SurfaceViewport.zoom

Methods ​

_emitViewportUpdatedSlot ​

private _emitViewportUpdatedSlot(): void

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/renderer.ts:89


_loop ​

private _loop(): void

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/renderer.ts:377


_render ​

private _render(): void

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/renderer.ts:387


_renderByBound ​

private _renderByBound( ctx, matrix, rc, bound, surfaceElements?): void

Parameters ​

ParameterType
ctxnull | CanvasRenderingContext2D
matrixDOMMatrix
rcRoughCanvas
boundIBound
surfaceElements?SurfaceElement< ISurfaceElement, ISurfaceElementLocalRecord >[]

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/renderer.ts:401


_resetSize ​

private _resetSize(): void

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/renderer.ts:359


addElement ​

addElement(element): void

Parameters ​

ParameterType
elementSurfaceElement< ISurfaceElement, ISurfaceElementLocalRecord >

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/renderer.ts:311


addOverlay ​

addOverlay(overlay): void

Parameters ​

ParameterType
overlayOverlay

Returns ​

void

Implementation of ​

SurfaceViewport.addOverlay

Defined In ​

packages/blocks/src/surface-block/renderer.ts:458


applyDeltaCenter ​

applyDeltaCenter(deltaX, deltaY): void

Parameters ​

ParameterType
deltaXnumber
deltaYnumber

Returns ​

void

Implementation of ​

SurfaceViewport.applyDeltaCenter

Defined In ​

packages/blocks/src/surface-block/renderer.ts:306


attach ​

attach(container): void

Parameters ​

ParameterType
containerHTMLElement

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/renderer.ts:332


getCanvasByBound ​

getCanvasByBound(bound, surfaceElements?): HTMLCanvasElement

Parameters ​

ParameterType
boundIBound
surfaceElements?SurfaceElement< ISurfaceElement, ISurfaceElementLocalRecord >[]

Returns ​

HTMLCanvasElement

Implementation of ​

SurfaceViewport.getCanvasByBound

Defined In ​

packages/blocks/src/surface-block/renderer.ts:438


isInViewport ​

isInViewport(bound): boolean

Parameters ​

ParameterType
boundBound

Returns ​

boolean

Implementation of ​

SurfaceViewport.isInViewport

Defined In ​

packages/blocks/src/surface-block/renderer.ts:175


load ​

load(elements): void

Parameters ​

ParameterType
elementsSurfaceElement< ISurfaceElement, ISurfaceElementLocalRecord >[]

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/renderer.ts:321


onResize ​

onResize(): void

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/renderer.ts:341


refresh ​

refresh(): void

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/renderer.ts:328


removeElement ​

removeElement(element): void

Parameters ​

ParameterType
elementSurfaceElement< ISurfaceElement, ISurfaceElementLocalRecord >

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/renderer.ts:316


removeOverlay ​

removeOverlay(overlay): void

Parameters ​

ParameterType
overlayOverlay

Returns ​

void

Implementation of ​

SurfaceViewport.removeOverlay

Defined In ​

packages/blocks/src/surface-block/renderer.ts:463


setCenter ​

setCenter(centerX, centerY): void

Parameters ​

ParameterType
centerXnumber
centerYnumber

Returns ​

void

Implementation of ​

SurfaceViewport.setCenter

Defined In ​

packages/blocks/src/surface-block/renderer.ts:193


setViewport ​

setViewport( newZoom, newCenter = ..., smooth = false): void

Parameters ​

ParameterTypeDefault value
newZoomnumberundefined
newCenternumber[]undefined
smoothbooleanfalse

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/renderer.ts:221


setViewportByBound ​

setViewportByBound( bound, padding = ..., smooth = false): void

Parameters ​

ParameterTypeDefault value
boundBoundundefined
padding[number, number, number, number]undefined
smoothbooleanfalse

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/renderer.ts:246


setZoom ​

setZoom(zoom, focusPoint?): void

Parameters ​

ParameterTypeDescription
zoomnumberzoom
focusPoint?IPointcanvas coordinate

Returns ​

void

Implementation of ​

SurfaceViewport.setZoom

Defined In ​

packages/blocks/src/surface-block/renderer.ts:205


smoothTranslate ​

smoothTranslate(x, y): void

Parameters ​

ParameterType
xnumber
ynumber

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/renderer.ts:283


smoothZoom ​

smoothZoom(zoom, focusPoint?): void

Parameters ​

ParameterType
zoomnumber
focusPoint?IPoint

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/renderer.ts:265


toModelCoord ​

toModelCoord(viewX, viewY): [number, number]

Parameters ​

ParameterType
viewXnumber
viewYnumber

Returns ​

[number, number]

Implementation of ​

SurfaceViewport.toModelCoord

Defined In ​

packages/blocks/src/surface-block/renderer.ts:183


toViewCoord ​

toViewCoord(modelX, modelY): [number, number]

Parameters ​

ParameterType
modelXnumber
modelYnumber

Returns ​

[number, number]

Implementation of ​

SurfaceViewport.toViewCoord

Defined In ​

packages/blocks/src/surface-block/renderer.ts:188