Added
- Add
PathItem#offset(distance, options), which grows, shrinks or offsets paths and compound paths with miter, round or bevel corners (#371). - Add
PathItem#outline(options), which turns the stroke of a path item into a filled path item, with its joins, caps and dashes (#371). - Add
PathItem#dash(options), which cuts a stroke into its dashes as the canvas draws them, as a group of open paths. - Add stroke profiles,
Path#strokeProfile: stops along a path that change the width, aspect and angle of the pen that draws its stroke, seeStrokeProfileStop. Not yet supported: compound paths,strokeScalingoff, andoffset(), boolean operations,interpolate()and SVG (#2505, #2506, #2507). - Add live effects,
Item#effects, which change what an item draws without changing the item, starting withoffsetandoutline.Effectdefines new ones, andItem#previewBoundsmeasures what they draw. - Add pattern colors from a
PatternDefinition, which tiles a raster or any other item, for fills and strokes, also in SVG and JSON (#829). - Add
Color#aspectfor elliptical radial gradients, and transform gradients exactly with their items, also when these scale unevenly or shear (#1744). - Add
Group#buffered, which keeps a group's drawing in a canvas until the group changes, for large groups that rarely do (#377). - Add
Item#onDrawandItem#onDrawSelection, which draw beneath an item or its selection, or replace them, also as class-level handlers such asPath.onDraw. - Add
PathItem#arcAround(center, angle)andPathItem#arcTowards(to)(#1052). - Support
optionsinPathItem#simplify(), withtoleranceand a range of segments throughfromandto, as inPathItem#smooth()(#2501). - Export and import the names and data of segments in SVG, as a
data-paper-segmentsattribute (#2398). - Add
Project#onActivateandProject#onDeactivate, also asProject.onActivateandProject.onDeactivatefor all projects. - Pass the import attributes of
import … with { … }in PaperScript on to the loader inoptions.loadofPaperScript.execute(). - Hosted projects, see
Project#host:- Share symbol and pattern definitions between items, referred to by their keys in JSON, and let scripts create new ones.
- Load the pixels of rasters from the host on first access.
- Load items in full when they move into a project with another host.
- Call
Item#onDrawandItem#onDrawSelection, throughProject#draw().
Changed
- Run the library in strict mode, which makes
Path#getNearestPoint()about 14% andItem#hitTest()about 6% faster. PaperScript still runs in sloppy mode. - Draw items with opacity, blend modes or shadows about twice as fast (#377).
- Make
PaperScope#projectan accessor, so that PaperScript'sprojectfollows the active project, asviewdoes. - Emit
deactivatewhen the active project or tool is removed. - Write the definition of symbol items to JSON as
definitioninstead ofsymbol, which still loads. - Let hosted linked text that moves into a project with another host bring a copy of its story along (#2462, #2463).
Fixed
- Fix boolean operations that could lose areas or whole results, at straight curves, near-coincident crossings, curves running back and forth along a line, shallow crossings and merged vertices.
- Measure curve lengths precisely near cusps, where
Curve#getLength()andPath#getPointAt()were off by up to 6%. - Find the nearest point on curves that cover a lot of ground between their samples, in
#getNearestPoint()and the methods using it. - Fix
PathItem#smooth()with a negativetoon closed paths, which threw. - Fix
PathItem#arcTo()with tiny arcs, which missed their end point. - Keep the attributes of compound paths in
CompoundPath#reduce()when a single child is left. - Return
falsefromCompoundPath#simplify()without children. - Keep the stripes of linear gradients across them when transforming them unevenly (#1744).
- Export the gradients of items that keep their matrix to SVG in the coordinates of their elements (#2410).
- Honor the
boundsandmatrixoptions ofItem#exportSVG(). - Keep
Group#isolatedandGroup#bufferedin clones. - Keep the content of rasters when setting
Raster#size. - Load
new Raster(source)from a string where there is no document, as in workers. - Draw the segments of selected paths again by default (#1899).
- Count the duration of
Item#tween()from the first frame. - PaperScript: compile
++and--correctly wherever they appear, keep keywords apart from replaced expressions in minified code, report the right lines in stack traces on V8, and return an object fromcompile()for empty code. - Hosted projects: leave items that moved away out of
Project#takeChanges(), and turn offView#autoUpdatewhen settingProject#host. - Let Angular's esbuild builder bundle Paper.js for browsers (#2035).