Prebuilt module for commit b6f0aaaf5d0aafeaf96e9bccee4763d8ce71f037

This commit is contained in:
Paper.js Bot 2020-06-22 15:30:35 +00:00
parent fdbab46e5d
commit 9f6061dfc1
17 changed files with 229 additions and 196 deletions

View file

@ -9,7 +9,7 @@
*
* All rights reserved.
*
* Date: Mon Jun 22 16:32:39 2020 +0200
* Date: Mon Jun 22 17:26:35 2020 +0200
*
***
*
@ -3891,22 +3891,35 @@ new function() {
this.setName(name);
},
rasterize: function(resolution, insert) {
rasterize: function(arg0, arg1) {
var resolution,
insert,
raster;
if (Base.isPlainObject(arg0)) {
resolution = arg0.resolution;
insert = arg0.insert;
raster = arg0.raster;
} else {
resolution = arg0;
insert = arg1;
}
if (!raster) {
raster = new Raster(Item.NO_INSERT);
}
var bounds = this.getStrokeBounds(),
scale = (resolution || this.getView().getResolution()) / 72,
topLeft = bounds.getTopLeft().floor(),
bottomRight = bounds.getBottomRight().ceil(),
size = new Size(bottomRight.subtract(topLeft)),
raster = new Raster(Item.NO_INSERT);
size = new Size(bottomRight.subtract(topLeft)).multiply(scale);
raster.setSize(size, true);
if (!size.isZero()) {
var canvas = CanvasProvider.getCanvas(size.multiply(scale)),
ctx = canvas.getContext('2d'),
var ctx = raster.getContext(true),
matrix = new Matrix().scale(scale).translate(topLeft.negate());
ctx.save();
matrix.applyToContext(ctx);
this.draw(ctx, new Base({ matrices: [matrix] }));
ctx.restore();
raster.setCanvas(canvas);
}
raster.transform(new Matrix().translate(topLeft.add(size.divide(2)))
.scale(1 / scale));
@ -5403,20 +5416,23 @@ var Raster = Item.extend({
this, 'setSize');
},
setSize: function() {
setSize: function(_size, _clear) {
var size = Size.read(arguments);
if (!size.equals(this._size)) {
if (size.width > 0 && size.height > 0) {
var element = this.getElement();
var element = !_clear && this.getElement();
this._setImage(CanvasProvider.getCanvas(size));
if (element)
if (element) {
this.getContext(true).drawImage(element, 0, 0,
size.width, size.height);
}
} else {
if (this._canvas)
CanvasProvider.release(this._canvas);
this._size = size.clone();
}
} else if (_clear) {
this.clear();
}
},

View file

@ -3271,28 +3271,26 @@ for (var i = 0; i < 20; i++) {
<div id="rasterize" class="member">
<div class="member-link">
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([resolution[, insert]])</tt></a>
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([options])</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Rasterizes the item into a newly created Raster object. The item itself is not removed after rasterization.</p>
<ul class="member-list">
<h4>Options:</h4>
<li><tt>resolution: <tt>Number</tt></tt> &mdash; the desired resolution to be used when rasterizing, in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used by default. &mdash;&nbsp;default: <tt>view.resolution</tt></li>
<li><tt>raster: <a href="../classes/Raster.html"><tt>Raster</tt></a></tt> &mdash; specifies a raster to be reused when rasterizing. If the raster has the desired size already, then the underlying canvas is reused and no new memory needs to be allocated. If no raster is provided, a new raster item is created and returned instead. &mdash;&nbsp;default: <tt>null</tt></li>
<li><tt>insert: <tt>Boolean</tt></tt> &mdash; specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the rasterized item. &mdash;&nbsp;default: <tt>true</tt></li>
</ul>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>resolution:</tt>
<tt>Number</tt>
&mdash;&nbsp;the resolution of the raster in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used.
&mdash;&nbsp;optional, default: <tt>view.resolution</tt>
</li>
<li>
<tt>insert:</tt>
<tt>Boolean</tt>
&mdash;&nbsp;specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the original
&mdash;&nbsp;optional, default: <tt>true</tt>
<tt>options:</tt>
<tt>Object</tt>
&mdash;&nbsp;the rasterization options
&mdash;&nbsp;optional, default: <tt>{}</tt>
</li>
</ul>
@ -3302,7 +3300,7 @@ for (var i = 0; i < 20; i++) {
<h4>Returns:</h4>
<li>
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the newly created raster item
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the reused raster or the newly created raster item
</li>

View file

@ -3139,28 +3139,26 @@ for (var i = 0; i < 20; i++) {
<div id="rasterize" class="member">
<div class="member-link">
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([resolution[, insert]])</tt></a>
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([options])</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Rasterizes the item into a newly created Raster object. The item itself is not removed after rasterization.</p>
<ul class="member-list">
<h4>Options:</h4>
<li><tt>resolution: <tt>Number</tt></tt> &mdash; the desired resolution to be used when rasterizing, in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used by default. &mdash;&nbsp;default: <tt>view.resolution</tt></li>
<li><tt>raster: <a href="../classes/Raster.html"><tt>Raster</tt></a></tt> &mdash; specifies a raster to be reused when rasterizing. If the raster has the desired size already, then the underlying canvas is reused and no new memory needs to be allocated. If no raster is provided, a new raster item is created and returned instead. &mdash;&nbsp;default: <tt>null</tt></li>
<li><tt>insert: <tt>Boolean</tt></tt> &mdash; specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the rasterized item. &mdash;&nbsp;default: <tt>true</tt></li>
</ul>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>resolution:</tt>
<tt>Number</tt>
&mdash;&nbsp;the resolution of the raster in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used.
&mdash;&nbsp;optional, default: <tt>view.resolution</tt>
</li>
<li>
<tt>insert:</tt>
<tt>Boolean</tt>
&mdash;&nbsp;specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the original
&mdash;&nbsp;optional, default: <tt>true</tt>
<tt>options:</tt>
<tt>Object</tt>
&mdash;&nbsp;the rasterization options
&mdash;&nbsp;optional, default: <tt>{}</tt>
</li>
</ul>
@ -3170,7 +3168,7 @@ for (var i = 0; i < 20; i++) {
<h4>Returns:</h4>
<li>
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the newly created raster item
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the reused raster or the newly created raster item
</li>

View file

@ -2900,28 +2900,26 @@ for (var i = 0; i < 20; i++) {
<div id="rasterize" class="member">
<div class="member-link">
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([resolution[, insert]])</tt></a>
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([options])</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Rasterizes the item into a newly created Raster object. The item itself is not removed after rasterization.</p>
<ul class="member-list">
<h4>Options:</h4>
<li><tt>resolution: <tt>Number</tt></tt> &mdash; the desired resolution to be used when rasterizing, in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used by default. &mdash;&nbsp;default: <tt>view.resolution</tt></li>
<li><tt>raster: <a href="../classes/Raster.html"><tt>Raster</tt></a></tt> &mdash; specifies a raster to be reused when rasterizing. If the raster has the desired size already, then the underlying canvas is reused and no new memory needs to be allocated. If no raster is provided, a new raster item is created and returned instead. &mdash;&nbsp;default: <tt>null</tt></li>
<li><tt>insert: <tt>Boolean</tt></tt> &mdash; specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the rasterized item. &mdash;&nbsp;default: <tt>true</tt></li>
</ul>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>resolution:</tt>
<tt>Number</tt>
&mdash;&nbsp;the resolution of the raster in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used.
&mdash;&nbsp;optional, default: <tt>view.resolution</tt>
</li>
<li>
<tt>insert:</tt>
<tt>Boolean</tt>
&mdash;&nbsp;specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the original
&mdash;&nbsp;optional, default: <tt>true</tt>
<tt>options:</tt>
<tt>Object</tt>
&mdash;&nbsp;the rasterization options
&mdash;&nbsp;optional, default: <tt>{}</tt>
</li>
</ul>
@ -2931,7 +2929,7 @@ for (var i = 0; i < 20; i++) {
<h4>Returns:</h4>
<li>
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the newly created raster item
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the reused raster or the newly created raster item
</li>

View file

@ -3055,28 +3055,26 @@ for (var i = 0; i < 20; i++) {
<div id="rasterize" class="member">
<div class="member-link">
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([resolution[, insert]])</tt></a>
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([options])</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Rasterizes the item into a newly created Raster object. The item itself is not removed after rasterization.</p>
<ul class="member-list">
<h4>Options:</h4>
<li><tt>resolution: <tt>Number</tt></tt> &mdash; the desired resolution to be used when rasterizing, in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used by default. &mdash;&nbsp;default: <tt>view.resolution</tt></li>
<li><tt>raster: <a href="../classes/Raster.html"><tt>Raster</tt></a></tt> &mdash; specifies a raster to be reused when rasterizing. If the raster has the desired size already, then the underlying canvas is reused and no new memory needs to be allocated. If no raster is provided, a new raster item is created and returned instead. &mdash;&nbsp;default: <tt>null</tt></li>
<li><tt>insert: <tt>Boolean</tt></tt> &mdash; specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the rasterized item. &mdash;&nbsp;default: <tt>true</tt></li>
</ul>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>resolution:</tt>
<tt>Number</tt>
&mdash;&nbsp;the resolution of the raster in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used.
&mdash;&nbsp;optional, default: <tt>view.resolution</tt>
</li>
<li>
<tt>insert:</tt>
<tt>Boolean</tt>
&mdash;&nbsp;specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the original
&mdash;&nbsp;optional, default: <tt>true</tt>
<tt>options:</tt>
<tt>Object</tt>
&mdash;&nbsp;the rasterization options
&mdash;&nbsp;optional, default: <tt>{}</tt>
</li>
</ul>
@ -3086,7 +3084,7 @@ for (var i = 0; i < 20; i++) {
<h4>Returns:</h4>
<li>
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the newly created raster item
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the reused raster or the newly created raster item
</li>

View file

@ -6210,28 +6210,26 @@ for (var i = 0; i < 20; i++) {
<div id="rasterize" class="member">
<div class="member-link">
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([resolution[, insert]])</tt></a>
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([options])</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Rasterizes the item into a newly created Raster object. The item itself is not removed after rasterization.</p>
<ul class="member-list">
<h4>Options:</h4>
<li><tt>resolution: <tt>Number</tt></tt> &mdash; the desired resolution to be used when rasterizing, in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used by default. &mdash;&nbsp;default: <tt>view.resolution</tt></li>
<li><tt>raster: <a href="../classes/Raster.html"><tt>Raster</tt></a></tt> &mdash; specifies a raster to be reused when rasterizing. If the raster has the desired size already, then the underlying canvas is reused and no new memory needs to be allocated. If no raster is provided, a new raster item is created and returned instead. &mdash;&nbsp;default: <tt>null</tt></li>
<li><tt>insert: <tt>Boolean</tt></tt> &mdash; specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the rasterized item. &mdash;&nbsp;default: <tt>true</tt></li>
</ul>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>resolution:</tt>
<tt>Number</tt>
&mdash;&nbsp;the resolution of the raster in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used.
&mdash;&nbsp;optional, default: <tt>view.resolution</tt>
</li>
<li>
<tt>insert:</tt>
<tt>Boolean</tt>
&mdash;&nbsp;specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the original
&mdash;&nbsp;optional, default: <tt>true</tt>
<tt>options:</tt>
<tt>Object</tt>
&mdash;&nbsp;the rasterization options
&mdash;&nbsp;optional, default: <tt>{}</tt>
</li>
</ul>
@ -6241,7 +6239,7 @@ for (var i = 0; i < 20; i++) {
<h4>Returns:</h4>
<li>
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the newly created raster item
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the reused raster or the newly created raster item
</li>

View file

@ -4914,28 +4914,26 @@ for (var i = 0; i < 20; i++) {
<div id="rasterize" class="member">
<div class="member-link">
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([resolution[, insert]])</tt></a>
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([options])</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Rasterizes the item into a newly created Raster object. The item itself is not removed after rasterization.</p>
<ul class="member-list">
<h4>Options:</h4>
<li><tt>resolution: <tt>Number</tt></tt> &mdash; the desired resolution to be used when rasterizing, in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used by default. &mdash;&nbsp;default: <tt>view.resolution</tt></li>
<li><tt>raster: <a href="../classes/Raster.html"><tt>Raster</tt></a></tt> &mdash; specifies a raster to be reused when rasterizing. If the raster has the desired size already, then the underlying canvas is reused and no new memory needs to be allocated. If no raster is provided, a new raster item is created and returned instead. &mdash;&nbsp;default: <tt>null</tt></li>
<li><tt>insert: <tt>Boolean</tt></tt> &mdash; specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the rasterized item. &mdash;&nbsp;default: <tt>true</tt></li>
</ul>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>resolution:</tt>
<tt>Number</tt>
&mdash;&nbsp;the resolution of the raster in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used.
&mdash;&nbsp;optional, default: <tt>view.resolution</tt>
</li>
<li>
<tt>insert:</tt>
<tt>Boolean</tt>
&mdash;&nbsp;specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the original
&mdash;&nbsp;optional, default: <tt>true</tt>
<tt>options:</tt>
<tt>Object</tt>
&mdash;&nbsp;the rasterization options
&mdash;&nbsp;optional, default: <tt>{}</tt>
</li>
</ul>
@ -4945,7 +4943,7 @@ for (var i = 0; i < 20; i++) {
<h4>Returns:</h4>
<li>
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the newly created raster item
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the reused raster or the newly created raster item
</li>

View file

@ -3062,28 +3062,26 @@ for (var i = 0; i < 20; i++) {
<div id="rasterize" class="member">
<div class="member-link">
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([resolution[, insert]])</tt></a>
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([options])</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Rasterizes the item into a newly created Raster object. The item itself is not removed after rasterization.</p>
<ul class="member-list">
<h4>Options:</h4>
<li><tt>resolution: <tt>Number</tt></tt> &mdash; the desired resolution to be used when rasterizing, in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used by default. &mdash;&nbsp;default: <tt>view.resolution</tt></li>
<li><tt>raster: <a href="../classes/Raster.html"><tt>Raster</tt></a></tt> &mdash; specifies a raster to be reused when rasterizing. If the raster has the desired size already, then the underlying canvas is reused and no new memory needs to be allocated. If no raster is provided, a new raster item is created and returned instead. &mdash;&nbsp;default: <tt>null</tt></li>
<li><tt>insert: <tt>Boolean</tt></tt> &mdash; specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the rasterized item. &mdash;&nbsp;default: <tt>true</tt></li>
</ul>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>resolution:</tt>
<tt>Number</tt>
&mdash;&nbsp;the resolution of the raster in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used.
&mdash;&nbsp;optional, default: <tt>view.resolution</tt>
</li>
<li>
<tt>insert:</tt>
<tt>Boolean</tt>
&mdash;&nbsp;specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the original
&mdash;&nbsp;optional, default: <tt>true</tt>
<tt>options:</tt>
<tt>Object</tt>
&mdash;&nbsp;the rasterization options
&mdash;&nbsp;optional, default: <tt>{}</tt>
</li>
</ul>
@ -3093,7 +3091,7 @@ for (var i = 0; i < 20; i++) {
<h4>Returns:</h4>
<li>
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the newly created raster item
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the reused raster or the newly created raster item
</li>

View file

@ -4087,28 +4087,26 @@ for (var i = 0; i < 20; i++) {
<div id="rasterize" class="member">
<div class="member-link">
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([resolution[, insert]])</tt></a>
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([options])</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Rasterizes the item into a newly created Raster object. The item itself is not removed after rasterization.</p>
<ul class="member-list">
<h4>Options:</h4>
<li><tt>resolution: <tt>Number</tt></tt> &mdash; the desired resolution to be used when rasterizing, in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used by default. &mdash;&nbsp;default: <tt>view.resolution</tt></li>
<li><tt>raster: <a href="../classes/Raster.html"><tt>Raster</tt></a></tt> &mdash; specifies a raster to be reused when rasterizing. If the raster has the desired size already, then the underlying canvas is reused and no new memory needs to be allocated. If no raster is provided, a new raster item is created and returned instead. &mdash;&nbsp;default: <tt>null</tt></li>
<li><tt>insert: <tt>Boolean</tt></tt> &mdash; specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the rasterized item. &mdash;&nbsp;default: <tt>true</tt></li>
</ul>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>resolution:</tt>
<tt>Number</tt>
&mdash;&nbsp;the resolution of the raster in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used.
&mdash;&nbsp;optional, default: <tt>view.resolution</tt>
</li>
<li>
<tt>insert:</tt>
<tt>Boolean</tt>
&mdash;&nbsp;specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the original
&mdash;&nbsp;optional, default: <tt>true</tt>
<tt>options:</tt>
<tt>Object</tt>
&mdash;&nbsp;the rasterization options
&mdash;&nbsp;optional, default: <tt>{}</tt>
</li>
</ul>
@ -4118,7 +4116,7 @@ for (var i = 0; i < 20; i++) {
<h4>Returns:</h4>
<li>
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the newly created raster item
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the reused raster or the newly created raster item
</li>

View file

@ -3638,28 +3638,26 @@ for (var i = 0; i < 20; i++) {
<div id="rasterize" class="member">
<div class="member-link">
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([resolution[, insert]])</tt></a>
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([options])</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Rasterizes the item into a newly created Raster object. The item itself is not removed after rasterization.</p>
<ul class="member-list">
<h4>Options:</h4>
<li><tt>resolution: <tt>Number</tt></tt> &mdash; the desired resolution to be used when rasterizing, in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used by default. &mdash;&nbsp;default: <tt>view.resolution</tt></li>
<li><tt>raster: <a href="../classes/Raster.html"><tt>Raster</tt></a></tt> &mdash; specifies a raster to be reused when rasterizing. If the raster has the desired size already, then the underlying canvas is reused and no new memory needs to be allocated. If no raster is provided, a new raster item is created and returned instead. &mdash;&nbsp;default: <tt>null</tt></li>
<li><tt>insert: <tt>Boolean</tt></tt> &mdash; specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the rasterized item. &mdash;&nbsp;default: <tt>true</tt></li>
</ul>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>resolution:</tt>
<tt>Number</tt>
&mdash;&nbsp;the resolution of the raster in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used.
&mdash;&nbsp;optional, default: <tt>view.resolution</tt>
</li>
<li>
<tt>insert:</tt>
<tt>Boolean</tt>
&mdash;&nbsp;specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the original
&mdash;&nbsp;optional, default: <tt>true</tt>
<tt>options:</tt>
<tt>Object</tt>
&mdash;&nbsp;the rasterization options
&mdash;&nbsp;optional, default: <tt>{}</tt>
</li>
</ul>
@ -3669,7 +3667,7 @@ for (var i = 0; i < 20; i++) {
<h4>Returns:</h4>
<li>
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the newly created raster item
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the reused raster or the newly created raster item
</li>

View file

@ -3030,28 +3030,26 @@ for (var i = 0; i < 20; i++) {
<div id="rasterize" class="member">
<div class="member-link">
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([resolution[, insert]])</tt></a>
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([options])</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Rasterizes the item into a newly created Raster object. The item itself is not removed after rasterization.</p>
<ul class="member-list">
<h4>Options:</h4>
<li><tt>resolution: <tt>Number</tt></tt> &mdash; the desired resolution to be used when rasterizing, in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used by default. &mdash;&nbsp;default: <tt>view.resolution</tt></li>
<li><tt>raster: <a href="../classes/Raster.html"><tt>Raster</tt></a></tt> &mdash; specifies a raster to be reused when rasterizing. If the raster has the desired size already, then the underlying canvas is reused and no new memory needs to be allocated. If no raster is provided, a new raster item is created and returned instead. &mdash;&nbsp;default: <tt>null</tt></li>
<li><tt>insert: <tt>Boolean</tt></tt> &mdash; specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the rasterized item. &mdash;&nbsp;default: <tt>true</tt></li>
</ul>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>resolution:</tt>
<tt>Number</tt>
&mdash;&nbsp;the resolution of the raster in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used.
&mdash;&nbsp;optional, default: <tt>view.resolution</tt>
</li>
<li>
<tt>insert:</tt>
<tt>Boolean</tt>
&mdash;&nbsp;specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the original
&mdash;&nbsp;optional, default: <tt>true</tt>
<tt>options:</tt>
<tt>Object</tt>
&mdash;&nbsp;the rasterization options
&mdash;&nbsp;optional, default: <tt>{}</tt>
</li>
</ul>
@ -3061,7 +3059,7 @@ for (var i = 0; i < 20; i++) {
<h4>Returns:</h4>
<li>
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the newly created raster item
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the reused raster or the newly created raster item
</li>

View file

@ -3144,28 +3144,26 @@ for (var i = 0; i < 20; i++) {
<div id="rasterize" class="member">
<div class="member-link">
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([resolution[, insert]])</tt></a>
<a name="rasterize" href="#rasterize"><tt><b>rasterize</b>([options])</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Rasterizes the item into a newly created Raster object. The item itself is not removed after rasterization.</p>
<ul class="member-list">
<h4>Options:</h4>
<li><tt>resolution: <tt>Number</tt></tt> &mdash; the desired resolution to be used when rasterizing, in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used by default. &mdash;&nbsp;default: <tt>view.resolution</tt></li>
<li><tt>raster: <a href="../classes/Raster.html"><tt>Raster</tt></a></tt> &mdash; specifies a raster to be reused when rasterizing. If the raster has the desired size already, then the underlying canvas is reused and no new memory needs to be allocated. If no raster is provided, a new raster item is created and returned instead. &mdash;&nbsp;default: <tt>null</tt></li>
<li><tt>insert: <tt>Boolean</tt></tt> &mdash; specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the rasterized item. &mdash;&nbsp;default: <tt>true</tt></li>
</ul>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>resolution:</tt>
<tt>Number</tt>
&mdash;&nbsp;the resolution of the raster in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used.
&mdash;&nbsp;optional, default: <tt>view.resolution</tt>
</li>
<li>
<tt>insert:</tt>
<tt>Boolean</tt>
&mdash;&nbsp;specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the original
&mdash;&nbsp;optional, default: <tt>true</tt>
<tt>options:</tt>
<tt>Object</tt>
&mdash;&nbsp;the rasterization options
&mdash;&nbsp;optional, default: <tt>{}</tt>
</li>
</ul>
@ -3175,7 +3173,7 @@ for (var i = 0; i < 20; i++) {
<h4>Returns:</h4>
<li>
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the newly created raster item
<tt><a href="../classes/Raster.html"><tt>Raster</tt></a></tt>&nbsp;&mdash;&nbsp;the reused raster or the newly created raster item
</li>

36
dist/paper-core.js vendored
View file

@ -9,7 +9,7 @@
*
* All rights reserved.
*
* Date: Mon Jun 22 16:32:39 2020 +0200
* Date: Mon Jun 22 17:26:35 2020 +0200
*
***
*
@ -3888,22 +3888,35 @@ new function() {
this.setName(name);
},
rasterize: function(resolution, insert) {
rasterize: function(arg0, arg1) {
var resolution,
insert,
raster;
if (Base.isPlainObject(arg0)) {
resolution = arg0.resolution;
insert = arg0.insert;
raster = arg0.raster;
} else {
resolution = arg0;
insert = arg1;
}
if (!raster) {
raster = new Raster(Item.NO_INSERT);
}
var bounds = this.getStrokeBounds(),
scale = (resolution || this.getView().getResolution()) / 72,
topLeft = bounds.getTopLeft().floor(),
bottomRight = bounds.getBottomRight().ceil(),
size = new Size(bottomRight.subtract(topLeft)),
raster = new Raster(Item.NO_INSERT);
size = new Size(bottomRight.subtract(topLeft)).multiply(scale);
raster.setSize(size, true);
if (!size.isZero()) {
var canvas = CanvasProvider.getCanvas(size.multiply(scale)),
ctx = canvas.getContext('2d'),
var ctx = raster.getContext(true),
matrix = new Matrix().scale(scale).translate(topLeft.negate());
ctx.save();
matrix.applyToContext(ctx);
this.draw(ctx, new Base({ matrices: [matrix] }));
ctx.restore();
raster.setCanvas(canvas);
}
raster.transform(new Matrix().translate(topLeft.add(size.divide(2)))
.scale(1 / scale));
@ -5400,20 +5413,23 @@ var Raster = Item.extend({
this, 'setSize');
},
setSize: function() {
setSize: function(_size, _clear) {
var size = Size.read(arguments);
if (!size.equals(this._size)) {
if (size.width > 0 && size.height > 0) {
var element = this.getElement();
var element = !_clear && this.getElement();
this._setImage(CanvasProvider.getCanvas(size));
if (element)
if (element) {
this.getContext(true).drawImage(element, 0, 0,
size.width, size.height);
}
} else {
if (this._canvas)
CanvasProvider.release(this._canvas);
this._size = size.clone();
}
} else if (_clear) {
this.clear();
}
},

File diff suppressed because one or more lines are too long

36
dist/paper-full.js vendored
View file

@ -9,7 +9,7 @@
*
* All rights reserved.
*
* Date: Mon Jun 22 16:32:39 2020 +0200
* Date: Mon Jun 22 17:26:35 2020 +0200
*
***
*
@ -3891,22 +3891,35 @@ new function() {
this.setName(name);
},
rasterize: function(resolution, insert) {
rasterize: function(arg0, arg1) {
var resolution,
insert,
raster;
if (Base.isPlainObject(arg0)) {
resolution = arg0.resolution;
insert = arg0.insert;
raster = arg0.raster;
} else {
resolution = arg0;
insert = arg1;
}
if (!raster) {
raster = new Raster(Item.NO_INSERT);
}
var bounds = this.getStrokeBounds(),
scale = (resolution || this.getView().getResolution()) / 72,
topLeft = bounds.getTopLeft().floor(),
bottomRight = bounds.getBottomRight().ceil(),
size = new Size(bottomRight.subtract(topLeft)),
raster = new Raster(Item.NO_INSERT);
size = new Size(bottomRight.subtract(topLeft)).multiply(scale);
raster.setSize(size, true);
if (!size.isZero()) {
var canvas = CanvasProvider.getCanvas(size.multiply(scale)),
ctx = canvas.getContext('2d'),
var ctx = raster.getContext(true),
matrix = new Matrix().scale(scale).translate(topLeft.negate());
ctx.save();
matrix.applyToContext(ctx);
this.draw(ctx, new Base({ matrices: [matrix] }));
ctx.restore();
raster.setCanvas(canvas);
}
raster.transform(new Matrix().translate(topLeft.add(size.divide(2)))
.scale(1 / scale));
@ -5403,20 +5416,23 @@ var Raster = Item.extend({
this, 'setSize');
},
setSize: function() {
setSize: function(_size, _clear) {
var size = Size.read(arguments);
if (!size.equals(this._size)) {
if (size.width > 0 && size.height > 0) {
var element = this.getElement();
var element = !_clear && this.getElement();
this._setImage(CanvasProvider.getCanvas(size));
if (element)
if (element) {
this.getContext(true).drawImage(element, 0, 0,
size.width, size.height);
}
} else {
if (this._canvas)
CanvasProvider.release(this._canvas);
this._size = size.clone();
}
} else if (_clear) {
this.clear();
}
},

File diff suppressed because one or more lines are too long

23
dist/paper.d.ts vendored
View file

@ -9,7 +9,7 @@
*
* All rights reserved.
*
* Date: Mon Jun 22 16:32:39 2020 +0200
* Date: Mon Jun 22 17:26:35 2020 +0200
*
* This is an auto-generated type definition.
*/
@ -1792,16 +1792,23 @@ declare namespace paper {
* Rasterizes the item into a newly created Raster object. The item itself
* is not removed after rasterization.
*
* @param resolution - the resolution of the raster
* in pixels per inch (DPI). If not specified, the value of
* `view.resolution` is used.
* @param insert - specifies whether the raster should be
* @option [resolution=view.resolution] {Number} the desired resolution to
* be used when rasterizing, in pixels per inch (DPI). If not specified,
* the value of `view.resolution` is used by default.
* @option [raster=null] {Raster} specifies a raster to be reused when
* rasterizing. If the raster has the desired size already, then the
* underlying canvas is reused and no new memory needs to be allocated.
* If no raster is provided, a new raster item is created and returned
* instead.
* @option [insert=true] {Boolean} specifies whether the raster should be
* inserted into the scene graph. When set to `true`, it is inserted
* above the original
* above the rasterized item.
*
* @return the newly created raster item
* @param options - the rasterization options
*
* @return the reused raster or the newly created raster item
*/
rasterize(resolution?: number, insert?: boolean): Raster
rasterize(options?: object): Raster
/**
* Checks whether the item's geometry contains the given point.