v0.17.0
- 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().
- 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).
- 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).
v0.16.0
- Add the
processNodeoption to#exportSVG()and theprocessItemoption to#importSVG(): callbacks that receive{ item, node }for each exported item with its SVG node and each imported SVG element with its item, and can return a replacement, e.g. to keep the SVGclassattribute inItem#data(#1843). - Let
Rectangle#scale()take a center point to scale from, asItem#scale()does, and normalize rectangles scaled by negative amounts (#1352). - Add
Segment#nameandSegment#data, stored in JSON but not in SVG. Named segments can be accessed by name throughPath#segments, as named items throughItem#children(#1459). - Add
Style#paintOrderandItem#paintOrder:'stroke'paints the stroke before the fill of paths, shapes and text, as in SVG'spaint-order, which is exported and imported (#1731). - Lay out right-to-left text in the order it reads: the pieces of the lines of paragraphs whose
directionis'rtl'are placed, hit and exported from the right, path text runs from the path's end towards its start, and canvas measures and draws text in its paragraph's direction (#2389). - Export layers to SVG with a
data-paper-layerattribute, and import the groups that carry it asLayeritems again, inside the imported group (#483). - Add
SymbolItem#embed(), which replaces a symbol item with a copy of its definition's item, transformed by the symbol item's matrix and combined with its opacity, visibility, blend mode and other attributes (#953). Project#currentTextStylein hosted projects: the style new text items take in place ofProject#currentStylewhen the host sets one, for hosts whose new text has defaults of its own, such as a black fill without a stroke.- Add
Point#values,Size#valuesandRectangle#values, which give their numbers as an array, asMatrix#valuesdoes.
- Apply the
data-*attributes of imported SVG elements toItem#databefore calling theprocessItemcallback of#importSVG(), so that it can extend the data, instead of after it, which replaced the data that it stored. Items that the callback returns as replacements no longer receive the data.
- The undocumented
onExport(item, node, options)andonImport(node, item, options)options of#exportSVG()and#importSVG(), replaced byprocessNodeandprocessItem.
- Only call the import callback of
#importSVG()for SVG elements, not also for the document of SVG strings, which received the item of its root element a second time. - Leave out the item itself and its ancestors when inserting children, which created a cycle in the scene graph and overflowed the stack, e.g. in
new Group({ children: [new Layer()] }), and returnnullfromItem#insertChildren()when none of the items can be inserted (#2406). - Keep the text path of hosted
PathTextandAreaTextitems when the host changes them:Project#invalidate()loads its new geometry into the path that scripts hold, which it replaced before. - Hit-test the strokes of shapes as those of their paths, which
Shapeonly approximated for ellipses and rounded corners, and for non-scaling strokes under non-uniform matrices (#2334).
v0.15.0
- Load text items from the host of a hosted project, see
Project#host, with their stories, and the paths and settings of path and area text, and let hosts lay them out as their documents do, throughhost.layOut(), given their JSON as the script holds them, also before the host has its changes, ornullfor text the script didn't change, which the host has as it is. - Add text ranges:
TextRange, a part of a text whose style properties read what its letters and paragraphs share and set them, fromTextItem#range(start, end),#runs,#paragraphs,#words,#lettersand#lines, which ranges have too, and#replace(content, start, end), andTextStory, a text's content, runs and paragraphs, asTextItem#story. - Add text linking:
TextItem#link(),#unlink(),#isLinked(),#nextTextItem,#previousTextItemand#visibleRange, by which a story flows through several text items, whichTextStory#textItemslists. - Add
PathText, text along a path betweenstartOffsetandendOffset, each letter turned to the path, which it takes asTextItem#textPath. - Add
AreaText, text inside any path as itstextPath, holes too, in columns and rows, with lines breaking between words and at soft hyphens,verticalAlign,fitHeight(), andlineWrap, a paragraph property that balances the lines. - Add
Item#textWrap, by which items push aside the text of the area texts below them in their layer, or let it flow inside them. - Export area text, text on paths and text with mixed styles to SVG: point text keeps a
<tspan>per line, with one per run where styles are mixed, and area text and text on paths are placed piece by piece, as they are laid out. - Add character style properties:
fontStyle,lineHeight,letterKerning,letterScaling,letterRotation,baselineShift,baselinePosition,capitals,underlineandstrikethrough, andfontVariationsandfeaturesfor hosts. - Add paragraph style properties:
justifyLast,startIndent,endIndent,firstLineIndent,spaceBefore,spaceAfteranddirection, the justifications'start','end'and'justify', andjustifySpacing,hyphenation,composerandtabsfor hosts. - Let
Item#strokeBoundsbe selected and set, asItem#boundscan:item.strokeBounds.selecteddraws the stroke bounds and their handles, independently ofitem.bounds.selected, and setting them scales the item so its stroke bounds match, also where its stroke's extent changes with its proportions, as with miters (#1030). - Import the
data-*attributes of SVG elements intoitem.data, with their names camelized as indataset, next todata-paper-data(#1227). - Export shadows to SVG as SVG 1.1 filters, which both browsers and editors such as Illustrator render, except for items without width or height, and import them back, along with CSS
drop-shadow()(#1003). - Import SVG masks as clip masks, which is exact for masks of solid white shapes, or of opaque shapes with
mask-type="alpha", and warns that other masks are approximated (#1916). - Add
Group#ungroup(), which replaces a group with its children, applying its matrix to them, and letItem#replaceWith()take several items (#1026). - Add
settings.segmentSize, the size of the segments when drawing selections, next tosettings.handleSizefor their handles, which it defaults to (#1899). - Add
angleInRadiansto the object literals that create points, next toangle, e.g.new Point({ length: 10, angleInRadians: Math.PI / 2 })(#562). - Add
Project#hasChanges(), which tells whether changes were logged since the lastProject#takeChanges(), without taking them. - Add dynamic
import(specifier)to PaperScript, which resolves to the module's namespace through the loader inoptions.load, which may return a Promise. - Add static
importto PaperScript, through a loader that hosts pass asoptions.loadtoPaperScript.execute(), together withexport … from. It needs a current Acorn asself.acorn. - Add
Item.getBounds(items[, options]), the bounds of a list of items in project coordinates as if they were grouped, e.g. of the selection (#2252). - Add
ToolEvent#velocityand#elapsed, the velocity of the mouse since the last tool event in points per second, and the time since then in seconds, which stay even when the system misses a mouse report. - Add
Event#time, the time of the event in seconds, as frame events have it, andoptions.timetoView#dispatchMouseEvent()and#dispatchKeyEvent(). - Add a setter to
View#bounds, which fits the view to the given rectangle, asView#fitBounds()does. - Let
PathItem#unite(),#intersect(),#subtract()and#exclude()take an array of paths, which they combine in one call: unite, intersect and subtract in a balanced tree, exclude in one even-odd pass. Uniting 500 paths takes 0.22 s instead of 2.9 s chained, excluding them 0.45 s instead of minutes (#2094, #2303, #2304). - Load hosted text that the host links into one story, which
host.getStory()gives once for all of its items, whichever of them loads first.
- Lay out text by the ascent and descent of its fonts: the bounds of
PointTextare its lines' line heights, with the leading split around their ascent and descent, instead of 3/4 of the first above its baseline and 1/4 of the last below. - Replace
leadingbylineHeight,'auto'(1.2) or another factor of the font size, or a fixed length;leadingstill sets and reads a fixed line height in pixels. RenametrackingtoletterTracking, whichtrackingstill sets and reads. - Make
Style#getFontStyle()return the CSS font style,'normal','italic'or'oblique', instead of the font as canvas takes it, and removeStyle#getTrackingStyle(). - Only go into the children that items show in
Item#getItems(), and log the changes of children that their parent doesn't show, such as a text's path, as the parent's. - Make
Item#intersects()check whether the items overlap, also when one contains the other, asRectangle#intersects()does, instead of only whether their outlines cross, and use it ingetItems({ overlapping })for items whose bounds contain the rectangle (#1751). - Use
settings.hitTolerancefor the mouse events of items, such asmouseenterandclick, which always hit-tested with a tolerance of 0 (#1971). - Keep the named exports of PaperScript modules with a default export:
export default xnow setsmodule.exports.defaultinstead of replacing the exports, and such modules are marked with__esModule.import xreceives the default export, or the whole exports of CommonJS-style modules, andimport * as mall exports, with CommonJS-style ones also asm.default. SoPaperScript.execute()returns{ default: x }forexport default x. - Deprecate
Event#timeStampin milliseconds, and theoptions.timeStampofView#dispatchMouseEvent()and#dispatchKeyEvent(), for the newtimein seconds. - Rename the
paper-sourced.jsbuild topaper-hosted.js, andProject#sourcetoProject#host, to matchHostItemand the host document that backs the items. - Draw dashes with
setLineDash(), which every canvas supports, and remove the dash emulation for canvases without it, along with the undocumentedpaper.support.nativeDash(#2350). - Trace the results of boolean operations through a planar graph of the operands' curves, which each operation builds within one geometric tolerance: intersections within it merge into one vertex, curves that pass within it of a vertex are cut there, and coincident curves become one edge. Results are correct to within about five times that tolerance, under a thousandth of a unit on a drawing of 1,000 units, and stable under tiny moves of the operands. They can differ from before in where their contours start and how they are divided, but not in their areas. Holes come out oriented opposite to their outlines, and islands like outlines (#2292).
PathItem#resolveCrossings()returns the filled outline of a path, without the inner loops that its fill rule covers (#2292).- Make boolean operations faster than in 0.14.0 on all inputs measured, from about 15% on small operations up to 5.7× on large polygons (#2293, #2296, #2297, #2299, #2300, #2301, #2302, #2305).
- Draw the CSS blend modes as
'normal'in old browsers whose canvas doesn't support them, such as Internet Explorer and the old Edge, instead of emulating them pixel by pixel. Paper.js's own modes, such as'add', are still emulated (#2350). - Remove the undocumented statics
Curve.getBounds(values), a leftover of old intersection code, andCurve.getCurveLineIntersections(), which nothing in the library calls. - Drop the code for browsers without current DOM APIs, which only old IE, Edge and WebKit needed: MS pointer events,
srcElement,toElement,keyIdentifier,backingStorePixelRatio, and the exception ofgetBoundingClientRect()for nodes outside the DOM (#2350).
- Hit-test strokes with
'miter'and'bevel'joins next to smooth segments, which are joined round, as the stroke bounds already treat them (#2342). - Update
Item#strokeBoundsafter changing the stroke of items without a parent, such as shapes, texts, symbol items and groups, which kept the old stroke bounds (#2343). - Fix
Path#handleBoundsof empty paths, which were infinite: they are an empty rectangle, as theirbounds(#2345). - Import the paragraphs of text items after their content, also from JSON that lists them first, as JSON written by other tools may.
- Keep gradients in the runs of text items through
#exportJSON()and#importJSON(), and round their style values and those of their paragraphs to theprecisionof the export (#2348). - Keep what scripts write to hosted items before they load, such as their
pivotor an area text'scolumns, which loading replaced. - Fix the stroke bounds of non-scaling strokes under non-uniform matrices, whose miters, bevels and square caps followed the untransformed angles.
- Fix
Item#strokeBoundsafter scaling items that apply their matrix, such as paths and groups, when they were read before: the cached stroke bounds were scaled along, including the width of the stroke, which doesn't scale. - Fix SVG export of
opacityandblendMode, which aren't inherited, so children with the same values as their group lost them, and the defaults were written where the group differed. - Fix the shadows of items that are both filled and stroked, which only cast the shadow of their fill, partly covered by the stroke (#892).
- Fix the shadows of text items, which only text with both a fill and a stroke drew (#2347).
- Fix the points at offsets of
PathFlatteneron straight curves, such as lines without handles, whose curve-time doesn't follow their length, which placed them off everywhere but at the ends. - Fix SVG import of
<use>elements, which now pass their styles and those of their parents on to the referenced element, as in SVG, instead of the styles of the place where it is defined, and skip circular references (#2090). - Divide the operands of boolean operations at all their intersections, also where they only touch, which makes the results of near-coincident geometry more stable, and ends the endless loop of #1849.
- Fix
Curve#getTimeOf()for points near the ends of straight curves, which it solved to times far from the ends, as it only tested the ends exactly. - Fix boolean operations that backtracked while tracing their result, which could give a curve of it the handle of a dead end and make it bulge.
- Measure text in views without a canvas of their own, such as in workers, with a canvas from
CanvasProvider, e.g. anOffscreenCanvas, soPointTexthas bounds there too. - Fix PaperScript's exported variable declarations without semicolons, such as
export const a = 1, which compiled to invalid code. - Fix
Curve#classify()reporting points of inflection, cusps and loops at the very ends of curves, which made boolean operations miss crossings at those vertices (#1879, #1387). - Fix PaperScript's compound assignments of properties, such as
array[index()] += 1, which evaluated their object and key twice. - Fix PaperScript with a current Acorn provided as
self.acorn, which parses all current syntax now, and its exports: of functions and classes, of renamed names (export { a as b }), of several declarations in a row, and of variables, which stay usable in the script itself. - Fix intersections of curves and lines at the curves' ends, which were lost when the curve touched the line there, e.g. at a zero-length handle (#1848).
- Fix the orientation of the results of
PathItem#exclude()and#subtract(), whose parts of the second path kept its reversed orientation, giving them negative areas (#2064). - Fix
PathItem#interiorPointreturning points on the path itself, such as a vertex shared with another path, which made boolean operations of paths that only touch keep or drop the wrong parts (#1837, #1979). - Fix intersections and boolean operations of curves and paths that only touch, at coordinates beyond 16384, where the tolerance of their bounds checks got lost in floating point (#1940, #1882).
- Fix boolean operations on open paths that end where they start, which lost the curve between their ends (#1929, #1973, #1989, #2018).
- Fix boolean operations with
{ trace: false }on closed paths, which could keep or drop the wrong parts depending on where the path started, and on compound paths, which threw an error (#1540, #1541, #1746, #1998, #2046). - Document
Item#fullySelected, which all items have, not only paths (#1687). - Type options objects from their documented options, such as those of
Item#hitTest(),#exportSVG()and#rasterize(), so misspelled options are errors in TypeScript (#1666). - Type the setters of point, size, rectangle and color properties with the values they accept, such as
item.position = [10, 20]anditem.fillColor = 'red'. The typings now need TypeScript 4.3 (#1665). - Handle the mouse events of
View#dispatchMouseEvent()also outside the view's bounds, since the host decides which events belong to its drawing surface. - Fix boolean operations on paths that touch or overlap along their edges, run close to each other, or cross near their vertices, which lost or added parts of their results (#1285, #1362, #1867, #1917, #1943, #1961, #2002, #2036, #2096, #2099).
- Fix
PathItem#resolveCrossings()on paths with both overlaps and crossings, which lost parts of their outlines (#2290). - Fix
Curve.getTimeOf()at coordinates beyond about 2e8, where it didn't recognize points on the curve (#2291). - Hit-test non-scaling strokes under non-uniform matrices where they're drawn, also next to corners, joins and caps, and with skewed or rotated matrices (#2334).
- Fix
Curve#strokeBoundsof curves without a path, which threw: without a path, there is no stroke, so they are the curve's bounds (#2344). - Give
View#dispatchKeyEvent()the characters of space, enter and tab, as the DOM's key events have them, instead of empty ones (#2346). - Fix
paper.support.nativeBlendModes, which listed the blend modes canvas accepted as170instead oftrue, and only knew the CSS blend modes where a canvas was available when Paper.js loaded. It lists the canvas composite modes and the CSS blend modes as native, and Paper.js's own modes as not, without testing canvas (#2349). - Hit-test strokes at segments where the curves meet in the same direction, such as where a line runs into a curve, whatever the join, also across curves without length, as in rectangles rounded to half their height.
- Calculate
Curve#getTimesWithTangent(),#lengthandCurve.getPeaks()precisely also far from the origin, from the curve's polynomial coefficients, which take the differences of the points first.
v0.14.0
- Add
options.handlerstoPaperScript.execute(), to export further global handlers next toonFrame,onResizeand the tool's, for hosts that call them themselves, such as Scriptographer'sonStop. - Add
Tool#eventInterval, as Scriptographer had it, to fireonMouseDragagain at an interval while the mouse button is held, also when the mouse doesn't move. - Add
Project#scope,View#scope,Item#scopeandTool#scope, to get from each of them to itsPaperScope(#1634). - Add
Group#isolated, to draw a group or layer through a temporary canvas, so that the blend modes of its children, such as'destination-out', only apply within it, like CSS'sisolation: isolate(#474). - Add
View#dispatchMouseEvent()andView#dispatchKeyEvent(), to feed mouse and key events from hosts without a DOM, such as workers, through the same handling as the DOM's events, for tools, items and views. - Add
settings.scaleStrokes, to scale the stroke widths of paths and compound paths along with their content when matrices are applied (#2098, #1514). - Add the
paper-sourced.jsbuild, in which a project's items can be backed by a host document throughProject#source: items are created as light shells from the host's records, and load their content and children from the host on first access, so a script costs what it touches. IncludesHostItem, for the host's own kinds of nodes (#2203). - Add
Project#trackChangesandProject#takeChanges(), to let hosts that keep their own document update only the items that changed, and exportChangeFlag(#2202).
Path.RegularPolygon()follows Illustrator: it stands on a flat bottom edge for any number of sides, and its segments run counterclockwise from its top vertex, or with an even number of sides, from the right end of its top edge. This changes the segment order of all regular polygons, and turns those with a multiple of 6 sides onto an edge (#1787).- Hit-test transparent fills, as in SVG: only items without a fill color are not hit through their fill (#1157).
paper.install()keeps what the target scope has already, such as the nativeEvent,MouseEventandSymbol, and PaperScript doesn't shadow existing globals with Paper.js's classes of the same name either (#1832, #1652).Item#importJSON()into an existing item resets the fields that the JSON leaves out, so the item ends up the same as a newly imported one, with its place in the scene graph and its event handlers kept (#1425, #1324).- Canvases without
resizeget their CSS size from the view on every screen, not only at pixel ratios other than 1, where the page's CSS won (#2088). #hitTestAll()reports every segment and handle of a path within the tolerance, closest first, followed by its stroke or fill hit, instead of only the first hit per path (#1294).
- Create the tool in PaperScript for all of its global handlers, also for scripts that only define
onActivate()oronDeactivate(), and documentTool#onActivateandTool#onDeactivate. - Keep
Key.modifiersin sync with the flags of mouse events, so modifier keys pressed or released while the page didn't have the focus don't stay wrong (#1140). - Keep Paper.js's own blend modes, which CSS doesn't have, such as
'destination-out', through SVG export and import, in adata-paper-blend-modeattribute (#1296). - Throw a clear error when creating an item without a project, instead of a null access deep inside the constructor (#1889).
- Free the pixels of temporary canvases when they're released, which their pool kept allocated at their largest size for the life of the page.
- Keep the size of rasters in JSON, so imported rasters have their size and bounds before their image has loaded, or if it fails to load (#1598).
- Fix the frame timer of workers and Node.js running forever after any script, which kept hosts from seeing scripts end.
- Fix touch scrolling over empty parts of a canvas whose items have mouse handlers (#1930).
- Fix mouse events reaching items and views through elements that cover the canvas, such as menus. Drags still reach beyond them (#992).
- Fix the points of
#hitTestAll()results of items inside transformed groups, which were in the items' own coordinates. - Support
strokeScaling: falseon text, exactly for uniform scaling (#1703). - Fix the view size of canvases inside elements with CSS transforms, which only scale the canvas on screen.
- Fix italic and oblique font weights in SVG export and import, which SVG keeps in
font-style(#937). - Fix
onFramein web workers, where views have no element (#2200). - Fix
PaperScope#execute()in web workers (#2201).
v0.13.0
- Add a
forceparameter toView#update(), to redraw the view even when nothing changed, e.g. after a web font has loaded (#1913). - Add
View#fitBounds(rectangle[, fit]), to fit a rectangle into the view.fittakes the values of CSS'sobject-fit:'contain'and'cover'(#1688). - Add the
reuseImagesoption to#exportSVG(), to export images shown by several rasters only once, and place them with<use>elements (#1993). - Add
trackingto the text styles: the space added after each character, in thousandths of an em, as in Adobe Illustrator and InDesign.#exportSVG()and#importSVG()write and read it asletter-spacing(#2066). - Add
easeInSine,easeOutSine,easeInOutSine,easeInExpo,easeOutExpo,easeInOutExpo,easeInCirc,easeOutCircandeaseInOutCirctoTween(#1855). - Add the
idPrefixoption to#exportSVG(), prepended to the generated ids of definitions, so that separately exported SVGs can be placed in one document (#1709). - Add the
crossOriginoption to#importSVG(), passed on to the rasters of<image>elements, so that canvases drawing them aren't tainted (#1094). - Add
View#project(#1634). - Add
Point#clamp(min, max), e.g. to keep a point inside a rectangle withpoint.clamp(rect.topLeft, rect.bottomRight). - Use
OffscreenCanvasin web-workers, soItem#rasterize(),new Raster(size), items with opacity or blend modes, and CSS color names, which resolved to black, work there.Raster#toDataURL()remains unsupported in web-workers (#1643).
- Time double-clicks from mousedown to mousedown and only within 3 pixels, as native
dblclickevents do, and don't take a third click for another double-click (#1451). - Make
Rectangle#left,#right,#topand#bottommove only their own side, as documented, and the corner points only their two sides, keeping the opposite ones where they are. They used to move the whole rectangle, unless another side was set before. This also applies toItem#bounds: setting a side or corner of an item's bounds now stretches the item. To move items, setbounds.point,bounds.center,bounds.xorbounds.y(#2024, #1147). - Hit-test groups wherever one of their children is hit, as in Illustrator, so
hitTestAll()always returns the groups above the hit items, andhitTest(point, { class: Group })finds the group under a point. Groups were only hit when all their children shared a fill (#2069). - Let inline
styledeclarations override presentation attributes in#importSVG(), as in CSS and browsers:<rect fill="blue" style="fill: red">now imports red (#1962). - Keep the pixels of images in
#importSVG()and scale them to their size in the SVG, instead of resampling them to that size, which made them blurry.Raster#sizeis now the image's own size, and images without a size are shown at it, as in browsers (#1963). - Let
Item#clone(), the boolean operations,Item#rasterize(),Path#toShape()andShape#toPath()followsettings.insertItemswhen noinsertoption is passed, instead of always inserting their results. An options object withoutinsertalso inserts the clone by default now, as documented, e.g.clone({ deep: false })(#1721). - Use jsdom's own
XMLSerializerfor#exportSVG()on Node.js, instead of a shim that returned HTML, so the output is valid XML with escaped attribute values, as in browsers. Empty elements are now self-closing (#1922). Item#fitBounds(rectangle[, fit])takes the values of CSS'sobject-fitasfit:'contain','cover'and'fill', which stretches the item to the rectangle.- Scale and align images in
#importSVG()as theirpreserveAspectRatiodescribes, fitting them into their box uniformly and centered by default, as browsers do, instead of stretching them.sliceis treated asmeet(#1129). - Let
Path#removeSegments(from, to)wrap around on closed paths whenfromis larger thanto, instead of removing nothing (#1881). - Read the
hrefof<image>elements in#importSVG()always as a URL, no longer as the id of a DOM element first.
- The boolean
fillparameter ofItem#fitBounds(): use'cover'instead oftrue.
- Remove the workaround for wrong
mouseoutcoordinates in old versions of Chrome on Windows (#1811). - Remove the CLA from the contribution guidelines, as it no longer exists (#2071).
- Fix
require('paper')in the Node.js REPL (#2019, #1792). - Fix loading PaperScript in bundles that leave the top-level
thisundefined, as in ES modules (#1480). - Prevent source-map-loader from warning about the source map string in PaperScript (#1991).
- Fix replacing style colors that were set as strings, which threw in strict mode (#2049).
- Fix SVG path data with arc flags that aren't separated from the numbers after them, as SVGO writes them (#1808, #1885).
- Fix
#importSVG()of gradients, fills, clip paths and<use>elements that reference definitions appearing later in the document (#1146, #1884, #1978). - Fix
#importSVG()of elements with numeric ids (#1754). - Fix
#importSVG()of rounded rectangles with onlyrxorry(#1863). - Fix
#exportSVG()writingfill-rule="none",font-family="none"etc. on groups with differently styled children (#1732). - Fix
Curve#handleBounds, which threw, to only include the curve's own points (#1992). - Fix
Curve#getTimesWithTangent()for curves without a cubic component, such as quadratic curves (#1870). - Fix
ShapeJSON import withtypeafterradius(#1820). - Fix boolean operations with
trace: falseorstroke: trueignoringoptions.insert(#2028). - Fix gradients drawn with
strokeScaling: false(#1821, #1822). - Fix the selection of items in symbol definitions being drawn (#1577).
- Fix
View#zoomof mirrored views, which was 0 (#1411). - Fix item mouse handlers that stopped working after removing items whose parent was already removed, or after moving items to another project (#2079, #1791).
- Fix key events with Control, Alt and Meta in Firefox and other browsers that fire no
keypressfor them (#1997, #1871). - Fix the space key staying down after Option + Space on macOS.
- Fix key events not reaching a view that became visible after the focused one was hidden (#1953).
- Load in DOMs whose canvas has no 2D context, as jsdom without canvas in jest, and run there as in workers (#1805).
- Keep the original error as
causewhen jsdom or canvas fail to load on Node.js (#1759). - Fix
#getItems()and#getItem()with a match function or without options to search recursively, as documented, instead of matching only the top-level items. - Fix
#importSVG()of transforms and styles on<use>elements that reference groups (#978). - Fix the
projectandparentoptions of thePath.*constructors. Withinsert: false, they no longer insert into the parent, asnew Path()doesn't either (#2012). - Fix the bounds of transformed circle and ellipse shapes (#1826).
- Fix
PointText#strokeBoundsto include the stroke, which got cut off when drawn with opacity (#1322). - Fix the
Item#boundssetter on items with zero width or height, which made their matrix non-invertible (#1794). - Fix
#getItems()withoverlapping, which never matched shapes, rasters and texts, as their matrix was applied twice (#1300). - Fix the bounds of items whose matrix cancels out the matrix of their parent (#1457).
- Fix the source URL and source map of PaperScript loaded from script tags, which were lost (#1753).
- Fix stroke hit-tests at the ends of paths with butt caps, which missed even the end points (#1460).
- Fix
Path#splitAt()with locations that aren't on the path, which split the path at its start instead of returningnull. - Fix clipping with groups that are clipped themselves, as imported SVG with a
viewBoxis, which clipped with their own clip mask too (#1618). - Fix
Item#hitTest()and#hitTestAll()on items inside transformed groups, which took the point in their parent's coordinates instead of the documented global ones (#1803). - Ignore
View#zoomvalues that aren't positive numbers, which left the view's matrix without an inverse, so thatView#boundsthrew (#1433). - Fix the hit-test tolerance of items inside transformed groups and of symbol items, which their transformations scaled. It is now in project coordinates, as documented (#1278).
- Limit the temporary canvases of items with opacity or blend modes to the visible area, so large groups no longer disappear or make zooming slow (#1644, #1920, #1925, #2001, #2029).
- Support SVG 2's plain
hrefattribute in#importSVG(), besidesxlink:href, for<use>,<image>and gradient links. - Fix
#exportSVG()of groups used as clip masks, which were exported as groups inside<clipPath>, where only shapes are allowed, so browsers clipped everything away (#1445, #1590). - Keep the lines of multi-line text in
#exportSVG()and#importSVG(), as<tspan>elements at their own baselines (#988). - Fix shadows being cut off on items with a fill, a stroke and an opacity, which are drawn through a temporary canvas (#1628).
- Fix
#importSVG()of<use>elements that place images, which weren't positioned and sized, as their rasters were cloned before the image loaded. - Fix
Item#fitBounds()andView#fitBounds()with empty rectangles or items: empty sides no longer collapse items, produceNaNcoordinates with'cover', or make the view throw; they are left out of the scaling. - Fix
#importSVG()of lengths inin,cm,mm,ptandpc, which were read as pixels (#1919). - Fix
#importSVG()of percentages inside nested<svg>elements, which referred to the size of the root instead of the nearest<svg>(#1404). - Fix
#importSVG()on Node.js of shapes without a fill, which were imported without one instead of black, as in browsers (#1229). - Fix the quadratic time of
#exportSVG()for groups with many children (#1353). - Implement the documented
'pin-light'blend mode, which drew nothing (#1527). - Fix clip masks of items with a matrix and an opacity or blend mode, which clipped in the wrong place (#1594).
- Fix rasters and point texts used as clip masks, which clipped with the path drawn before them. They now clip with their rectangle and bounds (#1845).
- Fix the stroke bounds of sheared, mirrored and non-uniformly scaled paths with
applyMatrix: false. The miter limit is now checked in the path's own coordinates, as canvas does (#2065). - Fix symbol items overwriting the
globalMatrixof their definition's item, which affected its stroke bounds and selection (#1684). - Fix the view size of canvases with padding or border, which grew with each setup of a project for them (#1160, #2033).
- Fix setting
View#rotationon mirrored views, which rotated the other way, and on non-uniformly scaled views, which got skewed (#1893). - Fix touches outside of the view taking over its drag (#1875).
- Fix hit-tests of point texts ignoring the tolerance (#632).
- Fix removed selected items being kept by their project, which leaked memory (#1856).
- Fix the line width of selections, which used whatever line width the view's context was left with.
- Fix hit-tests of symbol items with
class,typeandmatchfilters, which were applied to the definition's items instead (#1774). - Leave
workspacesandresolutionsout of the publishedpackage.json, which made Yarn warn when installing paper (#1921). - Fix stale
Item#globalMatrixand#localToGlobal()results of items whose sibling was asked first after their parent was transformed, and of items moved to another parent or removed (#1750). - Fix the points of mouse and touch events on canvases with padding or border, with a CSS size that differs from the view size, or under CSS transforms that scale them, which were offset or scaled (#549, #1729).
- Fix the sign of
Line#getSignedDistance()for lines whose direction has two negative coordinates (#1880). - Fix outdated bounds of nested groups after changes to items two or more levels down, and of groups containing placed symbols after changes to the symbol definition (#940).
- Docs: Mark the
pathargument ofPathItem#getIntersections()as optional. - Docs: Add
View#onKeyDown,View#onKeyUp,Point#negate(),Size#negate(),PaperScope#createCanvas(),#clear()and#remove(). - Docs: Correct the defaults of the hit-test options, the results of the math operator examples,
Raster#sourceandItem#guide, and documentPath#reduce()'ssimplifyoption, nullable location getters, optional arguments,ToolEvent#tool, which items have children, how group styles,getItems()ordering,Rectangle#selectedandTool#onMouseMovework, and theresizecanvas attribute (#2078, #2092, #2030, #1928, #1947, #1907, #1900, #2115, #1645, #1697, #1747, #1507, #604, #1330, #662). - Docs: Add examples to the boolean path operations (#1007).
- Docs: Document that
new Path(pathData)holds a single sub-path (#2057). - Docs: Document that styles set on symbol items, or inherited by imported
<use>elements, don't reach the symbol definition's items (#1329). - Docs: Document using Paper.js with a bundler in the README (#1695).
- Docs: Move the documentation of
<symbol>and<use>fromProject#importJSON()toProject#importSVG().
v0.12.20
- Keep the native
SymbolinPaperScope#install(), which replaced it with the deprecatedpaper.Symbolalias ofSymbolDefinition.paper.Symbolitself still works. - Support jsdom 20 and newer in Node.js: find jsdom's internals where jsdom 28 moved them, and run in worker mode without the canvas module again, which failed to load before.
- Update
paper-jsdomto jsdom 28, andpaper-jsdom-canvasto jsdom 28 and canvas 3, which install on current Node.js versions. Both now require Node.js 20.19, 22.12 or 24 and newer.
v0.12.19
- Fix XSS in
#importSVG(): imported SVG is now attached to a sandboxed iframe instead of the page while its styles are computed, so it can't run scripts or load resources (#2100).
#importSVG()is no longer affected by the page's style sheets. Style sheets inside the imported SVG still apply.
- Restore
settings.applyMatrixandsettings.insertItemswhen#importSVG()fails. - Fix
new Path.Rectangle(rectangle, radius),new Shape.Rectangle(rectangle, radius)andItem#fitBounds(rectangle, fill)when the rectangle is given as an array or object literal. - Fix
new Raster(source, position)ignoring the position. - Fix
new Path.Arc()handling ofinsert:{ insert: false }shadowedPath#insert(), and{ insert: true }was ignored. - Fix tweening of points, colors and relative values in
paper-core, which relied on PaperScript. - Fix setting
ToolEvent#count, which had no effect. - Fix
new Shape({ type: 'circle', radius })without a size, which threw. - Fix
View#getPixelSize()returningNaNfor views without an element, as in web workers, which brokeleadingfor font sizes in units other than pixels. - Only publish the intended files to npm, removing an accidental copy of the whole distribution from the package (12.3 MB → 6.2 MB unpacked).
v0.12.17
- Properly warning in Chrome Console by providing
{ willReadFrequently: true }canvas context option where needed (#2008).
v0.12.16
- Fix
Item#rasterize()bounds cache when reusing raster. - Fix new warning in Chrome Console by providing
{ willReadFrequently: true }canvas context option where needed (#1999, #2000, #2003). - Fix
Path.*constructor properties handling when passing{ insert: true }
- Rename
Raster#setImageData()to#putImageData(). - Change
Raster#setImageData()to also respect image size. - Add separate
Numerical.ANGULAR_EPSILONforPath#arcTo()