mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-03-13 16:33:28 -04:00
Prebuilt module for commit 27b92a6007
This commit is contained in:
parent
b468935fd5
commit
545b36d5de
8 changed files with 313 additions and 161 deletions
113
dist/docs/assets/js/paper.js
vendored
113
dist/docs/assets/js/paper.js
vendored
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Date: Wed Oct 3 10:22:49 2018 +0200
|
||||
* Date: Wed Oct 3 16:45:38 2018 +0200
|
||||
*
|
||||
***
|
||||
*
|
||||
|
@ -556,6 +556,20 @@ statics: {
|
|||
});
|
||||
},
|
||||
|
||||
push: function(list, items) {
|
||||
var itemsLength = items.length;
|
||||
if (itemsLength < 4096) {
|
||||
list.push.apply(list, items);
|
||||
} else {
|
||||
var startLength = list.length;
|
||||
list.length += itemsLength;
|
||||
for (var i = 0; i < itemsLength; i++) {
|
||||
list[startLength + i] = items[i];
|
||||
}
|
||||
}
|
||||
return list;
|
||||
},
|
||||
|
||||
splice: function(list, items, index, remove) {
|
||||
var amount = items && items.length,
|
||||
append = index === undefined;
|
||||
|
@ -565,12 +579,12 @@ statics: {
|
|||
for (var i = 0; i < amount; i++)
|
||||
items[i]._index = index + i;
|
||||
if (append) {
|
||||
list.push.apply(list, items);
|
||||
Base.push(list, items);
|
||||
return [];
|
||||
} else {
|
||||
var args = [index, remove];
|
||||
if (items)
|
||||
args.push.apply(args, items);
|
||||
Base.push(args, items);
|
||||
var removed = list.splice.apply(list, args);
|
||||
for (var i = 0, l = removed.length; i < l; i++)
|
||||
removed[i]._index = undefined;
|
||||
|
@ -7193,7 +7207,7 @@ new function() {
|
|||
}
|
||||
locations = [];
|
||||
for (var i = 0, l = arrays.length; i < l; i++) {
|
||||
locations.push.apply(locations, arrays[i]);
|
||||
Base.push(locations, arrays[i]);
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
|
@ -8116,12 +8130,7 @@ var Path = PathItem.extend({
|
|||
this._updateSelection(segment, 0, segment._selection);
|
||||
}
|
||||
if (append) {
|
||||
var originalLength = segments.length;
|
||||
var offsetLength = segs.length;
|
||||
segments.length += offsetLength;
|
||||
for (var i = 0; i < offsetLength; i++) {
|
||||
segments[originalLength + i] = segs[i];
|
||||
}
|
||||
Base.push(segments, segs);
|
||||
} else {
|
||||
segments.splice.apply(segments, [index, 0].concat(segs));
|
||||
for (var i = index + amount, l = segments.length; i < l; i++)
|
||||
|
@ -9703,8 +9712,9 @@ var CompoundPath = PathItem.extend({
|
|||
getCurves: function() {
|
||||
var children = this._children,
|
||||
curves = [];
|
||||
for (var i = 0, l = children.length; i < l; i++)
|
||||
curves.push.apply(curves, children[i].getCurves());
|
||||
for (var i = 0, l = children.length; i < l; i++) {
|
||||
Base.push(curves, children[i].getCurves());
|
||||
}
|
||||
return curves;
|
||||
},
|
||||
|
||||
|
@ -9890,8 +9900,8 @@ PathItem.inject(new function() {
|
|||
function collect(paths) {
|
||||
for (var i = 0, l = paths.length; i < l; i++) {
|
||||
var path = paths[i];
|
||||
segments.push.apply(segments, path._segments);
|
||||
curves.push.apply(curves, path.getCurves());
|
||||
Base.push(segments, path._segments);
|
||||
Base.push(curves, path.getCurves());
|
||||
path._overlapsOnly = true;
|
||||
}
|
||||
}
|
||||
|
@ -10586,7 +10596,7 @@ PathItem.inject(new function() {
|
|||
if (clearCurves)
|
||||
clearCurveHandles(clearCurves);
|
||||
paths = tracePaths(Base.each(paths, function(path) {
|
||||
this.push.apply(this, path._segments);
|
||||
Base.push(this, path._segments);
|
||||
}, []));
|
||||
}
|
||||
var length = paths.length,
|
||||
|
@ -11105,6 +11115,7 @@ var Color = Base.extend(new function() {
|
|||
|
||||
function fromCSS(string) {
|
||||
var match = string.match(/^#(\w{1,2})(\w{1,2})(\w{1,2})$/),
|
||||
type = 'rgb',
|
||||
components;
|
||||
if (match) {
|
||||
components = [0, 0, 0];
|
||||
|
@ -11113,11 +11124,28 @@ var Color = Base.extend(new function() {
|
|||
components[i] = parseInt(value.length == 1
|
||||
? value + value : value, 16) / 255;
|
||||
}
|
||||
} else if (match = string.match(/^rgba?\((.*)\)$/)) {
|
||||
components = match[1].split(',');
|
||||
for (var i = 0, l = components.length; i < l; i++) {
|
||||
var value = +components[i];
|
||||
components[i] = i < 3 ? value / 255 : value;
|
||||
} else if (match = string.match(/^(rgb|hsl)a?\((.*)\)$/)) {
|
||||
type = match[1];
|
||||
components = match[2].split(/[,\s]+/g);
|
||||
var isHSL = type === 'hsl';
|
||||
for (var i = 0, l = Math.min(components.length, 4); i < l; i++) {
|
||||
var component = components[i];
|
||||
var value = parseFloat(component);
|
||||
if (isHSL) {
|
||||
if (i === 0) {
|
||||
var unit = component.match(/([a-z]*)$/)[1];
|
||||
value *= ({
|
||||
turn: 360,
|
||||
rad: 180 / Math.PI,
|
||||
grad: 0.9
|
||||
}[unit] || 1);
|
||||
} else if (i < 3) {
|
||||
value /= 100;
|
||||
}
|
||||
} else if (i < 3) {
|
||||
value /= 255;
|
||||
}
|
||||
components[i] = value;
|
||||
}
|
||||
} else if (window) {
|
||||
var cached = colorCache[string];
|
||||
|
@ -11140,7 +11168,7 @@ var Color = Base.extend(new function() {
|
|||
} else {
|
||||
components = [0, 0, 0];
|
||||
}
|
||||
return components;
|
||||
return [type, components];
|
||||
}
|
||||
|
||||
var hsbIndices = [
|
||||
|
@ -11248,30 +11276,32 @@ var Color = Base.extend(new function() {
|
|||
Base.each(properties, function(name, index) {
|
||||
var part = Base.capitalize(name),
|
||||
hasOverlap = /^(hue|saturation)$/.test(name),
|
||||
parser = componentParsers[type][index] = name === 'gradient'
|
||||
? function(value) {
|
||||
var current = this._components[0];
|
||||
value = Gradient.read(Array.isArray(value) ? value
|
||||
: arguments, 0, { readNull: true });
|
||||
if (current !== value) {
|
||||
if (current)
|
||||
current._removeOwner(this);
|
||||
if (value)
|
||||
value._addOwner(this);
|
||||
parser = componentParsers[type][index] = type === 'gradient'
|
||||
? name === 'gradient'
|
||||
? function(value) {
|
||||
var current = this._components[0];
|
||||
value = Gradient.read(
|
||||
Array.isArray(value)
|
||||
? value
|
||||
: arguments, 0, { readNull: true }
|
||||
);
|
||||
if (current !== value) {
|
||||
if (current)
|
||||
current._removeOwner(this);
|
||||
if (value)
|
||||
value._addOwner(this);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
: type === 'gradient'
|
||||
? function() {
|
||||
: function() {
|
||||
return Point.read(arguments, 0, {
|
||||
readNull: name === 'highlight',
|
||||
clone: true
|
||||
});
|
||||
}
|
||||
: function(value) {
|
||||
return value == null || isNaN(value) ? 0 : value;
|
||||
};
|
||||
|
||||
: function(value) {
|
||||
return value == null || isNaN(value) ? 0 : +value;
|
||||
};
|
||||
this['get' + part] = function() {
|
||||
return this._type === type
|
||||
|| hasOverlap && /^hs[bl]$/.test(this._type)
|
||||
|
@ -11341,8 +11371,9 @@ var Color = Base.extend(new function() {
|
|||
if (values.length > length)
|
||||
values = Base.slice(values, 0, length);
|
||||
} else if (argType === 'string') {
|
||||
type = 'rgb';
|
||||
components = fromCSS(arg);
|
||||
var converted = fromCSS(arg);
|
||||
type = converted[0];
|
||||
components = converted[1];
|
||||
if (components.length === 4) {
|
||||
alpha = components[3];
|
||||
components.length--;
|
||||
|
|
95
dist/docs/classes/Color.html
vendored
95
dist/docs/classes/Color.html
vendored
|
@ -340,6 +340,65 @@ var path = new Path.Rectangle({
|
|||
</div>
|
||||
|
||||
|
||||
<div id="color-color" class="member">
|
||||
<div class="member-link">
|
||||
<a name="color-color" href="#color-color"><tt><b>Color</b>(color)</tt></a>
|
||||
</div>
|
||||
<div class="member-description hidden">
|
||||
<div class="member-text">
|
||||
<p>Creates a Color object from a CSS string. All common CSS color string formats are supported: - Named colors (e.g. <code>'red'</code>, <code>'fuchsia'</code>, …) - Hex strings (<code>'#ffff00'</code>, <code>'#ff0'</code>, …) - RGB strings (<code>'rgb(255, 128, 0)'</code>, <code>'rgba(255, 128, 0, 0.5)'</code>, …) - HSL strings (<code>'hsl(180deg, 20%, 50%)'</code>, <code>'hsla(3.14rad, 20%, 50%, 0.5)'</code>, …)</p>
|
||||
|
||||
|
||||
<ul class="member-list">
|
||||
<h4>Parameters:</h4>
|
||||
|
||||
<li>
|
||||
<tt>color:</tt>
|
||||
<tt>String</tt>
|
||||
— the color’s CSS string representation
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<ul class="member-list">
|
||||
<h4>Returns:</h4>
|
||||
|
||||
<li>
|
||||
<tt><a href="../classes/Color.html"><tt>Color</tt></a></tt>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
<h4>Example:</h4>
|
||||
|
||||
<div class="paperscript split">
|
||||
|
||||
<div class="buttons">
|
||||
<div class="button run">Run</div>
|
||||
</div>
|
||||
|
||||
<script type="text/paperscript" canvas="canvas-7">
|
||||
var circle = new Path.Circle({
|
||||
center: [80, 50],
|
||||
radius: 30,
|
||||
fillColor: new Color('rgba(255, 255, 0, 0.5)')
|
||||
});
|
||||
</script>
|
||||
<div class="canvas"><canvas width="516" height="100" id="canvas-7"></canvas></div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="color-gradient-origin-destination" class="member">
|
||||
<div class="member-link">
|
||||
<a name="color-gradient-origin-destination" href="#color-gradient-origin-destination"><tt><b>Color</b>(gradient, origin, destination[, highlight])</tt></a>
|
||||
|
@ -404,7 +463,7 @@ var path = new Path.Rectangle({
|
|||
<div class="button run">Run</div>
|
||||
</div>
|
||||
|
||||
<script type="text/paperscript" canvas="canvas-7">
|
||||
<script type="text/paperscript" canvas="canvas-8">
|
||||
// Define two points which we will be using to construct
|
||||
// the path and to position the gradient color:
|
||||
var topLeft = view.center - [80, 80];
|
||||
|
@ -425,7 +484,7 @@ var gradientColor = new Color(gradient, topLeft, bottomRight);
|
|||
// Set the fill color of the path to the gradient color:
|
||||
path.fillColor = gradientColor;
|
||||
</script>
|
||||
<div class="canvas"><canvas width="516" height="200" id="canvas-7"></canvas></div>
|
||||
<div class="canvas"><canvas width="516" height="200" id="canvas-8"></canvas></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -437,7 +496,7 @@ path.fillColor = gradientColor;
|
|||
<div class="button run">Run</div>
|
||||
</div>
|
||||
|
||||
<script type="text/paperscript" canvas="canvas-8">
|
||||
<script type="text/paperscript" canvas="canvas-9">
|
||||
// Create a circle shaped path at the center of the view
|
||||
// with a radius of 80:
|
||||
var path = new Path.Circle({
|
||||
|
@ -471,7 +530,7 @@ var gradientColor = new Color(gradient, from, to);
|
|||
// Set the fill color of the path to the gradient color:
|
||||
path.fillColor = gradientColor;
|
||||
</script>
|
||||
<div class="canvas"><canvas width="516" height="200" id="canvas-8"></canvas></div>
|
||||
<div class="canvas"><canvas width="516" height="200" id="canvas-9"></canvas></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -946,7 +1005,7 @@ console.log(color.type); // 'rgb'</code></pre>
|
|||
<div class="button run">Run</div>
|
||||
</div>
|
||||
|
||||
<script type="text/paperscript" canvas="canvas-9">
|
||||
<script type="text/paperscript" canvas="canvas-10">
|
||||
var circle = new Path.Circle(new Point(80, 50), 30);
|
||||
|
||||
// Fill the circle with red and give it a 20pt green stroke:
|
||||
|
@ -959,7 +1018,7 @@ circle.style = {
|
|||
// Make the stroke half transparent:
|
||||
circle.strokeColor.alpha = 0.5;
|
||||
</script>
|
||||
<div class="canvas"><canvas width="516" height="100" id="canvas-9"></canvas></div>
|
||||
<div class="canvas"><canvas width="516" height="100" id="canvas-10"></canvas></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -998,14 +1057,14 @@ circle.strokeColor.alpha = 0.5;
|
|||
<div class="button run">Run</div>
|
||||
</div>
|
||||
|
||||
<script type="text/paperscript" canvas="canvas-10">
|
||||
<script type="text/paperscript" canvas="canvas-11">
|
||||
var circle = new Path.Circle(new Point(80, 50), 30);
|
||||
circle.fillColor = 'blue';
|
||||
|
||||
// Blue + red = purple:
|
||||
circle.fillColor.red = 1;
|
||||
</script>
|
||||
<div class="canvas"><canvas width="516" height="100" id="canvas-10"></canvas></div>
|
||||
<div class="canvas"><canvas width="516" height="100" id="canvas-11"></canvas></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -1042,7 +1101,7 @@ circle.fillColor.red = 1;
|
|||
<div class="button run">Run</div>
|
||||
</div>
|
||||
|
||||
<script type="text/paperscript" canvas="canvas-11">
|
||||
<script type="text/paperscript" canvas="canvas-12">
|
||||
var circle = new Path.Circle(new Point(80, 50), 30);
|
||||
|
||||
// First we set the fill color to red:
|
||||
|
@ -1051,7 +1110,7 @@ circle.fillColor = 'red';
|
|||
// Red + green = yellow:
|
||||
circle.fillColor.green = 1;
|
||||
</script>
|
||||
<div class="canvas"><canvas width="516" height="100" id="canvas-11"></canvas></div>
|
||||
<div class="canvas"><canvas width="516" height="100" id="canvas-12"></canvas></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -1088,7 +1147,7 @@ circle.fillColor.green = 1;
|
|||
<div class="button run">Run</div>
|
||||
</div>
|
||||
|
||||
<script type="text/paperscript" canvas="canvas-12">
|
||||
<script type="text/paperscript" canvas="canvas-13">
|
||||
var circle = new Path.Circle(new Point(80, 50), 30);
|
||||
|
||||
// First we set the fill color to red:
|
||||
|
@ -1097,7 +1156,7 @@ circle.fillColor = 'red';
|
|||
// Red + blue = purple:
|
||||
circle.fillColor.blue = 1;
|
||||
</script>
|
||||
<div class="canvas"><canvas width="516" height="100" id="canvas-12"></canvas></div>
|
||||
<div class="canvas"><canvas width="516" height="100" id="canvas-13"></canvas></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -1164,12 +1223,12 @@ circle.fillColor.blue = 1;
|
|||
<div class="button run">Run</div>
|
||||
</div>
|
||||
|
||||
<script type="text/paperscript" canvas="canvas-13">
|
||||
<script type="text/paperscript" canvas="canvas-14">
|
||||
var circle = new Path.Circle(new Point(80, 50), 30);
|
||||
circle.fillColor = 'red';
|
||||
circle.fillColor.hue += 30;
|
||||
</script>
|
||||
<div class="canvas"><canvas width="516" height="100" id="canvas-13"></canvas></div>
|
||||
<div class="canvas"><canvas width="516" height="100" id="canvas-14"></canvas></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -1181,7 +1240,7 @@ circle.fillColor.hue += 30;
|
|||
<div class="button run">Run</div>
|
||||
</div>
|
||||
|
||||
<script type="text/paperscript" canvas="canvas-14">
|
||||
<script type="text/paperscript" canvas="canvas-15">
|
||||
// Create a rectangle shaped path, using the dimensions
|
||||
// of the view:
|
||||
var path = new Path.Rectangle(view.bounds);
|
||||
|
@ -1191,7 +1250,7 @@ function onFrame(event) {
|
|||
path.fillColor.hue += 0.5;
|
||||
}
|
||||
</script>
|
||||
<div class="canvas"><canvas width="516" height="100" id="canvas-14"></canvas></div>
|
||||
<div class="canvas"><canvas width="516" height="100" id="canvas-15"></canvas></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -1337,7 +1396,7 @@ function onFrame(event) {
|
|||
<div class="button run">Run</div>
|
||||
</div>
|
||||
|
||||
<script type="text/paperscript" canvas="canvas-15">
|
||||
<script type="text/paperscript" canvas="canvas-16">
|
||||
var path = new Path.Circle({
|
||||
center: view.center,
|
||||
radius: view.bounds.height * 0.4
|
||||
|
@ -1358,7 +1417,7 @@ function onMouseMove(event) {
|
|||
path.fillColor.highlight = event.point;
|
||||
}
|
||||
</script>
|
||||
<div class="canvas"><canvas width="516" height="300" id="canvas-15"></canvas></div>
|
||||
<div class="canvas"><canvas width="516" height="300" id="canvas-16"></canvas></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
2
dist/node/canvas.js
vendored
2
dist/node/canvas.js
vendored
|
@ -19,7 +19,7 @@ module.exports = function(self, requireName) {
|
|||
var Canvas;
|
||||
try {
|
||||
Canvas = require('canvas');
|
||||
} catch(e) {
|
||||
} catch(error) {
|
||||
// Remove `self.window`, so we still have the global `self` reference,
|
||||
// but no `window` object:
|
||||
// - On the browser, this corresponds to a worker context.
|
||||
|
|
113
dist/paper-core.js
vendored
113
dist/paper-core.js
vendored
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Date: Wed Oct 3 10:22:49 2018 +0200
|
||||
* Date: Wed Oct 3 16:45:38 2018 +0200
|
||||
*
|
||||
***
|
||||
*
|
||||
|
@ -556,6 +556,20 @@ statics: {
|
|||
});
|
||||
},
|
||||
|
||||
push: function(list, items) {
|
||||
var itemsLength = items.length;
|
||||
if (itemsLength < 4096) {
|
||||
list.push.apply(list, items);
|
||||
} else {
|
||||
var startLength = list.length;
|
||||
list.length += itemsLength;
|
||||
for (var i = 0; i < itemsLength; i++) {
|
||||
list[startLength + i] = items[i];
|
||||
}
|
||||
}
|
||||
return list;
|
||||
},
|
||||
|
||||
splice: function(list, items, index, remove) {
|
||||
var amount = items && items.length,
|
||||
append = index === undefined;
|
||||
|
@ -565,12 +579,12 @@ statics: {
|
|||
for (var i = 0; i < amount; i++)
|
||||
items[i]._index = index + i;
|
||||
if (append) {
|
||||
list.push.apply(list, items);
|
||||
Base.push(list, items);
|
||||
return [];
|
||||
} else {
|
||||
var args = [index, remove];
|
||||
if (items)
|
||||
args.push.apply(args, items);
|
||||
Base.push(args, items);
|
||||
var removed = list.splice.apply(list, args);
|
||||
for (var i = 0, l = removed.length; i < l; i++)
|
||||
removed[i]._index = undefined;
|
||||
|
@ -7193,7 +7207,7 @@ new function() {
|
|||
}
|
||||
locations = [];
|
||||
for (var i = 0, l = arrays.length; i < l; i++) {
|
||||
locations.push.apply(locations, arrays[i]);
|
||||
Base.push(locations, arrays[i]);
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
|
@ -8116,12 +8130,7 @@ var Path = PathItem.extend({
|
|||
this._updateSelection(segment, 0, segment._selection);
|
||||
}
|
||||
if (append) {
|
||||
var originalLength = segments.length;
|
||||
var offsetLength = segs.length;
|
||||
segments.length += offsetLength;
|
||||
for (var i = 0; i < offsetLength; i++) {
|
||||
segments[originalLength + i] = segs[i];
|
||||
}
|
||||
Base.push(segments, segs);
|
||||
} else {
|
||||
segments.splice.apply(segments, [index, 0].concat(segs));
|
||||
for (var i = index + amount, l = segments.length; i < l; i++)
|
||||
|
@ -9703,8 +9712,9 @@ var CompoundPath = PathItem.extend({
|
|||
getCurves: function() {
|
||||
var children = this._children,
|
||||
curves = [];
|
||||
for (var i = 0, l = children.length; i < l; i++)
|
||||
curves.push.apply(curves, children[i].getCurves());
|
||||
for (var i = 0, l = children.length; i < l; i++) {
|
||||
Base.push(curves, children[i].getCurves());
|
||||
}
|
||||
return curves;
|
||||
},
|
||||
|
||||
|
@ -9890,8 +9900,8 @@ PathItem.inject(new function() {
|
|||
function collect(paths) {
|
||||
for (var i = 0, l = paths.length; i < l; i++) {
|
||||
var path = paths[i];
|
||||
segments.push.apply(segments, path._segments);
|
||||
curves.push.apply(curves, path.getCurves());
|
||||
Base.push(segments, path._segments);
|
||||
Base.push(curves, path.getCurves());
|
||||
path._overlapsOnly = true;
|
||||
}
|
||||
}
|
||||
|
@ -10586,7 +10596,7 @@ PathItem.inject(new function() {
|
|||
if (clearCurves)
|
||||
clearCurveHandles(clearCurves);
|
||||
paths = tracePaths(Base.each(paths, function(path) {
|
||||
this.push.apply(this, path._segments);
|
||||
Base.push(this, path._segments);
|
||||
}, []));
|
||||
}
|
||||
var length = paths.length,
|
||||
|
@ -11105,6 +11115,7 @@ var Color = Base.extend(new function() {
|
|||
|
||||
function fromCSS(string) {
|
||||
var match = string.match(/^#(\w{1,2})(\w{1,2})(\w{1,2})$/),
|
||||
type = 'rgb',
|
||||
components;
|
||||
if (match) {
|
||||
components = [0, 0, 0];
|
||||
|
@ -11113,11 +11124,28 @@ var Color = Base.extend(new function() {
|
|||
components[i] = parseInt(value.length == 1
|
||||
? value + value : value, 16) / 255;
|
||||
}
|
||||
} else if (match = string.match(/^rgba?\((.*)\)$/)) {
|
||||
components = match[1].split(',');
|
||||
for (var i = 0, l = components.length; i < l; i++) {
|
||||
var value = +components[i];
|
||||
components[i] = i < 3 ? value / 255 : value;
|
||||
} else if (match = string.match(/^(rgb|hsl)a?\((.*)\)$/)) {
|
||||
type = match[1];
|
||||
components = match[2].split(/[,\s]+/g);
|
||||
var isHSL = type === 'hsl';
|
||||
for (var i = 0, l = Math.min(components.length, 4); i < l; i++) {
|
||||
var component = components[i];
|
||||
var value = parseFloat(component);
|
||||
if (isHSL) {
|
||||
if (i === 0) {
|
||||
var unit = component.match(/([a-z]*)$/)[1];
|
||||
value *= ({
|
||||
turn: 360,
|
||||
rad: 180 / Math.PI,
|
||||
grad: 0.9
|
||||
}[unit] || 1);
|
||||
} else if (i < 3) {
|
||||
value /= 100;
|
||||
}
|
||||
} else if (i < 3) {
|
||||
value /= 255;
|
||||
}
|
||||
components[i] = value;
|
||||
}
|
||||
} else if (window) {
|
||||
var cached = colorCache[string];
|
||||
|
@ -11140,7 +11168,7 @@ var Color = Base.extend(new function() {
|
|||
} else {
|
||||
components = [0, 0, 0];
|
||||
}
|
||||
return components;
|
||||
return [type, components];
|
||||
}
|
||||
|
||||
var hsbIndices = [
|
||||
|
@ -11248,30 +11276,32 @@ var Color = Base.extend(new function() {
|
|||
Base.each(properties, function(name, index) {
|
||||
var part = Base.capitalize(name),
|
||||
hasOverlap = /^(hue|saturation)$/.test(name),
|
||||
parser = componentParsers[type][index] = name === 'gradient'
|
||||
? function(value) {
|
||||
var current = this._components[0];
|
||||
value = Gradient.read(Array.isArray(value) ? value
|
||||
: arguments, 0, { readNull: true });
|
||||
if (current !== value) {
|
||||
if (current)
|
||||
current._removeOwner(this);
|
||||
if (value)
|
||||
value._addOwner(this);
|
||||
parser = componentParsers[type][index] = type === 'gradient'
|
||||
? name === 'gradient'
|
||||
? function(value) {
|
||||
var current = this._components[0];
|
||||
value = Gradient.read(
|
||||
Array.isArray(value)
|
||||
? value
|
||||
: arguments, 0, { readNull: true }
|
||||
);
|
||||
if (current !== value) {
|
||||
if (current)
|
||||
current._removeOwner(this);
|
||||
if (value)
|
||||
value._addOwner(this);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
: type === 'gradient'
|
||||
? function() {
|
||||
: function() {
|
||||
return Point.read(arguments, 0, {
|
||||
readNull: name === 'highlight',
|
||||
clone: true
|
||||
});
|
||||
}
|
||||
: function(value) {
|
||||
return value == null || isNaN(value) ? 0 : value;
|
||||
};
|
||||
|
||||
: function(value) {
|
||||
return value == null || isNaN(value) ? 0 : +value;
|
||||
};
|
||||
this['get' + part] = function() {
|
||||
return this._type === type
|
||||
|| hasOverlap && /^hs[bl]$/.test(this._type)
|
||||
|
@ -11341,8 +11371,9 @@ var Color = Base.extend(new function() {
|
|||
if (values.length > length)
|
||||
values = Base.slice(values, 0, length);
|
||||
} else if (argType === 'string') {
|
||||
type = 'rgb';
|
||||
components = fromCSS(arg);
|
||||
var converted = fromCSS(arg);
|
||||
type = converted[0];
|
||||
components = converted[1];
|
||||
if (components.length === 4) {
|
||||
alpha = components[3];
|
||||
components.length--;
|
||||
|
|
16
dist/paper-core.min.js
vendored
16
dist/paper-core.min.js
vendored
File diff suppressed because one or more lines are too long
113
dist/paper-full.js
vendored
113
dist/paper-full.js
vendored
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Date: Wed Oct 3 10:22:49 2018 +0200
|
||||
* Date: Wed Oct 3 16:45:38 2018 +0200
|
||||
*
|
||||
***
|
||||
*
|
||||
|
@ -556,6 +556,20 @@ statics: {
|
|||
});
|
||||
},
|
||||
|
||||
push: function(list, items) {
|
||||
var itemsLength = items.length;
|
||||
if (itemsLength < 4096) {
|
||||
list.push.apply(list, items);
|
||||
} else {
|
||||
var startLength = list.length;
|
||||
list.length += itemsLength;
|
||||
for (var i = 0; i < itemsLength; i++) {
|
||||
list[startLength + i] = items[i];
|
||||
}
|
||||
}
|
||||
return list;
|
||||
},
|
||||
|
||||
splice: function(list, items, index, remove) {
|
||||
var amount = items && items.length,
|
||||
append = index === undefined;
|
||||
|
@ -565,12 +579,12 @@ statics: {
|
|||
for (var i = 0; i < amount; i++)
|
||||
items[i]._index = index + i;
|
||||
if (append) {
|
||||
list.push.apply(list, items);
|
||||
Base.push(list, items);
|
||||
return [];
|
||||
} else {
|
||||
var args = [index, remove];
|
||||
if (items)
|
||||
args.push.apply(args, items);
|
||||
Base.push(args, items);
|
||||
var removed = list.splice.apply(list, args);
|
||||
for (var i = 0, l = removed.length; i < l; i++)
|
||||
removed[i]._index = undefined;
|
||||
|
@ -7193,7 +7207,7 @@ new function() {
|
|||
}
|
||||
locations = [];
|
||||
for (var i = 0, l = arrays.length; i < l; i++) {
|
||||
locations.push.apply(locations, arrays[i]);
|
||||
Base.push(locations, arrays[i]);
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
|
@ -8116,12 +8130,7 @@ var Path = PathItem.extend({
|
|||
this._updateSelection(segment, 0, segment._selection);
|
||||
}
|
||||
if (append) {
|
||||
var originalLength = segments.length;
|
||||
var offsetLength = segs.length;
|
||||
segments.length += offsetLength;
|
||||
for (var i = 0; i < offsetLength; i++) {
|
||||
segments[originalLength + i] = segs[i];
|
||||
}
|
||||
Base.push(segments, segs);
|
||||
} else {
|
||||
segments.splice.apply(segments, [index, 0].concat(segs));
|
||||
for (var i = index + amount, l = segments.length; i < l; i++)
|
||||
|
@ -9703,8 +9712,9 @@ var CompoundPath = PathItem.extend({
|
|||
getCurves: function() {
|
||||
var children = this._children,
|
||||
curves = [];
|
||||
for (var i = 0, l = children.length; i < l; i++)
|
||||
curves.push.apply(curves, children[i].getCurves());
|
||||
for (var i = 0, l = children.length; i < l; i++) {
|
||||
Base.push(curves, children[i].getCurves());
|
||||
}
|
||||
return curves;
|
||||
},
|
||||
|
||||
|
@ -9890,8 +9900,8 @@ PathItem.inject(new function() {
|
|||
function collect(paths) {
|
||||
for (var i = 0, l = paths.length; i < l; i++) {
|
||||
var path = paths[i];
|
||||
segments.push.apply(segments, path._segments);
|
||||
curves.push.apply(curves, path.getCurves());
|
||||
Base.push(segments, path._segments);
|
||||
Base.push(curves, path.getCurves());
|
||||
path._overlapsOnly = true;
|
||||
}
|
||||
}
|
||||
|
@ -10586,7 +10596,7 @@ PathItem.inject(new function() {
|
|||
if (clearCurves)
|
||||
clearCurveHandles(clearCurves);
|
||||
paths = tracePaths(Base.each(paths, function(path) {
|
||||
this.push.apply(this, path._segments);
|
||||
Base.push(this, path._segments);
|
||||
}, []));
|
||||
}
|
||||
var length = paths.length,
|
||||
|
@ -11105,6 +11115,7 @@ var Color = Base.extend(new function() {
|
|||
|
||||
function fromCSS(string) {
|
||||
var match = string.match(/^#(\w{1,2})(\w{1,2})(\w{1,2})$/),
|
||||
type = 'rgb',
|
||||
components;
|
||||
if (match) {
|
||||
components = [0, 0, 0];
|
||||
|
@ -11113,11 +11124,28 @@ var Color = Base.extend(new function() {
|
|||
components[i] = parseInt(value.length == 1
|
||||
? value + value : value, 16) / 255;
|
||||
}
|
||||
} else if (match = string.match(/^rgba?\((.*)\)$/)) {
|
||||
components = match[1].split(',');
|
||||
for (var i = 0, l = components.length; i < l; i++) {
|
||||
var value = +components[i];
|
||||
components[i] = i < 3 ? value / 255 : value;
|
||||
} else if (match = string.match(/^(rgb|hsl)a?\((.*)\)$/)) {
|
||||
type = match[1];
|
||||
components = match[2].split(/[,\s]+/g);
|
||||
var isHSL = type === 'hsl';
|
||||
for (var i = 0, l = Math.min(components.length, 4); i < l; i++) {
|
||||
var component = components[i];
|
||||
var value = parseFloat(component);
|
||||
if (isHSL) {
|
||||
if (i === 0) {
|
||||
var unit = component.match(/([a-z]*)$/)[1];
|
||||
value *= ({
|
||||
turn: 360,
|
||||
rad: 180 / Math.PI,
|
||||
grad: 0.9
|
||||
}[unit] || 1);
|
||||
} else if (i < 3) {
|
||||
value /= 100;
|
||||
}
|
||||
} else if (i < 3) {
|
||||
value /= 255;
|
||||
}
|
||||
components[i] = value;
|
||||
}
|
||||
} else if (window) {
|
||||
var cached = colorCache[string];
|
||||
|
@ -11140,7 +11168,7 @@ var Color = Base.extend(new function() {
|
|||
} else {
|
||||
components = [0, 0, 0];
|
||||
}
|
||||
return components;
|
||||
return [type, components];
|
||||
}
|
||||
|
||||
var hsbIndices = [
|
||||
|
@ -11248,30 +11276,32 @@ var Color = Base.extend(new function() {
|
|||
Base.each(properties, function(name, index) {
|
||||
var part = Base.capitalize(name),
|
||||
hasOverlap = /^(hue|saturation)$/.test(name),
|
||||
parser = componentParsers[type][index] = name === 'gradient'
|
||||
? function(value) {
|
||||
var current = this._components[0];
|
||||
value = Gradient.read(Array.isArray(value) ? value
|
||||
: arguments, 0, { readNull: true });
|
||||
if (current !== value) {
|
||||
if (current)
|
||||
current._removeOwner(this);
|
||||
if (value)
|
||||
value._addOwner(this);
|
||||
parser = componentParsers[type][index] = type === 'gradient'
|
||||
? name === 'gradient'
|
||||
? function(value) {
|
||||
var current = this._components[0];
|
||||
value = Gradient.read(
|
||||
Array.isArray(value)
|
||||
? value
|
||||
: arguments, 0, { readNull: true }
|
||||
);
|
||||
if (current !== value) {
|
||||
if (current)
|
||||
current._removeOwner(this);
|
||||
if (value)
|
||||
value._addOwner(this);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
: type === 'gradient'
|
||||
? function() {
|
||||
: function() {
|
||||
return Point.read(arguments, 0, {
|
||||
readNull: name === 'highlight',
|
||||
clone: true
|
||||
});
|
||||
}
|
||||
: function(value) {
|
||||
return value == null || isNaN(value) ? 0 : value;
|
||||
};
|
||||
|
||||
: function(value) {
|
||||
return value == null || isNaN(value) ? 0 : +value;
|
||||
};
|
||||
this['get' + part] = function() {
|
||||
return this._type === type
|
||||
|| hasOverlap && /^hs[bl]$/.test(this._type)
|
||||
|
@ -11341,8 +11371,9 @@ var Color = Base.extend(new function() {
|
|||
if (values.length > length)
|
||||
values = Base.slice(values, 0, length);
|
||||
} else if (argType === 'string') {
|
||||
type = 'rgb';
|
||||
components = fromCSS(arg);
|
||||
var converted = fromCSS(arg);
|
||||
type = converted[0];
|
||||
components = converted[1];
|
||||
if (components.length === 4) {
|
||||
alpha = components[3];
|
||||
components.length--;
|
||||
|
|
16
dist/paper-full.min.js
vendored
16
dist/paper-full.min.js
vendored
File diff suppressed because one or more lines are too long
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -1007,9 +1007,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"deepmerge": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-2.1.1.tgz",
|
||||
"integrity": "sha512-urQxA1smbLZ2cBbXbaYObM1dJ82aJ2H57A1C/Kklfh/ZN1bgH4G/n5KWhdNfOK11W98gqZfyYj7W4frJJRwA2w==",
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-2.2.0.tgz",
|
||||
"integrity": "sha512-7iuEZ5j20aoFhiiaFZiSipk23nPl+UGKsglMJ+dy27HTpQ3wm2tj2esD/UHXlrqh5o6p6MW7m+fYSUz4JvuqVQ==",
|
||||
"dev": true
|
||||
},
|
||||
"defaults": {
|
||||
|
|
Loading…
Reference in a new issue