Skip to content

API > @blocksuite/blocks > RoughCanvas

Class: RoughCanvas ​

Constructors ​

constructor ​

new RoughCanvas(canvas, config?): RoughCanvas

Parameters ​

ParameterType
canvasHTMLCanvasElement
config?Config

Returns ​

RoughCanvas

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:16

Properties ​

canvas ​

private canvas: HTMLCanvasElement

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:13


ctx ​

private ctx: CanvasRenderingContext2D

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:14


gen ​

private gen: RoughGenerator

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:12

Accessors ​

generator ​

get generator(): RoughGenerator

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:123

Methods ​

_drawToContext ​

private _drawToContext( ctx, drawing, fixedDecimals?, rule? = 'nonzero'): void

Parameters ​

ParameterTypeDefault value
ctxCanvasRenderingContext2Dundefined
drawingOpSetundefined
fixedDecimals?numberundefined
rule?CanvasFillRule'nonzero'

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:85


arc ​

arc( x, y, width, height, start, stop, closed = false, options?): Drawable

Parameters ​

ParameterTypeDefault value
xnumberundefined
ynumberundefined
widthnumberundefined
heightnumberundefined
startnumberundefined
stopnumberundefined
closedbooleanfalse
options?Optionsundefined

Returns ​

Drawable

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:185


circle ​

circle( x, y, diameter, options?): Drawable

Parameters ​

ParameterType
xnumber
ynumber
diameternumber
options?Options

Returns ​

Drawable

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:167


curve ​

curve(points, options?): Drawable

Parameters ​

ParameterType
pointsPoint[]
options?Options

Returns ​

Drawable

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:200


draw ​

draw(drawable): void

Parameters ​

ParameterType
drawableDrawable

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:23


ellipse ​

ellipse( x, y, width, height, options?): Drawable

Parameters ​

ParameterType
xnumber
ynumber
widthnumber
heightnumber
options?Options

Returns ​

Drawable

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:155


fillSketch ​

private fillSketch( ctx, drawing, o): void

Parameters ​

ParameterType
ctxCanvasRenderingContext2D
drawingOpSet
oResolvedOptions

Returns ​

void

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:63


getDefaultOptions ​

getDefaultOptions(): ResolvedOptions

Returns ​

ResolvedOptions

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:127


line ​

line( x1, y1, x2, y2, options?): Drawable

Parameters ​

ParameterType
x1number
y1number
x2number
y2number
options?Options

Returns ​

Drawable

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:131


linearPath ​

linearPath(points, options?): Drawable

Parameters ​

ParameterType
pointsPoint[]
options?Options

Returns ​

Drawable

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:173


path ​

path(d, options?): Drawable

Parameters ​

ParameterType
dstring
options?Options

Returns ​

Drawable

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:206


polygon ​

polygon(points, options?): Drawable

Parameters ​

ParameterType
pointsPoint[]
options?Options

Returns ​

Drawable

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:179


rectangle ​

rectangle( x, y, width, height, options?): Drawable

Parameters ​

ParameterType
xnumber
ynumber
widthnumber
heightnumber
options?Options

Returns ​

Drawable

Defined In ​

packages/blocks/src/surface-block/rough/canvas.ts:143