canvasToResizedCanvasWithBars Function

Resize a canvas to a desired size. The final size will be targetSize plus barSize. The original canvas is left untouched and a new, resized canvas with potential side bars is returned.

canvasToResizedCanvasWithBars(canvasIn: HTMLCanvasElement, targetSize: Point2d, barSize: Point2d..., barStyle: string"#C0C0C0"): HTMLCanvasElement

@returns an HTMLCanvasElement object containing the resized image and any requested side bars.

Parameter Type Description
canvasIn HTMLCanvasElement the source HTMLCanvasElement to resize.
targetSize Point2d the desired new size for the canvas image.
barSize Point2d total size of side bars to add to the image in width and height; defaults to (0, 0). For example, if you specify (2, 0), a 1 pixel side bar will be added to the left and right sides of the resized image. If an odd dimension is specified, the left or upper side of the image will be one pixel larger than the opposite side. For example, if you specify (1, 0), a 1 pixel side bar will be added to the left side of the image and a 0 pixel side bar will be added to the right side of the image.
barStyle string CSS style string to apply to any side bars; defaults to "#C0C0C0", which is silver.

Returns - HTMLCanvasElement

an HTMLCanvasElement object containing the resized image and any requested side bars.

Defined in

Last Updated: 17 December, 2024