Comments (16)
Before we go down that route, can you explain what you mean with "doesn't work"? these lines ensure that the following calls all work, by looking at whether the passed values act as iterable or not.
You can verify that they work by pulling up a dev console on http://pomax.github.io/bezierjs and running them in the console:
- new Bezier(1,2, 3,4, 5,6)
- (the same but for 4 pairs)
- new Bezier(1,2,3, 4 5,6, 7,8,9)
- (the same but for 4 pairs)
- new Bezier([{x:1,y:2},{x:3,y:4},{x:5,y:6}])
- (the same but with 4 pairs, z-coordinates, and both)
from bezierjs.
I knew I should have given an example! Sorry. new Bezier({x:1,y:2},{x:3,y:4},{x:5,y:6})
from bezierjs.
You're right, that won't work: if you put them in an array and pass that in, it'll work fine, but the code should probably be able to deal with this. The problem is not with the line you marked, though. That line should stay the same. The trouble is that https://github.com/Pomax/bezierjs/blob/gh-pages/bezier.js#L502 doesn't use the right container for its data.
from bezierjs.
We can easily make it work. Putting it in an array works fine too, of course (which is what I did in my code).
from bezierjs.
The fix here will be to replace this:
if(typeof args[0] === "object") {
args = [];
for(var i=0; i<coords.length; i++) {
['x','y','z'].forEach(function(d) {
if(typeof coords[i][d] !== "undefined") {
args.push(coords[i][d]);
}
});
}
}
with this
if(typeof args[0] === "object") {
newargs = [];
for(var i=0; i<args.length; i++) {
['x','y','z'].forEach(function(d) {
if(typeof coords[i][d] !== "undefined") {
newargs .push(args[i][d]);
}
});
}
args = newargs;
}
from bezierjs.
Yep, that looks right! Probably var newargs =
instead of newargs =
.
from bezierjs.
For the other part, the odd Chrome performance issue, do you think the workaround makes sense?
from bezierjs.
sort of. Might as well just do a straight up array cast, though.
var args = ... [].slice.call( arguments )
from bezierjs.
That's what I thought too, but apparently even that isn't optimized well in Chrome (I read that in a bug report and just tested in my Chromium to double check).
from bezierjs.
I'd love to be missing something, though, so let me know if you find something different. I'm checking whether it's optimized well by running the profiler in Chromium and looking for the yellow exclamation-mark warning sign next to Bezier in the "Heavy (bottom up)" profile. Mouse over the warning sign to see the message describing the warning.
from bezierjs.
I've pushed the update, so you can check what Chrome thinks of that.
from bezierjs.
I'm still seeing a warning message in the profiler.
from bezierjs.
If you want to see where I'm testing, it's at https://github.com/idupree/trainworldii that you can compile with tsc script.ts
and then open index.html in a browser (first edit bezier.js to be the version you want it to be). If that's too complicated I can make it easier to test.
from bezierjs.
On further investigation, even with the difference in ⚠ vs not, it's now taking about the same amount of time for me either way in the profile. I wonder if I missed something before. I am satisfied to tentatively close this ticket unless/until anyone can measure a large time difference in the future.
from bezierjs.
in that case let's close this, until such time someone else run into it.
from bezierjs.
Thanks!
from bezierjs.
Related Issues (20)
- Get the length of the curve at some `t` HOT 1
- _lut caching doesn't work: steps is off by one HOT 5
- Release v6.1.2 broken HOT 3
- Why get(t = 0.5) point is not the middle point of the curve? HOT 5
- Find optmal D1 - Bezier.cubicFromPoints HOT 1
- PolyBezier is not exported correct for ES Module. HOT 3
- Rational Bezier Curve Support HOT 1
- Example usage of `dist/bezier.js` HOT 4
- How to make a "strict" version of bezier.project(point)? HOT 2
- Should bezier.lineIntersects(line) work for line-line intersections? HOT 3
- intersects bug Bezier to Bezier HOT 3
- Suspicious line in `utils.compute()` HOT 2
- The intersection of the two bezier is empty HOT 9
- The intersection of two identical curves HOT 2
- Intersect line method does not always return existing intersections HOT 4
- Ability to get and estimate the centerline of a list of 3D points HOT 3
- PR for extending API to interpolate values along curve and find point on curve at distance?
- Artifact when offsetting an SVG path
- Split curves do not follow old curve. HOT 2
- Missing LICENSE file HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bezierjs.