Skip to content

Choose a tag to compare

@kyranet kyranet released this 01 Aug 09:22
· 345 commits to main since this release

Very large update with many changes, tl;dr on changes, all methods prefixed with print render an element to the canvas, *Rect is renamed to *Rectangle, *Beveled is renamed to *Rounded, and removed support for Buffer in all methods that previously accepted this, instead, you must use loadImage (from canvas or canvas-constructor).

Also new website! https://canvasconstructor.js.org

Added

  • Added hex util to format hexadecimal strings into a valid color string.
  • Added rgb util to format the parameters into a valid color string.
  • Added rgba util to format the parameters into a valid color string.
  • Added hsl util to format the parameters into a valid color string.
  • Added hsla util to format the parameters into a valid color string.
  • Added color util to provide type safety when picking colors.
  • Added Canvas#createEllipseClip.
  • Added better types for Canvas#process.
  • Added better types for Canvas#toBuffer{Async}.
  • Added better types for Canvas#toDataURL{Async}.
  • Added better types for Canvas#toBlob{Async}.
  • Added ESM support.
  • Added treeshaking support for web bundles.
  • Added lots of documentation and examples.

Changed

  • Renamed createRectClip to createRectangleClip.
  • Renamed clearPixels to clearRectangle.
  • Renamed addRect to printRectangle.
  • Renamed addStrokeRect to printStrokeRectangle.
  • Renamed addCircle to printCircle.
  • Renamed addText to printText.
  • Renamed addStrokeText to printStrokeText.
  • Renamed addWrappedText to printWrappedText.
  • Renamed addResponsiveText to printResponsiveText.
  • Renamed addBeveledRect to printRoundedRectangle.
  • Renamed addCircularImage to printCircularImage.
  • Renamed addBeveledImage to printRoundedImage.
  • Renamed addPattern to printPattern.
  • Renamed createRoundPath to createCircularPath.
  • Renamed createRoundClip to createCircularClip.
  • Renamed createRectPath to createRectanglePath.
  • Renamed createRectClip to createRectangleClip.
  • Renamed createBeveledPath to createRoundedPath.
  • Renamed createBeveledClip to createRoundedClip.
  • Renamed addLinearColorGradient to printLinearColorGradient.
  • Renamed addLinearStrokeGradient to printLinearStrokeGradient.
  • Renamed addRadialColorGradient to printRadialColorGradient.
  • Renamed addRadialStrokeGradient to printRadialStrokeGradient.
  • Renamed createEllipse to createEllipsePath.
  • Renamed addImage to printImage.
  • Modified addImage to take Image | Canvas instead of Buffer | Image, you must use loadImage.
  • Modified addCircularImage to take Image | Canvas instead of Buffer | Image, you must use loadImage.
  • Modified addBeveledImage to take Image | Canvas instead of Buffer | Image, you must use loadImage.
  • Modified addPattern to take Image | Canvas instead of Buffer | Image, you must use loadImage.
  • Modified createPattern to take Image | Canvas instead of Buffer | Image, you must use loadImage.
  • Modified printPattern to take Image | Canvas instead of Buffer | Image, you must use loadImage.
  • Changed website, we are now using a typedoc generated one rather than the half-broken one.
  • Changed bundler from webpack to rollup.
  • Rewritten the library to strict TypeScript.

Fixed

  • Browser support is now fully operational.
  • Fixed typing conflicts with canvas, since they added typings recently.
  • Fixed interface callback types, the this parameter is now typed.

Removed

  • Removed options in addImage. Use printCircularImage or printRoundedImage instead.
  • Removed addRoundImage. Use printCircularImage instead, beware that (x, y) is the centre and not top-left.
  • Removed registerFont from Canvas, use the export from canvas instead.
  • Removed support for canvas-prebuilt. canvas already comes with them.