Update to straps.js v3.0.1 and make all functions and accessors enumerable.

This commit is contained in:
Jürg Lehni 2017-04-22 18:50:53 +02:00
parent b26b056522
commit 188c006197
12 changed files with 545 additions and 553 deletions

View file

@ -13,7 +13,7 @@
var clones = 30; var clones = 30;
var angle = 360 / clones; var angle = 360 / clones;
for(var i = 0; i < clones; i++) { for (var i = 0; i < clones; i++) {
var clonedPath = circlePath.clone(); var clonedPath = circlePath.clone();
clonedPath.rotate(angle * i, circlePath.bounds.topLeft); clonedPath.rotate(angle * i, circlePath.bounds.topLeft);
}; };

View file

@ -120,7 +120,7 @@
function getEqualizerBands(data) { function getEqualizerBands(data) {
var bands = []; var bands = [];
var amount = Math.sqrt(data.length) / 2; var amount = Math.sqrt(data.length) / 2;
for(var i = 0; i < amount; i++) { for (var i = 0; i < amount; i++) {
var start = Math.pow(2, i) - 1; var start = Math.pow(2, i) - 1;
var end = start * 2 + 1; var end = start * 2 + 1;
var sum = 0; var sum = 0;

View file

@ -55,7 +55,7 @@
function removeSmallBits(path) { function removeSmallBits(path) {
var averageLength = path.length / path.segments.length; var averageLength = path.length / path.segments.length;
var min = path.length / 50; var min = path.length / 50;
for(var i = path.segments.length - 1; i >= 0; i--) { for (var i = path.segments.length - 1; i >= 0; i--) {
var segment = path.segments[i]; var segment = path.segments[i];
var cur = segment.point; var cur = segment.point;
var nextSegment = segment.next; var nextSegment = segment.next;
@ -69,8 +69,8 @@
function generateBeeHivePoints(size, loose) { function generateBeeHivePoints(size, loose) {
var points = []; var points = [];
var col = view.size / size; var col = view.size / size;
for(var i = -1; i < size.width + 1; i++) { for (var i = -1; i < size.width + 1; i++) {
for(var j = -1; j < size.height + 1; j++) { for (var j = -1; j < size.height + 1; j++) {
var point = new Point(i, j) / new Point(size) * view.size + col / 2; var point = new Point(i, j) / new Point(size) * view.size + col / 2;
if (j % 2) if (j % 2)
point += new Point(col.width / 2, 0); point += new Point(col.width / 2, 0);

View file

@ -15,7 +15,7 @@
var clones = 30; var clones = 30;
var angle = 360 / clones; var angle = 360 / clones;
for(var i = 0; i < clones; i++) { for (var i = 0; i < clones; i++) {
var clonedPath = circlePath.clone(); var clonedPath = circlePath.clone();
clonedPath.rotate(angle * i, circlePath.bounds.topLeft); clonedPath.rotate(angle * i, circlePath.bounds.topLeft);
}; };

View file

@ -69,7 +69,7 @@
"run-sequence": "^1.2.2", "run-sequence": "^1.2.2",
"source-map-support": "^0.4.0", "source-map-support": "^0.4.0",
"stats.js": "0.16.0", "stats.js": "0.16.0",
"straps": "^2.1.0" "straps": "^3.0.1"
}, },
"browser": { "browser": {
"canvas": false, "canvas": false,

File diff suppressed because it is too large Load diff

View file

@ -17,8 +17,6 @@
// global one in the whole scope. // global one in the whole scope.
paper = new (PaperScope.inject(Base.exports, { paper = new (PaperScope.inject(Base.exports, {
// Mark fields as enumerable so PaperScope.inject can pick them up
enumerable: true,
Base: Base, Base: Base,
Numerical: Numerical, Numerical: Numerical,
Key: Key, Key: Key,

View file

@ -26,11 +26,8 @@ var HitResult = Base.extend(/** @lends HitResult# */{
// Inject passed values, so we can be flexible about the HitResult // Inject passed values, so we can be flexible about the HitResult
// properties. // properties.
// This allows the definition of getters too, e.g. for 'pixel'. // This allows the definition of getters too, e.g. for 'pixel'.
if (values) { if (values)
// Make enumerable so toString() works.
values.enumerable = true;
this.inject(values); this.inject(values);
}
}, },
/** /**

View file

@ -1955,7 +1955,7 @@ new function() { // Scope for bezier intersection using fat-line clipping
// Calculate the curve values of the rotated curve. // Calculate the curve values of the rotated curve.
rv = [], rv = [],
roots = []; roots = [];
for(var i = 0; i < 8; i += 2) { for (var i = 0; i < 8; i += 2) {
var x = v[i] - px, var x = v[i] - px,
y = v[i + 1] - py; y = v[i + 1] - py;
rv.push( rv.push(

View file

@ -115,8 +115,9 @@ new function() {
if (length > 2) { if (length > 2) {
type = item._closed ? 'polygon' : 'polyline'; type = item._closed ? 'polygon' : 'polyline';
var parts = []; var parts = [];
for(var i = 0; i < length; i++) for (var i = 0; i < length; i++) {
parts.push(formatter.point(segments[i]._point)); parts.push(formatter.point(segments[i]._point));
}
attrs.points = parts.join(' '); attrs.points = parts.join(' ');
} else { } else {
type = 'line'; type = 'line';

View file

@ -125,7 +125,7 @@ var Numerical = new function() {
/** /**
* The machine epsilon for a double precision (Javascript Number) is * The machine epsilon for a double precision (Javascript Number) is
* 2.220446049250313e-16. (try this in the js console: * 2.220446049250313e-16. (try this in the js console:
* (function(){for(var e=1;1<1+e/2;)e/=2;return e}()) * (function(){ for (var e = 1; 1 < 1+e/2;) e/=2; return e }())
* *
* The constant MACHINE_EPSILON here refers to the constants δ and ε * The constant MACHINE_EPSILON here refers to the constants δ and ε
* such that, the error introduced by addition, multiplication on a * such that, the error introduced by addition, multiplication on a

View file

@ -154,7 +154,7 @@ test('transform test 1', function() {
var clones = 30; var clones = 30;
var angle = 360 / clones; var angle = 360 / clones;
for(var i = 0; i < clones; i++) { for (var i = 0; i < clones; i++) {
var clonedPath = circlePath.clone(); var clonedPath = circlePath.clone();
clonedPath.rotate(angle * i, circlePath.bounds.topLeft); clonedPath.rotate(angle * i, circlePath.bounds.topLeft);
} }