Skip to content

Releases: samizdatco/skia-canvas

v3.0.8

25 Sep 20:41

Choose a tag to compare

Bugfix

  • Fix rendering to windows with semi-transparent backgrounds

Full Changelog: v3.0.7...v3.0.8

v3.0.7

19 Sep 21:02

Choose a tag to compare

Bugfix

  • Added missing TypeScript definitions for resizable property (thanks to @goldenratio #265)

Misc. Improvements

Full Changelog: v3.0.6...v3.0.7

v3.0.6

28 Aug 19:02

Choose a tag to compare

Bugfix

  • Fixed Windows CI build

Full Changelog: v3.0.5...v3.0.6

v3.0.5

28 Aug 19:02

Choose a tag to compare

v3.0.5 Pre-release
Pre-release

Misc. Improvements

  • Decreased memory usage when drawing one canvas's contents onto another (via drawImage or drawCanvas).
  • Reduced dependency footprint (from 294 to 22 modules when installed with devDependencies included):
    • replaced nodemon with node --watch
    • replaced jest with node --test for unit tests
    • replaced express with hono for visual tests
    • dropped lodash and fast-glob usage in test suite

Full Changelog: v3.0.4...v3.0.5

v3.0.4

23 Aug 04:38

Choose a tag to compare

Misc. Improvements

  • When installing the module, any proxy server defined via npm config set proxy or an HTTPS_PROXY environment variable will be used to fetch the prebuilt binary
  • Replaced fetch altogether, now using Node's built-in http and https modules for better backward compatibility, support for additional request parameters for loadImage(), and a further reduction in the number of npm dependencies (now down to 8)

Bugfixes

  • Variable fonts can now correctly function as fallbacks (previously only the first-matched font in a stack would be converted to a usable instance)

Full Changelog: v3.0.3...v3.0.4

v3.0.3

20 Aug 15:43

Choose a tag to compare

Bugfix

  • Fixed a segfault where windows on Vulkan platforms were being deallocated incorrectly upon close.

Full Changelog: v3.0.2...v3.0.3

v3.0.2

17 Aug 15:48

Choose a tag to compare

Misc. Improvements

  • Only use node-fetch on systems lacking a built-in fetch
  • Dropped fast-glob (reducing external dependency count to 11)

Breaking Changes

Full Changelog: v3.0.1...v3.0.2

v3.0.1

17 Aug 00:26

Choose a tag to compare

Bugfixes

Full Changelog: v3.0.0...v3.0.1

v3.0.0

15 Aug 22:13

Choose a tag to compare

New Features

GUI

  • The App global now has an eventLoop property which can be set to:
    • "native" (the default) in which case the Node event loop is suspended while the OS handles displaying GUI windows
    • "node" where the Node event loop maintains control (allowing setInterval and setTimeout to run) and handles GUI events manually every few milliseconds (though note some of the caveats associated with the Winit feature this uses).
  • Window objects now have a read-only closed property and emit a close event when they are closed. Closed windows can later be re-opened by calling the new open() method.
  • The new borderless attribute allows Window titlebars and borders to be hidden (thanks to @hydroperx #230)

Imagery

  • The loadImage() and loadImageData() helpers now use node-fetch to handle web requests and can accept a fetch options object as the final argument.
  • Image objects can now be created by passing a Buffer or dataURL-containing string as a constructor argument and will be immeditately drawable (no asynchronous loading required).
  • Added support for integrating the Sharp image processor into canvas workflows (if the sharp npm module has been installed):
    • The new Canvas.toSharp() & ImageData.toSharp() convenience methods convert their contents to a Sharp bitmap object
    • loadImage() & loadImageData() can now be called with a Sharp object as their sole argument
    • The src property on a new Image object can be set to a Sharp object and it will begin asynchronously loading
  • Added new options to createTexture() for setting the line cap style and selecting whether vector patterns should be clipped or outlined

Rendering

  • Significant speed-ups for deeply layered drawing in which the canvas isn't cleared or reset (potentially resulting in numerous vector objects being re-drawn despite being hidden by shapes drawn on top):
    • The bitmap generated by getImageData()/toBuffer()/toFile() is now cached. When called repeatedly, only newly added drawing commands will need to be rasterized (and will be layered atop the bitmap saved in the prior call).
    • Window contents are now cached between screen refreshes, improving performance during resizing and in cases where the canvas is drawn to in multiple passes and not cleared with every frame
    • Calling clearRect() or fillRect() with an area that covers the canvas now erases all the vector shapes below
  • The toFile(), toBuffer(), and toDataURL() methods now accept an optional downsample flag (for jpegs only), which enables 4:2:0 chroma-subsampling. By default, no subsampling (a.k.a. 4:4:4) will be performed
  • The getImageData() method now accepts additional rendering arguments (density, matte, and msaa) which behave the same as their equivalents in the toFile() method.

Typography

  • Text lightness can now be fine-tuned through a pair of optional arguments that can be passed to the Canvas or Window constructors:
    • textContrast — a number in the range 0.0–1.0 controlling the amount of additional weight to add (defaults to 0.0)
    • textGamma — a number in the range 0.0–4.0 controlling how glyph edges are blended with the background (defaults to 1.4)
  • The textAlign attribute can now be set to "justify"
  • measureText() has been rewritten to calculate metrics based not just on the font specified in font but also any fallback fonts that were used for character glyphs not present in the ‘main’ font. The line-by-line measurements now include a runs array with bounds and metrics for each single-font range of characters on the line.

Supported Platforms

  • Added precompiled binaries for Arm-based Windows systems
  • Now providing pre-built ‘layer’ archives for use with AWS Lambda (for Node v20 and above)
  • Linux builds now include a statically linked version of fontconfig, as a result:
    • libfontconfig packages no longer need to be installed on the host system using apt, apk, yum, dnf, etc.
    • it now runs on ‘serverless’ platforms like Vercel without modification (sadly Cloudflare doesn't support native modules at all though)

Breaking Changes

  • Renamed export functions and options to be more consistent with similar browser APIs and other Node modules:
    • saveAs() and saveAsSync() are now called toFile() and toFileSync()
    • toDataURL() now behaves the same as its browser equivalent: it is synchronous and its only configuration option is a numerical quality setting
    • toDataURLSync() has been removed
    • toURL() and toURLSync() produce data URLs and support the same enhanced export options as toBuffer
  • When exporting to an SVG, text is now converted to paths only if the outline option is set to true

Misc. Improvements

  • App.launch() now returns a Promise that resolves when the final window is closed, allowing you to schedule code to run before the process would otherwise exit (see also the new idle event which fires under the same circumstances).
  • input event objects now contain an inputType property to distinguish between insertion, deletion, and IME composition
  • Mouse events are no longer coalesced down to a single instance per frame (most relevant for mousemove events)
  • Mouse events now include a standard buttons attribute
  • DPI metadata is now included in webp files (reflecting the density option passed to toFile() or toBuffer())
  • Argument validation now emulates browser behavior much more closely—including converting what were previously TypeErrors in certain cases into silent failures. To reënable these errors, set the SKIA_CANVAS_STRICT environment variable to 1 or true.
  • Replaced node-pre-gyp with a custom installation script and glob with fast-glob, cutting the number of node_modules directories installed from 83 to 29.
  • loadImage(), loadImageData(), and Image.src can now accept URL objects (using http(s), file, or data protocols). Likewise, toFile() now accepts file: URLs (allowing relative paths to be constructed with import.meta.url)
  • The Canvas constructor's options argument can now contain a gpu property which can be set to false in order to use CPU-based rendering

Bugfixes

  • Setting a window's cursor property to "none" now hides the cursor
  • Spurious moved window events are no longer emitted during resizes
  • resize events now update the window object’s width & height properties in addition to providing the new size in the event object
  • roundRect() now reflects context's current transform state and accepts plain {x, y} objects for corner-...
Read more

v2.0.2

28 Jan 04:19

Choose a tag to compare

New Features

  • Added fontHinting attribute (off by default to better match font weights in browser rendering). Setting it to true may result in crisper edges but adds some weight to the font.

Bugfixes

  • Text spacing
    • Setting letterSpacing no longer indents text at beginning of line
    • letterSpacing now properly handles negative values

Misc. Improvements

  • Improved accuracy of measureText()
    • Now uses font metrics' default leading when the line-height is left unspecified in the ctx.font string (NB: this is likely to cause vertical shifts for non-alphabetic baselines)
    • Updated baseline offset calculations for middle & hanging to better match browsers
    • The actualBoundingBox* & lines[].x/y/width/height rectangles returned by measureText() are now just the glyph-occupied area, not the whole line-height of the textblock
    • Fixed the sign on actualBoundingBoxLeft (positive values now mean left of the origin)
    • lines[].baseline now corresponds to the selected ctx.textBaseline, previously it was always the alphabetic baseline
  • TypeScript definitions no longer include the entire DOM library (which had been pulling in tons of non-Canvas-related object types that this library doesn't emulate)