Skip to main content

utils

import {...} from "@canvas-commons/2d/lib/utils";

Classes

Functions

adjustRectRadius

public adjustRectRadiusradius: numberhorizontal: numbervertical: numberrect: BBox: number

Parameters


arc

public arccontext: CanvasRenderingContext2DPath2Dcenter: Vector2radius: numberstartAngle: number = 0endAngle: number = ...counterclockwise: boolean = false: void

Parameters


arcTo

Parameters


bezierCurveTo

Parameters


canvasStyleParser

public canvasStyleParserstyle: PossibleCanvasStyle: ColorGradientPatternnull

Parameters

  • style: PossibleCanvasStyle

createRoughConfig

public createRoughConfigroughness: numberbowing: numberfillStyle: RoughFillStylefillWeight: numberundefinedhachureAngle: numberhachureGap: numberseed: numberdisableMultiStroke: booleandisableMultiStrokeFill: boolean: PartialRoughConfig

Helper to create rough config from individual signals.

Parameters


drawImage

Parameters


drawLine

Parameters


drawPivot

public drawPivotcontext: CanvasRenderingContext2DPath2Doffset: Vector2radius: number = 8: void

Parameters


drawPolygon

public drawPolygonpath: CanvasRenderingContext2DPath2Drect: BBoxsides: number: void

Parameters


drawRect

Parameters


drawRoughCircle

public drawRoughCirclecontext: CanvasRenderingContext2Dcenter: Vector2size: Vector2config: PartialRoughConfigfill: PossibleCanvasStylestroke: PossibleCanvasStylestrokeWidth: number: void

Draw a rough circle/ellipse.

Parameters


drawRoughDrawable

public drawRoughDrawablecontext: CanvasRenderingContext2Ddrawable: Drawable: void

Draw a cached rough drawable.

Parameters


drawRoughPath

public drawRoughPathcontext: CanvasRenderingContext2DpathData: stringconfig: PartialRoughConfigfill: PossibleCanvasStylestroke: PossibleCanvasStylestrokeWidth: number: void

Draw a rough path from SVG path data.

Parameters


drawRoughRect

public drawRoughRectcontext: CanvasRenderingContext2Dbox: BBoxconfig: PartialRoughConfigfill: PossibleCanvasStylestroke: PossibleCanvasStylestrokeWidth: number: void

Draw a rough rectangle.

Parameters


drawRoughRoundedRect

public drawRoughRoundedRectcontext: CanvasRenderingContext2Dbox: BBoxradius: SpacingsmoothCorners: booleancornerSharpness: numberconfig: PartialRoughConfigfill: PossibleCanvasStylestroke: PossibleCanvasStylestrokeWidth: number: void

Draw a rough rounded rectangle.

Parameters


drawRoundRect

Parameters


fillRect

Parameters


generateRoughPath

public generateRoughPathcontext: CanvasRenderingContext2DpathData: stringconfig: PartialRoughConfigfill: PossibleCanvasStylestroke: PossibleCanvasStylestrokeWidth: number: Drawable

Generate a rough path drawable from SVG path data.

Parameters


generateRoughRect

public generateRoughRectcontext: CanvasRenderingContext2Dbox: BBoxconfig: PartialRoughConfigfill: PossibleCanvasStylestroke: PossibleCanvasStylestrokeWidth: number: Drawable

Generate a rough rectangle drawable.

Parameters


generateRoughRoundedRect

public generateRoughRoundedRectcontext: CanvasRenderingContext2Dbox: BBoxradius: SpacingsmoothCorners: booleancornerSharpness: numberconfig: PartialRoughConfigfill: PossibleCanvasStylestroke: PossibleCanvasStylestrokeWidth: number: Drawable

Generate a rough rounded rectangle drawable.

Parameters


is

public isklass: (): object: any => object is T

Create a predicate that checks if the given object is an instance of the given class.

Parameters

  • klass: ()

    The class to check against.


lineTo

Parameters


moveTo

Parameters


quadraticCurveTo

Parameters


resolveCanvasStyle

public resolveCanvasStylestyle: CanvasStylecontext: CanvasRenderingContext2D: stringCanvasGradientCanvasPattern

Parameters


roundedRectToSVGPath

public roundedRectToSVGPathbox: BBoxradius: SpacingsmoothCorners: booleancornerSharpness: number: string

Convert a rounded rectangle to SVG path data.

Parameters


strokeRect

public strokeRectcontext: CanvasRenderingContext2Drect: BBox: void

Parameters


withDefaults

public withDefaultscomponent: Tdefaults: PropsOfT: props: PropsOfT => Node

Create a higher order component with default props.

Examples

Parameters

  • component: T

    The base class or function component to wrap.

  • defaults: PropsOfT

    The default props to apply.