canvasimo
Version:
An HTML5 canvas drawing library, with 150+ useful methods, jQuery-like fluent interface, and cross-browser compatibility enhancements.
805 lines (804 loc) • 29.9 kB
TypeScript
import { BooleanFalsy, CreateImageData, DrawImage, Fill, FillOrStrokeStyle, ForEach, GetAngle, GlobalCompositeOperation, LimitedTextMetrics, LineCap, LineJoin, MaxWidth, Points, PutImageData, Repeat, SetSize, Size, Stroke, TextAlign, TextBaseline } from './types';
export declare class Canvasimo {
private element;
private ctx;
private storedContextValues;
private ctxType;
private density;
constructor(element: HTMLCanvasElement);
/**
* @group Canvas element
* @description A collection of methods for getting and setting various properties of the canvas element.
*/
/**
* Get the canvas element.
* @alias getElement
*/
getCanvas: () => HTMLCanvasElement;
getElement: () => HTMLCanvasElement;
/**
* Set the canvas pixel density.
*/
setDensity: (density: number) => Canvasimo;
/**
* Get the canvas pixel density.
*/
getDensity: () => number;
/**
* Set the canvas dimensions.
*/
setSize: SetSize;
/**
* Get the canvas dimensions.
*/
getSize: () => Size;
/**
* Set the canvas width.
*/
setWidth: (width: number) => Canvasimo;
/**
* Get the canvas width.
*/
getWidth: () => number;
/**
* Set the canvas height.
*/
setHeight: (height: number) => Canvasimo;
/**
* Get the canvas height.
*/
getHeight: () => number;
/**
* Get the canvas size & position on screen.
*/
getBoundingClientRect: () => ClientRect;
/**
* @group Context
* @description 'A collection of methods for retrieving a canvas context or information about the context.
*/
/**
* Get the standard canvas context (used for drawing).
*/
getContext: (type: string, contextAttributes?: CanvasRenderingContext2DSettings | WebGLContextAttributes | undefined) => CanvasRenderingContext2D | WebGLRenderingContext | null;
/**
* Get canvas context used by Canvasimo (2d).
*/
getCurrentContext: () => CanvasRenderingContext2D;
/**
* Get the context type used by Canvasimo ('2d', 'webgl', etc).
*/
getCurrentContextType: () => "2d";
/**
* Get the context attributes used.
*/
getContextAttributes: () => CanvasRenderingContext2DSettings | WebGLContextAttributes | null;
/**
* @group Solid Shapes
* @description A collection of methods for plotting or drawing solid shapes -
* those that create a new shape when invoked, and are self closing.
*/
/**
* Plot a rectangle that can then have a fill or stroke applied to it.
* @alias rect
*/
plotRect: (x: number, y: number, width: number, height: number) => Canvasimo;
rect: (x: number, y: number, width: number, height: number) => Canvasimo;
/**
* Plot a rectangle and apply a stroke to it.
*/
strokeRect: (x: number, y: number, width: number, height: number, color?: string | undefined) => Canvasimo;
/**
* Plot a rectangle and apply a fill to it.
*/
fillRect: (x: number, y: number, width: number, height: number, color?: string | undefined) => Canvasimo;
/**
* Plot a rounded rectangle that can then have a fill or stroke applied to it.
*/
plotRoundedRect: (x: number, y: number, width: number, height: number, radius: number) => Canvasimo;
/**
* Plot a rounded rectangle and apply a stroke to it.
*/
strokeRoundedRect: (x: number, y: number, width: number, height: number, radius: number, color?: string | undefined) => Canvasimo;
/**
* Plot a rounded rectangle and apply a fill to it.
*/
fillRoundedRect: (x: number, y: number, width: number, height: number, radius: number, color?: string | undefined) => Canvasimo;
/**
* Plot a circle that can then have a stroke or fill applied to it.
*/
plotCircle: (x: number, y: number, radius: number, anticlockwise?: BooleanFalsy) => Canvasimo;
/**
* Plot a circle and apply a stroke to it.
*/
strokeCircle: (x: number, y: number, radius: number, anticlockwise?: BooleanFalsy, color?: string | undefined) => Canvasimo;
/**
* Plot a circle and apply a fill to it.
*/
fillCircle: (x: number, y: number, radius: number, anticlockwise?: BooleanFalsy, color?: string | undefined) => Canvasimo;
/**
* Plot a polygon that can then have a stroke or fill applied to it.
*/
plotPoly: (x: number, y: number, radius: number, sides: number, anticlockwise?: BooleanFalsy) => Canvasimo;
/**
* Plot a polygon and apply a stoke to it.
*/
strokePoly: (x: number, y: number, radius: number, sides: number, anticlockwise?: BooleanFalsy, color?: string | undefined) => Canvasimo;
/**
* Plot a polygon and apply a fill to it.
*/
fillPoly: (x: number, y: number, radius: number, sides: number, anticlockwise?: BooleanFalsy, color?: string | undefined) => Canvasimo;
/**
* Plot a star that can then have a stroke or fill applied to it.
*/
plotStar: (x: number, y: number, radius1: number, sides: number, anticlockwise?: BooleanFalsy) => Canvasimo;
/**
* Plot a star and apply a stoke to it.
*/
strokeStar: (x: number, y: number, radius1: number, sides: number, anticlockwise?: BooleanFalsy, color?: string | undefined) => Canvasimo;
/**
* Plot a star and apply a fill to it.
*/
fillStar: (x: number, y: number, radius1: number, sides: number, anticlockwise?: BooleanFalsy, color?: string | undefined) => Canvasimo;
/**
* Plot a burst that can then have a stroke or fill applied to it.
*/
plotBurst: (x: number, y: number, radius1: number, radius2: number, sides: number, anticlockwise?: BooleanFalsy) => Canvasimo;
/**
* Plot a burst and apply a stoke to it.
*/
strokeBurst: (x: number, y: number, radius1: number, radius2: number, sides: number, anticlockwise?: BooleanFalsy, color?: string | undefined) => Canvasimo;
/**
* Plot a burst and apply a fill to it.
*/
fillBurst: (x: number, y: number, radius1: number, radius2: number, sides: number, anticlockwise?: BooleanFalsy, color?: string | undefined) => Canvasimo;
/**
* Plot a single pixel that can then have a stroke or fill applied to it.
*/
plotPixel: (x: number, y: number) => Canvasimo;
/**
* Plot a single pixel and apply a stroke to it.
*/
strokePixel: (x: number, y: number, color?: string | undefined) => Canvasimo;
/**
* Plot a single pixel and apply a fill to it.
*/
fillPixel: (x: number, y: number, color?: string | undefined) => Canvasimo;
/**
* Plot a closed path that can then have a stroke or fill applied to it.
*/
plotClosedPath: (points: Points) => Canvasimo;
/**
* Plot a closed path and apply a stroke to it.
*/
strokeClosedPath: (points: Points, color?: string | undefined) => Canvasimo;
/**
* Plot a closed path and apply a fill to it.
*/
fillClosedPath: (points: Points, color?: string | undefined) => Canvasimo;
/**
* @group Open Shapes
* @description A collection of methods for plotting or drawing open shapes -
* those that create a new shape when invoked, but are not self closing.
*/
/**
* Plot a line that can then have a stroke or fill applied to it.
*/
plotLine: (x1: number, y1: number, x2: number, y2: number) => Canvasimo;
/**
* Plot a line and apply a stroke to it.
*/
strokeLine: (x1: number, y1: number, x2: number, y2: number, color?: string | undefined) => Canvasimo;
/**
* Plot a line, by length & angle, that can then have a stroke or fill applied to it.
*/
plotLength: (x1: number, y1: number, length: number, angle: number) => Canvasimo;
/**
* Plot a line, by length & angle, and apply a stroke to it.
*/
strokeLength: (x1: number, y1: number, length: number, angle: number, color?: string | undefined) => Canvasimo;
/**
* Plot a path, that is not self closing, that can have a stroke or fill applied to it.
*/
plotPath: (points: Points) => Canvasimo;
/**
* Plot a path, that is not self closing, and apply a stroke to it.
*/
strokePath: (points: Points, color?: string | undefined) => Canvasimo;
/**
* Plot a path, that is not self closing, and apply a fill to it.
*/
fillPath: (points: Points, color?: string | undefined) => Canvasimo;
/**
* @group Paths
* @description A collection of methods for plotting or drawing paths -
* shapes that can be connected to create more complex shapes.
*/
/**
* Plot an arc that can have a stroke or fill applied to it.
* @alias arc
*/
plotArc: (x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: BooleanFalsy) => Canvasimo;
arc: (x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: BooleanFalsy) => Canvasimo;
/**
* Plot an arc and apply a stroke to it.
*/
strokeArc: (x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: BooleanFalsy, color?: string | undefined) => Canvasimo;
/**
* Plot an arc and apply a fill to it.
*/
fillArc: (x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: BooleanFalsy, color?: string | undefined) => Canvasimo;
/**
* Plot an ellipse that can then have a stroke or fill applied to it.
* @alias ellipse
*/
plotEllipse: (x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: BooleanFalsy) => Canvasimo;
ellipse: (x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: BooleanFalsy) => Canvasimo;
/**
* Plot an ellipse and apply a stroke to it.
*/
strokeEllipse: (x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: BooleanFalsy, color?: string | undefined) => Canvasimo;
/**
* Plot an ellipse and apply a fill to it.
*/
fillEllipse: (x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: BooleanFalsy, color?: string | undefined) => Canvasimo;
/**
* @group Text
* @description A collection of methods for drawing text,
* and getting and setting properties related to text rendering.
*/
/**
* Draw a text with a stroke.
*/
strokeText: (text: string, x: number, y: number, maxWidth?: MaxWidth, color?: string | undefined) => Canvasimo;
/**
* Draw a text with a fill.
*/
fillText: (text: string, x: number, y: number, maxWidth?: MaxWidth, color?: string | undefined) => Canvasimo;
/**
* Draw text with a stroke, wrapped at newlines and automatically wrapped if the text exceeds the maxWidth.
* If no maxWidth is specified text will only wrap at newlines (wordBreak is ignore).
* Words will not break by default (normal) and therefore may overflow.
* break-all will break words wherever possible, and break-word will only break words if there is not enough room.
* The lineHeight parameter is a multiplier for the font size, and defaults to 1.
*/
strokeTextMultiline: (text: string, x: number, y: number, maxWidth?: MaxWidth, wordBreak?: "normal" | "break-word" | "break-all" | undefined, lineHeight?: number | undefined, color?: string | undefined) => Canvasimo;
/**
* Draw text with a fill, wrapped at newlines and automatically wrapped if the text exceeds the maxWidth.
* If no maxWidth is specified text will only wrap at newlines (wordBreak is ignore).
* Words will not break by default (normal) and therefore may overflow.
* break-all will break words wherever possible, and break-word will only break words if there is not enough room.
* The lineHeight parameter is a multiplier for the font size, and defaults to 1.
*/
fillTextMultiline: (text: string, x: number, y: number, maxWidth?: MaxWidth, wordBreak?: "normal" | "break-word" | "break-all" | undefined, lineHeight?: number | undefined, color?: string | undefined) => Canvasimo;
/**
* Get information about the size text will be drawn.
* @alias measureText
*/
getTextSize: (text: string) => LimitedTextMetrics;
measureText: (text: string) => LimitedTextMetrics;
/**
* Set the horizontal text alignment.
*/
setTextAlign: (value: TextAlign) => Canvasimo;
/**
* Get the horizontal text alignment.
*/
getTextAlign: () => TextAlign;
/**
* Set the vertical text alignment.
*/
setTextBaseline: (value: TextBaseline) => Canvasimo;
/**
* Get the vertical text alignment.
*/
getTextBaseline: () => TextBaseline;
/**
* @group Fonts
* @description A collection of methods for getting and setting font styles and variations.
*/
/**
* Set the font to use.
*/
setFont: (font: string) => Canvasimo;
/**
* Get the font that is being used.
* This returns the exact CanvasRenderingContext2D.font string.
*/
getFont: () => string;
/**
* Set the font family to use.
*/
setFontFamily: (family: string) => Canvasimo;
/**
* Get the font that is being used.
*/
getFontFamily: () => string | null;
/**
* Set the font size to use.
*/
setFontSize: (size: string | number) => Canvasimo;
/**
* Get the font size that is being used.
* Returns null if using a special font e.g. caption, icon, menu.
*/
getFontSize: () => number | null;
/**
* Set the font style to use.
*/
setFontStyle: (style: string) => Canvasimo;
/**
* Get the font style that is being used.
* Returns null if using a special font e.g. caption, icon, menu.
*/
getFontStyle: () => string | null;
/**
* Set the font variant to use.
*/
setFontVariant: (variant: string) => Canvasimo;
/**
* Get the font variant that is being used.
* Returns null if using a special font e.g. caption, icon, menu.
*/
getFontVariant: () => string | null;
/**
* Set the font weight to use.
*/
setFontWeight: (weight: string | number) => Canvasimo;
/**
* Get the font weight that is being used.
* Returns null if using a special font e.g. caption, icon, menu.
*/
getFontWeight: () => string | number | null;
/**
* @group Stroke Styles
* @description A collection of methods for getting and setting stroke styles,
* and applying strokes to existing shapes.
*/
/**
* Apply a stroke to the current shape.
*/
stroke: Stroke;
/**
* Set the stroke style to use.
* @alias setStrokeStyle
*/
setStroke: (value: FillOrStrokeStyle) => Canvasimo;
setStrokeStyle: (value: FillOrStrokeStyle) => Canvasimo;
/**
* Get the stroke style that is being used.
* @alias getStrokeStyle
*/
getStroke: () => FillOrStrokeStyle;
getStrokeStyle: () => string;
/**
* Set the stroke cap to use.
* @alias setLineCap
*/
setStrokeCap: (value: LineCap) => Canvasimo;
setLineCap: (value: LineCap) => Canvasimo;
/**
* Get the stroke cap that is being used.
* @alias getLineCap
*/
getStrokeCap: () => LineCap;
getLineCap: () => LineCap;
/**
* Set the stroke dash to use.
* @alias setLineDash
*/
setStrokeDash: (segments: number[]) => Canvasimo;
setLineDash: (segments: number[]) => Canvasimo;
/**
* Get the stroke dash that is being used.
* @alias getLineDash
*/
getStrokeDash: () => number[];
getLineDash: () => number[];
/**
* Set the stroke dash offset to use.
* @alias setLineDashOffset
*/
setStrokeDashOffset: (value: number) => Canvasimo;
setLineDashOffset: (value: number) => Canvasimo;
/**
* Get the stroke dash offset that is being used.
* @alias getLineDashOffset
*/
getStrokeDashOffset: () => number;
getLineDashOffset: () => number;
/**
* Set the stroke join to use.
* @alias setLineJoin
*/
setStrokeJoin: (value: LineJoin) => Canvasimo;
setLineJoin: (value: LineJoin) => Canvasimo;
/**
* Get the stroke join that is being used.
* @alias getLineJoin
*/
getStrokeJoin: () => LineJoin;
getLineJoin: () => LineJoin;
/**
* Set the stroke width to use.
* @alias setLineWidth
*/
setStrokeWidth: (value: number) => Canvasimo;
setLineWidth: (value: number) => Canvasimo;
/**
* Get the stroke width that is being used.
* @alias getLineWidth
*/
getStrokeWidth: () => number;
getLineWidth: () => number;
/**
* Set the miter limit to use.
*/
setMiterLimit: (value: number) => Canvasimo;
/**
* Get the miter limit that is being used.
*/
getMiterLimit: () => number;
/**
* @group Fill styles
* @description A collection of methods for getting and setting fill styles,
* and applying fills to existing shapes.
*/
/**
* Apply a fill to the current shape.
*/
fill: Fill;
/**
* Apply a fill to the entire canvas area.
*/
fillCanvas: (color?: string | undefined) => Canvasimo;
/**
* Clear the entire canvas area
*/
clearCanvas: () => Canvasimo;
/**
* Clear a rectangular area of the canvas.
*/
clearRect: (x: number, y: number, width: number, height: number) => Canvasimo;
/**
* Set the fill to use.
* @alias setFillStyle
*/
setFill: (value: FillOrStrokeStyle) => Canvasimo;
setFillStyle: (value: FillOrStrokeStyle) => Canvasimo;
/**
* Get the fill that is being used.
* @alias getFillStyle
*/
getFill: () => FillOrStrokeStyle;
getFillStyle: () => FillOrStrokeStyle;
/**
* Create a linear gradient to use as a fill.
*/
createLinearGradient: (x0: number, y0: number, x1: number, y1: number) => CanvasGradient;
/**
* Create a radial gradient to use as a fill.
*/
createRadialGradient: (x0: number, y0: number, r0: number, x1: number, y1: number, r1: number) => CanvasGradient;
/**
* Create a pattern to be used as a fill.
*/
createPattern: (image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string) => CanvasPattern | null;
/**
* Draw an image to the canvas.
* If the second position / size arguments are supplied, the first will be used for cropping the image,
* and the second for the position and size it will be drawn.
*/
drawImage: DrawImage;
/**
* @group Image Data
* @description A collection of methods for creating, putting, or getting image data about the canvas.
*/
/**
* Get a data URL of the current canvas state.
*/
getDataURL: (type?: string | undefined, ...args: any[]) => string;
/**
* Create image data with either the width and height specified,
* or with the width and height of a the image data supplied.
*/
createImageData: CreateImageData;
/**
* Get the image data from an area of the canvas.
*/
getImageData: (sx: number, sy: number, sw: number, sh: number) => ImageData;
/**
* Draw image data onto the canvas.
*/
putImageData: PutImageData;
/**
* Get image data about a specific pixel.
*/
getPixelData: (x: number, y: number) => Uint8ClampedArray;
/**
* Get the color of a specific pixel.
*/
getPixelColor: (x: number, y: number) => string;
/**
* @group Color Helpers
* @description A collection of methods to help with creating color strings.
*/
/**
* Create an HSL color string from the given values.
*/
createHSL: (h: number, s: number, l: number) => string;
/**
* Create an HSLA color string from the given values.
*/
createHSLA: (h: number, s: number, l: number, a: number) => string;
/**
* Create an RGB color string from the given values.
*/
createRGB: (r: number, g: number, b: number) => string;
/**
* Create an RGBA color string from the given values.
*/
createRGBA: (r: number, g: number, b: number, a: number) => string;
/**
* Return an HSL color string from the given HSLA color string.
*/
getHSLFromHSLA: (color: string) => string;
/**
* Return an RGB color string from the given RGBA color string.
*/
getRGBFromRGBA: (color: string) => string;
/**
* @group Converting Sizes
* @description A collection of methods to help with calculating and converting sizes, and distances.
*/
/**
* Get a fraction from the provided percent value e.g. 80 returns 0.8.
*/
getFractionFromPercent: (percent: number) => number;
/**
* Get a percent from the provided fraction value e.g. 0.7 returns 70.
*/
getPercentFromFraction: (fraction: number) => number;
/**
* Returns the actual value of a fraction of the canvas width e.g.
* a canvas with a width of 200 returns 100 if the provided value is 0.5.
*/
getFractionOfWidth: (fraction: number) => number;
/**
* Returns the actual value of a fraction of the canvas height e.g.
* a canvas with a height of 100 returns 20 if the provided value is 0.2.
*/
getFractionOfHeight: (fraction: number) => number;
/**
* Returns the actual value of a percentage of the canvas width e.g.
* a canvas with a width of 200 returns 100 if the provided value is 50.
*/
getPercentOfWidth: (percent: number) => number;
/**
* Returns the actual value of a percentage of the canvas height e.g.
* a canvas with a height of 100 returns 20 if the provided value is 20.
*/
getPercentOfHeight: (percent: number) => number;
/**
* Returns the distance between 2 points.
*/
getDistance: (x1: number, y1: number, x2: number, y2: number) => number;
/**
* @group Converting Angles
* @description A collection of methods to help with calculating and converting angles.
*/
/**
* Get a radian value from the provided degrees e.g. 90 returns 1.5708.
*/
getRadiansFromDegrees: (degrees: number) => number;
/**
* Get a degree value from the provided radians e.g. 3.14159 returns 180.
*/
getDegreesFromRadians: (radians: number) => number;
/**
* Get the angle (in radians) between 2 or 3 points.
*/
getAngle: GetAngle;
/**
* @group Path Plotting
* @description A collection of methods for path drawing.
*/
/**
* Begin a new path (shape).
*/
beginPath: () => Canvasimo;
/**
* Close the current path (shape).
*/
closePath: () => Canvasimo;
/**
* Move the starting point of a the next sub-path.
*/
moveTo: (x: number, y: number) => Canvasimo;
/**
* Connect the last point to the provided coordinates.
*/
lineTo: (x: number, y: number) => Canvasimo;
/**
* Arc from one point to another.
*/
arcTo: (x1: number, y1: number, x2: number, y2: number, radius: number) => Canvasimo;
/**
* Connect the last point to the provided coordinates with a bezier curve (2 control points).
*/
bezierCurveTo: (cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number) => Canvasimo;
/**
* Connect the last point to the provided coordinates with a quadratic curve (1 control point).
*/
quadraticCurveTo: (cpx: number, cpy: number, x: number, y: number) => Canvasimo;
/**
* @group Canvas State
* @description A collection of methods to save, restore, or transform the canvas state.
*/
/**
* Push the current state of the canvas into a stack that can later be restored.
*/
save: () => Canvasimo;
/**
* Restore the most recent state of the canvas that was saved.
*/
restore: () => Canvasimo;
/**
* Add rotation (in radians) to the transform matrix so that shapes can be drawn at an angle.
*/
rotate: (angle: number) => Canvasimo;
/**
* Scale the transform matrix so that shapes can be drawn at the provided scale.
*/
scale: (x: number, y: number) => Canvasimo;
/**
* Move the canvas origin.
*/
translate: (x: number, y: number) => Canvasimo;
/**
* Multiply the current transformation with the provided matrix.
*/
transform: (m11: number, m12: number, m21: number, m22: number, dx: number, dy: number) => Canvasimo;
/**
* Replace the current transformation with the provided matrix.
*/
setTransform: (m11: number, m12: number, m21: number, m22: number, dx: number, dy: number) => Canvasimo;
/**
* Replace the current transformation with the default matrix: [1, 0, 0, 1, 0, 0].
*/
resetTransform: () => Canvasimo;
/**
* Use the current path as a clipping path.
*/
clip: (fillRule?: "nonzero" | "evenodd" | undefined) => Canvasimo;
/**
* Set the opacity to use for drawing.
* @alias setGlobalAlpha
*/
setOpacity: (value: number) => Canvasimo;
setGlobalAlpha: (value: number) => Canvasimo;
/**
* Get the opacity that is being used.
* @alias getGlobalAlpha
*/
getOpacity: () => number;
getGlobalAlpha: () => number;
/**
* Set the composite operation to use for drawing.
* @alias setGlobalCompositeOperation
*/
setCompositeOperation: (value: GlobalCompositeOperation) => Canvasimo;
setGlobalCompositeOperation: (value: GlobalCompositeOperation) => Canvasimo;
/**
* Get the composite operation that is being used.
* @alias getGlobalCompositeOperation
*/
getCompositeOperation: () => GlobalCompositeOperation;
getGlobalCompositeOperation: () => GlobalCompositeOperation;
/**
* Set whether image smoothing should be used.
*/
setImageSmoothingEnabled: (value: BooleanFalsy) => Canvasimo;
/**
* Get whether image smoothing is being used.
*/
getImageSmoothingEnabled: () => boolean;
/**
* Set the image smoothing quality.
*/
setImageSmoothingQuality: (value: ImageSmoothingQuality) => Canvasimo;
/**
* Get the current image smoothing quality.
*/
getImageSmoothingQuality: () => ImageSmoothingQuality;
/**
* Set how blurry shadows are.
*/
setShadowBlur: (value: number) => Canvasimo;
/**
* Get the value of how blurry shadows are.
*/
getShadowBlur: () => number;
/**
* Set the color to be used for shadows.
*/
setShadowColor: (value: string) => Canvasimo;
/**
* Get the color being used for shadows.
*/
getShadowColor: () => string;
/**
* Set how horizontally offset shadows should be.
*/
setShadowOffsetX: (value: number) => Canvasimo;
/**
* Get the value of how horizontally offset shadows should be.
*/
getShadowOffsetX: () => number;
/**
* Set how vertically offset shadows should be.
*/
setShadowOffsetY: (value: number) => Canvasimo;
/**
* Get the value of how vertically offset shadows should be.
*/
getShadowOffsetY: () => number;
/**
* @group Misc
* @description Miscellaneous methods.
*/
/**
* Break out of the method chain and execute a callback.
*/
tap: (callback: () => any) => Canvasimo;
/**
* Break out of the method chain and execute a callback with values between start and end,
* increasing / decreasing by step (start defaults to 0, step defaults to 1).
* You may return false from the callback at any point to stop at the current iteration.
*/
repeat: Repeat;
/**
* Break out of the method chain and loop over the given array, object or string,
* calling the callback with the value & key / index.
* You may return false from the callback at any point to stop at the current iteration.
*/
forEach: ForEach;
/**
* Constrain a number between a minimum and maximum value.
*/
constrain: (value: number, min: number, max: number) => number;
/**
* Map a value from one range to another e.g. mapping 0.5 from 0-1 to 0-10 returns 5.
*/
map: (value: number, fromStart: number, fromEnd: number, toStart: number, toEnd: number) => number;
/**
* Draw a focus ring around the current path, or the path supplied,
* if the element supplied has focus.
*/
drawFocusIfNeeded: (element: Element) => Canvasimo;
/**
* Returns whether the given point is within the current or given path.
*/
isPointInPath: (x: number, y: number, fillRule?: "nonzero" | "evenodd" | undefined) => boolean;
/**
* Returns whether the given point is within the area contained by applying
* a stroke to the current or given path.
*/
isPointInStroke: () => boolean | null;
/**
* Return the current version of Canvasimo (and log to console if logInfo parameter is true)
* @alias version
*/
getVersion: (logInfo?: BooleanFalsy) => string;
version: (logInfo?: BooleanFalsy) => string;
private setCanvasProperty;
private getCanvasProperty;
private drawTextWithLineBreaks;
private wrapBreakAll;
private wrapBreakWord;
private wrapNormal;
private textMultiline;
private setDefaultContextValues;
private saveContextValues;
private restoreContextValues;
}
export default Canvasimo;