This is a stub types definition for paper (https://github.com/paperjs/paper.js).
paper provides its own type definitions, so you don't need @types/paper installed!
This is a stub types definition. paper provides its own type definitions, so you do not need this installed.
Stub TypeScript definitions entry for paper, which provides its own types definitions
This is a stub types definition for paper (https://github.com/paperjs/paper.js).
paper provides its own type definitions, so you don't need @types/paper installed!
0.12.18
options.reduceAttributes
option for SVG export (#1895).0.12.17
{ willReadFrequently: true }
canvas context option where needed (#2008).0.12.16
Item#rasterize()
bounds cache when reusing raster.{ willReadFrequently: true }
canvas context option where needed (#1999, #2000, #2003).Path.*
constructor properties handling when passing { insert: true }
Raster#setImageData()
to #putImageData()
.Raster#setImageData()
to also respect image size.Numerical.ANGULAR_EPSILON
for Path#arcTo()
0.12.15
husky
introduced in v0.12.13
0.12.13
Item#rasterize()
(#1905).0.12.12
Item#raster({ resolution, insert })
to receive options object, while remaining backward compatible.Raster#smoothing
to support the values 'low'
, 'medium'
, 'high'
and 'off'
. Setting to a boolean value is still supported, translating false
→
'off'
and true
→ 'low'
.Item#rasterize({ raster })
: By providing an existing raster in options.raster
, the raster and maybe even its underlying canvas can be reused, as long as the rasterized size doesn't change between rasterizations. This allows for big performance improvements.0.12.11
0.12.9
CanvasProvider
to allow experimenting with
https://www.npmjs.com/package/canvaskit-wasm on Node.jsPath.strokeBounds
that was incorrect for certain paths (#1824).0.12.8
Path#strokeBounds
for open paths (#1817).Tween.update()
.Item#scaling
to a new value after it was set to zero (#1816).Raster#initialize(object)
documentation (#1815, #1782).Item#getItem(options)
documentation.0.12.7
options.paperFeatures.moduleExports
work
independently from options.paperFeatures.operatorOverloading
.0.12.6
options.paperFeatures.moduleExports
to control
module exports conversion.0.12.5
options.paperFeatures.operatorOverloading
to control
operator overloading.new Raster(HTMLCanvasElement)
constructor (#1745).CurveLocation
on paths with only one segment.CompoundPath.compare()
(#1769).Path
items with blend mode and no segments (#1763).getCrossingSegments()
(#1773).Raster#drawImage(CanvasImageSource)
(#1784).'paper-'
prefix in generated view ids.0.12.4
O(n^2)
to nearly O(n)
by the use of the
sweep and prune algorithm (#1737).PathItem#getCrossing()
to not return overlaps (#1409).Curve.getIntersections()
(#1638).CurveLocation.isCrossing()
(#1419, #1263).SymbolItem#hitTestAll()
to return only one match per symbol item
(#1680).Shape
sizes (#1733).Color
strings with percentages (#1736).Shape
bounds when passing position in constructor (#1686).0.12.3
Item#internalBounds
.Color
change propagation (#1672, #1674).Symbol
(#1668).Item#contains()
(#1651).Item#clipMask
(#1673).0.12.2
Group#clipItem.matrix
in Group#internalBounds
(#1427).Path#arcTo()
where from
and to
points are equal (#1613).new Raster(size[, position])
constructor (#1621).Item#matrix
is not invertible (#1580).<switch/>
support (#1597).Item#insert()
method from being overridden (#1392).0.12.1
new Raster(size[, position])
constructor.Raster#context
accessor.Raster#clear()
method to clear associated canvas context.Color.random()
documentation.Tween#then()
documentation.0.12.0
Another release, another new member on the team: Please welcome
@arnoson, who has worked hard on the all new
animation support, exposed through the Tween
class and its various methods on
the Item
class, see below for details:
Tween
class and related methods on Item
, to animate and
interpolate their various properties, including colors, sub-properties, etc.:
Item#tween(from, to, options)
, Item#tween(to, options)
,
Item#tween(options)
, Item#tweenFrom(from, options)
,
Item#tweenTo(to, options)
Group#selectedColor
(#1571).Item.once()
to actually only emit event once.0.11.8
This is the first release in quite a while, and it was made possible thanks to two new people on the team:
A warm welcome to @sasensi and @sapics, the two new and very active maintainers / contributors! :tada:
Their efforts mean that many issues are finally getting proper attention and
solid fixes, as we are paving the way for the upcoming release of 1.0.0
. Here
the fixes and additions from the past two weeks:
paper
object from polluting the global scope (#1544).Path#arcTo()
always passes through the provide through point
(#1477).Raster
images (#1437).Path#flatten()
(#1338).Symbol
items from causing issues with transformations (#1561).Raster
images positions in SVG import (#1328).Shape#toPath()
(#1374).Item#locked
(#1436).Curve#getTimesWithTangent()
and Path#getOffsetsWithTangent()
as a way to
get the curve-times / offsets where the path is tangential to a given vector.Raster#smoothing
to control if pixels should be blurred or repeated when a
raster is scaled up (#1521).PaperScript
to export from executed code, supporting export default
,
named exports, as well as module.exports
.0.11.5
Curve#isSelected()
to correctly reflect the state of #handle1
(#1378).0.11.4
0.11.3
doubleclick
events (#1316).Item#rotation
and #scaling
and fixing situations caused by wrongly
caching Item#position
and #bounds
values.0.11.2
0.11.1
0.11.0
.0.11.0
paper
module on NPM into: paper
, paper-jsdom
and
paper-jsdom-canvas
(#1252):paper
is the main library, and can be used directly in a browser
context, e.g. a web browser or worker.paper-jsdom
is a shim module for Node.js, offering headless use with SVG
importing and exporting through jsdom.paper-jsdom-canvas
is a shim module for Node.js, offering canvas
rendering through Node-Canvas
as well as SVG importing and exporting through
jsdom.options.position
to hit Item#position
(#1249).Item#copyTo()
into #addTo()
and #copyTo()
.Item#applyMatrix = false
(#1289).PathItem#subtract(path, options)
(#1221).options.trace
as a way to perform boolean operations on
the strokes / traces instead of the fills / areas of the involved paths
(#1221).Item#applyMatrix = false
(#1238).Item#style
to an
object (#1277).mousedrag
events (#1247, #1286).Item#applyMatrix = false
(#1250).left
/ top
/ right
/ bottom
/ center
values (#1147).insert = false
in new Path.Constructor()
initialization (#1305).#exportSVG()
(#1254).@link
references to bean properties.0.10.3
Canvas
module, and treat
its absence like a headless web worker context in the browser (#1103).Item#_set()
, #set()
and #initialize()
:#_set()
for actually setting internal properties, e.g. on Point
,
Size
, so that derived classes can reuse other parts without having to
override each individual function (e.g. in SegmentPoint
)#set()
as a shortcut to #initialize()
on all basic types, to
offer the same amount of flexibility when setting values, accepting object
literals as well as lists of value arguments.h
/ v
commands for horizontal /
vertical lines in SVG output.true
as the last entryPathItem.create()
as well as
the CompoundPath
constructor to create all sub-paths.View#zoom
and View#center
through matrix decomposition, and
implement additional decomposed properties such as #scaling
and #rotation
.PathItem#resolveCrossings()
into #resolveCrossings()
and
#reorient()
(#973).Path#divideAt(location)
, in analogy to Curve#divideAt(location)
.PathItem#compare()
as a way to compare the geometry of two paths to see
if they describe the same shape, handling cases where paths start in different
segments or use different amounts of curves to describe the same shape.Curve#hasLength()
as an optimized check for curve-length (#1109).Curve#classify()
to determine the type of cubic Bézier curve via
discriminant classification, based on an approach described by Loop and Blinn,
and use it to simplify curve self-intersection handling (#773, #1074, #1235).Curve.getPeaks()
as a fast way to retrieve points that are often similar
to the more costly curvature extrema for use in curve offsetting.Curve. getCurveLineIntersections()
for use in curve offsetting.Line.getDistance()
and use it in Curve.getOverlaps()
(#1253).Segment#isSmooth()
and use it in handling of stroke-joins.Item#rotation
and #scaling
, but only allow matrix
decomposition-based properties on items with #applyMatrix = false
(#1004, #1177).Path
is open and the other closed (#1089).null
exceptions during complex boolean operations (#1091).divideLocations()
(#1191).Curve#getIntersections()
(#1174).getOverlaps()
to always return overlaps in correct sequence (#1223).CurveLocation#isCrossing()
, by finding
unambiguous vectors, taking the curve's loop, cusp, inflection, and "peak"
points into account (#1073, #1074).Path#getStrokeBounds(matrix)
from accidentally modifying segments
(#1102).Numerical.findRoot()
(#1149).#applyMatrix = false
( #1225).Curve#divideAt(offset)
(#1230).Curve#isStraight()
where handles were checked incorrectly
for collinearity (#1269). Line#getSide()
imprecisions when points are on the line.Project#hitTestAll()
(#536).option.class
value in Project#hitTest()
(#632).Numerical.TOLERANCE = 1e-6
as there is no internal use for it
anymore.0.10.2
0.10.1
0.10.0
release.0.10.0
This is a huge release for Paper.js as we aim for a version 1.0.0
release
later this year. As of this version, all notable changes are documented in the
change-log following common CHANGELOG conventions.
Paper.js now also adheres to Semantic Versioning.
There are many items in the changelog (and many more items not in the changelog) so here a high-level overview to frame the long list of changes:
Boolean operations have been improved and overhauled for reliability and efficiency. These include the path functions to unite, intersect, subtract, exclude, and divide with another path.
There was a large amount of work implementing test coverage under QUnit.
Mouse and key handling has been re-engineered and extended to work with view. Many outstanding bugs have been fixed with mouse and key handling.
Many SVG-handling enhancements and bug-fixes, including handling browser- specific interpretations of the SVG standard, have been added.
There are API name changes for more consistency as well as some required by
changes in the EcmaScript 6 standard (e.g., Symbol
→ SymbolDefinition
).
Even though it is not new, since version 0.9.22
Paper.js no longer resizes
the canvas to match the view. The canvas must be resized independently.
Thank you all for using Paper.js, submitting bugs and ideas, and all those that contribute to the code.
PathItem#unite()
, #subtract()
, #intersect()
, #exclude()
, #divide()
:time
parameter or boolean second parameter causing
the argument to be interpreted as curve-time instead of offset are now
separate functions with distinct names (#563):Curve#getNormalAt(time, true)
→ #getNormalAtTime(true)
Curve#divide()
→ #divideAt(offset)
/ #divideAtTime(time)
Curve#split()
→ #splitAt(offset)
/ #splitAtTime(time)
Curve#getParameterAt(offset)
→ #getTimeAt(offset)
Curve#getParameterOf(point)
→ getTimeOf(point)
Curve#getPointAt(time, true)
→ #getPointAtTime(time)
Curve#getTangentAt(time, true)
→ #getTangentAtTime(time)
Curve#getNormalAt(time, true)
→ #getNormalAtTime(time)
Curve#getCurvatureAt(time, true)
→ #getCurvatureAtTime(time)
CurveLocation#parameter
→ #time
Path#split(offset/location)
→ #splitAt(offset/location)
PathItem#getIntersections()
and #getCrossings()
.PathItem#smooth()
now accepts an options.type
string specifying which
smoothing algorithm to use: 'asymmetric'
(default), 'continuous'
,
'catmull-rom'
, and 'geometric'
(#338).PathItem#flatten()
: argument has been changed from tolerance
(maximum
allowed distance between points) to flatness
(maximum allowed error) (#618).0.5.0
, the last small version.1.20.0
.8.3.0
, to benefit from integrated image and canvas support.Item#removeOn()
calls.Tool
(#595).false
to call event.stop()
, stopping event
propagation and prevent the default browser behavior.event.preventDefault()
is called by default after any handled mouse mouse
events, except 'mousemove'
, and only on a 'mousedown'
event if the view
or tool respond to 'mouseup'
.#windingRule
to #fillRule
on Item
and Style
.Item#children
with new one
when the name is identical.#strokeScaling
to PathItem
and Shape
(#721).#smooth()
are segments or curves from
incorrect paths.Matrix#concatenate()
to #append()
and preConcatenate()
to
#prepend()
.Matrix#shiftless()
and #orNullIfIdentity()
internal functions.View#update()
calls to minimize the number of times a
canvas is redrawn (#830, #925).Symbol
now clashes with ES6 definition of Symbol and has been changed
(#770):Symbol
→ SymbolDefinition
PlacedSymbol
→ SymbolItem
Symbol#definition
→ SymbolDefinition#item
PlacedSymbol#symbol
→ SymbolItem#definition
Style#font
property.parameter
to time
for Postscript-style drawing commands.Item#clone()
: optional argument is now an options object with defaults
{insert: true, deep: true}
. insert
controls whether the clone is inserted
into the project and deep
controls whether the item's children are cloned.
The previous boolean optional argument is still interpreted as the insert
option (#941).Matrix
properties #b
and #c
have been reversed to match common standard.#importSVG()
: improve handling of style inheritance for nested <defs>
.PaperScript#execute()
URL argument into options.url
(#902).==
to equals() calls for
Point,
Sizeand
Color` (#1043).View
.'keydown'
and 'keyup'
events to View
(#896).View#requestUpdate()
function to minimize number of actual canvas
redraw.View#matrix
to allow matrix transformation to be accessed and modified
directly on the view (#832).#exportSVG()
):{ precision: value }
option.#fillRule
through the SVG fill-rule
attribute.#blendMode
through the CSS mix-blend-mode
attribute.#getItems()
on Project
and Item
:{ recursive: false }
as a way to prevent iterating over
all children of children.{ match: function() {} }
, so the match function can be
passed in combination with other options.Item#copyAttributes()
and Item#copyContent()
, and use them in
Item#clone()
.insert
boolean argument to Path#toShape()
, Shape#toPath()
,
Item#rasterize()
. Default is to insert, set to false
to prevent the
created item from being inserted into the scene graph.Project#addLayer()
and Project#insertLayer()
(#903).project.layers[name]
(#491).Matrix#prepended()
and #appended()
to return copies of the modified
matrix.Shape#hitTest()
: Add boolean option options.stroke
(#911).Raster#onLoad()
events on Raster#setImage()
now (#924).Raster#onError()
event support (#849).View#autoUpdate
(default: true
)(#921).1px
default strokeWidth
for SVG imports to fix IE/Edge default (#467).ImportSVG()
passes imported SVG data to onLoad
callback as second
parameter.#interpolate
for Segment
, Path
, and CompoundPath
(#624).CompoundPath#flatten()
, #simplify()
, #smooth()
(#727).#hitTestAll()
to return all items that were hit (#536).#importSVG()
implements option.onError
callback (#969).settings.insertItems
controls whether newly created items are inserted or
not (default: true
).#importSVG()
option.insert
(default: true
) to control insertion
(#763).#exportSVG()
to control output bounds and transformation
matrix (#972).Item#position
to be selected via Item#position.selected
(#980).tolerance
argument to Path#join(path, tolerance)
.Curve#getOffsetAtTime(time)
, as the reverse of
Curve#getTimeAt(offset)
.Raster#loaded
to reflect the loading state of its image.Item#strokeBounds
for all possible combinations of
Item#strokeScaling
and Item#applyMatrix
for Path
, Shape
and
SymbolItem
, along with correct handling of such strokes in Item#hitTest()
(#697, #856, #1014). #contains()
checks on path with horizontal lines
(#819).Path#getInteriorPoint()
in rare edge-cases.Item#hitTest()
(#617).doubleclick
events on Group
(#834).#key
values in key-events that do not match character (#881).ctrl-alt-del
key sequence on Chrome/Windows
(#800).7.0.0
and newer (#821).Raster#source
correctly on Node.js (#914).Path
items within CompoundPath
(#912).CompoundPath#insertChildren()
when it is a child items array of a CompoundPath
.#strokeScaling
in Shape
hit-tests (#697).#hitTest()
and #contains()
cases (#819, #884).#simplify()
(#920).#importSVG()
now supports percentage dimensions and
gradientUnits="objectBoundingBox"
. (#954, #650).Group
items with clip-masks now calculate correct bounding boxes (#956).event.stopPropagation()
in 'mousedown'
handler no longer prevents
'mousedrag'
events (#952).Item
shadows when #shadowBlur
is zero (#955).Item
bounds from permanently collapsing to 0 when applying non-
invertible transformations (#558).Path#arcTo()
correctly handles zero sizes.#importSVG()
handles onLoad
and onError
callbacks for string inputs that
load external resources (#827).#importJSON()
and #exportJSON()
now handle non-Item
objects correctly
(#392).#exportSVG()
now exports empty paths if used as a clip-mask.#importJSON()
no longer generates callstack exceeded exceptions (#764).Group#importJSON()
(#785).Item#importJSON()
where #parent
is null
when calling it
on existing, already inserted items (#1041).event.delta
on mousedrag events (#981).Item#removeChildren()
fully removes children (#991).View
and Item
(#995).#importSVG()
: Improve handling of viewBox.Path#unite()
(#1000).Path
item's bounds without selecting the segments
(#769).Item#insertChildren()
, when inserting children that
were previously inserted in the same parent (#1015).PathItem#closePath()
to handle imprecise SVG data due to
rounding (#1045).Numerical.solveQuadratic()
and
Numerical.solveCubic()
for edge-cases (#1085).Canvas attributes "resize" and "data-paper-resize" no longer cause paper to
resize the canvas when the viewport size changes; Additional CSS styles are
required since 0.9.22
, e.g.:
/* Scale canvas with resize attribute to full size */
canvas[resize] {
width: 100%;
height: 100%;
}
Color
constructors (removed in 0.9.25
): GrayColor
, RgbColor
,
HsbColor
, HslColor
, and GradientColor
. These have been replaced
with corresponding forms of the Color
constructor.Project#addChild()
that added a layer to a project.
It is replaced by Project#addLayer()
and Project#insertLayer()
.#windingRule
on Item
and Style
→ #fillRule
Curve#getNormalAt(time, true)
→ #getNormalAtTime(true)
Curve#divide()
→ #divideAt(offset)
/ #divideAtTime(time)
Curve#split()
→ #splitAt(offset)
/ #splitAtTime(time)
Curve#getParameterAt(offset)
→ #getTimeAt(offset)
Curve#getParameterOf(point)
→ getTimeOf(point)
Curve#getPointAt(time, true)
→ #getPointAtTime(time)
Curve#getTangentAt(time, true)
→ #getTangentAtTime(time)
Curve#getNormalAt(time, true)
→ #getNormalAtTime(time)
Curve#getCurvatureAt(time, true)
→ #getCurvatureAtTime(time)
CurveLocation#parameter
→ #time
Path#split(offset/location)
→ #splitAt(offset/location)
Symbol
→ SymbolDefinition
PlacedSymbol
→ SymbolItem
Symbol#definition
→ SymbolDefinition#item
PlacedSymbol#symbol
→ SymbolItem#definition
Project#symbols
→ #symbolDefinitions
Matrix#concatenate
→ #append
Matrix#preConcatenate
→ #prepend
Matrix#chain
→ #appended
GradientStop#rampPoint
→ #offset