utils
import {...} from "@canvas-commons/2d/lib/utils";
Classes
Functions
adjustRectRadius
public adjustRectRadiusradius: numberhorizontal: numbervertical: numberrect: BBox: number
Parameters
radius: numberhorizontal: numbervertical: numberrect: BBox
arc
public arccontext: CanvasRenderingContext2DPath2Dcenter: Vector2radius: numberstartAngle: number = 0endAngle: number = ...counterclockwise: boolean = false: void
Parameters
context: CanvasRenderingContext2DPath2Dcenter: Vector2radius: numberstartAngle: number = 0endAngle: number = ...counterclockwise: boolean = false
arcTo
Parameters
bezierCurveTo
public bezierCurveTocontext: CanvasRenderingContext2DPath2DcontrolPoint1: Vector2controlPoint2: Vector2to: Vector2: void
Parameters
canvasStyleParser
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
roughness: numberRoughness value
bowing: numberBowing value
fillStyle: RoughFillStyleFill style
fillWeight: numberundefinedFill weight
hachureAngle: numberHachure angle
hachureGap: numberHachure gap
seed: numberRandom seed (always defined, generated from useRandom if not specified)
disableMultiStroke: booleanDisable multiple strokes for stroke
disableMultiStrokeFill: booleanDisable multiple strokes for fill
drawImage
public drawImagecontext: CanvasRenderingContext2Dimage: CanvasImageSourcedestination: BBox: void
public drawImagecontext: CanvasRenderingContext2Dimage: CanvasImageSourcesource: BBoxdestination: BBox: void
Parameters
drawLine
public drawLinecontext: CanvasRenderingContext2DPath2Dpoints: Vector2[]: void
Parameters
drawPivot
Parameters
drawPolygon
Parameters
drawRect
public drawRectcontext: CanvasRenderingContext2DPath2Drect: BBox: void
Parameters
drawRoughCircle
public drawRoughCirclecontext: CanvasRenderingContext2Dcenter: Vector2size: Vector2config: PartialRoughConfigfill: PossibleCanvasStylestroke: PossibleCanvasStylestrokeWidth: number: void
Draw a rough circle/ellipse.
Parameters
context: CanvasRenderingContext2DThe 2D rendering context
center: Vector2Center point of the circle
size: Vector2Size (width and height) of the ellipse
config: PartialRoughConfigRough configuration
fill: PossibleCanvasStyleFill style
stroke: PossibleCanvasStyleStroke style
strokeWidth: numberLine width
drawRoughDrawable
public drawRoughDrawablecontext: CanvasRenderingContext2Ddrawable: Drawable: void
Draw a cached rough drawable.
Parameters
context: CanvasRenderingContext2DThe 2D rendering context
drawable: DrawableThe cached drawable to render
drawRoughPath
public drawRoughPathcontext: CanvasRenderingContext2DpathData: stringconfig: PartialRoughConfigfill: PossibleCanvasStylestroke: PossibleCanvasStylestrokeWidth: number: void
Draw a rough path from SVG path data.
Parameters
context: CanvasRenderingContext2DThe 2D rendering context
pathData: stringSVG path string
config: PartialRoughConfigRough configuration
fill: PossibleCanvasStyleFill style
stroke: PossibleCanvasStyleStroke style
strokeWidth: numberLine width
drawRoughRect
public drawRoughRectcontext: CanvasRenderingContext2Dbox: BBoxconfig: PartialRoughConfigfill: PossibleCanvasStylestroke: PossibleCanvasStylestrokeWidth: number: void
Draw a rough rectangle.
Parameters
context: CanvasRenderingContext2DThe 2D rendering context
box: BBoxThe bounding box of the rectangle
config: PartialRoughConfigRough configuration
fill: PossibleCanvasStyleFill style
stroke: PossibleCanvasStyleStroke style
strokeWidth: numberLine width
drawRoughRoundedRect
public drawRoughRoundedRectcontext: CanvasRenderingContext2Dbox: BBoxradius: SpacingsmoothCorners: booleancornerSharpness: numberconfig: PartialRoughConfigfill: PossibleCanvasStylestroke: PossibleCanvasStylestrokeWidth: number: void
Draw a rough rounded rectangle.
Parameters
context: CanvasRenderingContext2DThe 2D rendering context
box: BBoxThe bounding box of the rectangle
radius: SpacingCorner radius values
smoothCorners: booleanWhether to use smooth corners
cornerSharpness: numberSharpness of smooth corners
config: PartialRoughConfigRough configuration
fill: PossibleCanvasStyleFill style
stroke: PossibleCanvasStyleStroke style
strokeWidth: numberLine width
drawRoundRect
public drawRoundRectcontext: CanvasRenderingContext2DPath2Drect: BBoxradius: SpacingsmoothCorners: booleancornerSharpness: number: void
Parameters
context: CanvasRenderingContext2DPath2Drect: BBoxradius: SpacingsmoothCorners: booleancornerSharpness: number
fillRect
public fillRectcontext: CanvasRenderingContext2Drect: BBox: void
Parameters
generateRoughPath
public generateRoughPathcontext: CanvasRenderingContext2DpathData: stringconfig: PartialRoughConfigfill: PossibleCanvasStylestroke: PossibleCanvasStylestrokeWidth: number: Drawable
Generate a rough path drawable from SVG path data.
Parameters
context: CanvasRenderingContext2DThe 2D rendering context
pathData: stringSVG path string
config: PartialRoughConfigRough configuration
fill: PossibleCanvasStyleFill style
stroke: PossibleCanvasStyleStroke style
strokeWidth: numberLine width
generateRoughRect
public generateRoughRectcontext: CanvasRenderingContext2Dbox: BBoxconfig: PartialRoughConfigfill: PossibleCanvasStylestroke: PossibleCanvasStylestrokeWidth: number: Drawable
Generate a rough rectangle drawable.
Parameters
context: CanvasRenderingContext2DThe 2D rendering context
box: BBoxThe bounding box of the rectangle
config: PartialRoughConfigRough configuration
fill: PossibleCanvasStyleFill style
stroke: PossibleCanvasStyleStroke style
strokeWidth: numberLine width
generateRoughRoundedRect
public generateRoughRoundedRectcontext: CanvasRenderingContext2Dbox: BBoxradius: SpacingsmoothCorners: booleancornerSharpness: numberconfig: PartialRoughConfigfill: PossibleCanvasStylestroke: PossibleCanvasStylestrokeWidth: number: Drawable
Generate a rough rounded rectangle drawable.
Parameters
context: CanvasRenderingContext2DThe 2D rendering context
box: BBoxThe bounding box of the rectangle
radius: SpacingCorner radius values
smoothCorners: booleanWhether to use smooth corners
cornerSharpness: numberSharpness of smooth corners
config: PartialRoughConfigRough configuration
fill: PossibleCanvasStyleFill style
stroke: PossibleCanvasStyleStroke style
strokeWidth: numberLine width
is
Create a predicate that checks if the given object is an instance of the given class.
Parameters
klass: ()The class to check against.
lineTo
public lineTocontext: CanvasRenderingContext2DPath2Dposition: Vector2: void
Parameters
moveTo
public moveTocontext: CanvasRenderingContext2DPath2Dposition: Vector2: void
Parameters
quadraticCurveTo
public quadraticCurveTocontext: CanvasRenderingContext2DPath2DcontrolPoint: Vector2to: Vector2: void
Parameters
resolveCanvasStyle
public resolveCanvasStylestyle: CanvasStylecontext: CanvasRenderingContext2D: stringCanvasGradientCanvasPattern
Parameters
style: CanvasStylecontext: CanvasRenderingContext2D
roundedRectToSVGPath
public roundedRectToSVGPathbox: BBoxradius: SpacingsmoothCorners: booleancornerSharpness: number: string
Convert a rounded rectangle to SVG path data.
Parameters
box: BBoxThe bounding box of the rectangle
radius: SpacingCorner radius values
smoothCorners: booleanWhether to use smooth corners (bezier curves)
cornerSharpness: numberSharpness of smooth corners
strokeRect
public strokeRectcontext: CanvasRenderingContext2Drect: BBox: void
Parameters
withDefaults
Create a higher order component with default props.