paperjs / paper.js

The Swiss Army Knife of Vector Graphics Scripting – Scriptographer ported to JavaScript and the browser, using HTML5 Canvas. Created by @lehni & @puckey
http://paperjs.org
Other
14.45k stars 1.22k forks source link

v9.16 - #transformContent = false leads to error #426

Closed cyrildiagne closed 10 years ago

cyrildiagne commented 10 years ago

Hi, I'm making my first steps with paperjs and I'm facing an issue that seems to have been introduced in the latest version.

In the v9.16 release, if I use transformContent = false on a paper.Layer and then try to change the position of a children I get this error :

Uncaught TypeError: 
Object [object Object] has no method '_clearBoundsCache'  paper.js:3083
Base.extend.Base.each.statics._clearBoundsCache           paper.js:3083
Base.extend._changed                                      paper.js:2767
_changed                                                  paper.js:6380
Base.extend.transform                                     paper.js:3747
Base.extend._changed                                      paper.js:1916
Base.extend.preConcatenate                                paper.js:2062
Base.extend.transform                                     paper.js:3731
Base.extend.translate                                     paper.js:3704
Base.extend.setPosition                                   paper.js:2958
Point.extend.setX                                         paper.js:1310

The errors comes from :

3082      if (child !== item && child._boundsCache)
3083 >        child._clearBoundsCache();

with child being the paper.Layer instance. However the same code works fine in the v9.15.

I'm very new to this library so I'm not sure what's going on but I thought I'd report. cheers,

lehni commented 10 years ago

I cannot reproduce this. Please provide a test-case online so I can see it in action.

cyrildiagne commented 10 years ago

Hi, thanks for the feedback! Here is a code snippets that reproduces the issue :

var canvas, circle, circleGroup, view, viewport;

canvas = document.createElement('canvas');
canvas.setAttribute('width', '400');
canvas.setAttribute('height', '400');
canvas.setAttribute('data-paper-hidpi', '');
document.body.appendChild(canvas);

paper.setup(canvas);

view = new paper.Layer();
view.transformContent = false;

circleGroup = new paper.Group();
view.addChild(circleGroup);

circle = new paper.Path.Circle({
  center: [0, 0],
  strokeColor: "#000000",
  radius: 100
});

circle.position.x = 100;
circle.position.y = 100;
circleGroup.addChild(circle);

// No error if the following 2 lines are commented
// or when using v0.9.15
view.position.x = 200;
view.position.y = 200;

paper.view.onFrame = function() {
  circle.segments[0].point.x = 0;
};
lehni commented 10 years ago

Thanks! I can reproduce it in sketch. Will investigate:

http://sketch.paperjs.org/#S/ZVHBasMwDP0V4V1SKGla2GEtOwW2yxiDHZsejKM0po5UbKdZKf332U43uswn+72n9yT5Ikh2KNbi84BetWIuFNfxfZIWjDyjhWcgHOAt3rPZpqKE5t5Kcg3brmTySD7IGmkcBkFFsVhpqwy+Wu6PN4t0v7OQdV222tTZnXQ2qb+Vfkjf5mVCsktFACpEol3DtphDsZtHyHnLByzZcMAr8VCkU4lEWlnr3q1hGRC6jiljQn5kp71myr9CWOA3/5nzhEmtTvsfTRcLeGdAa9mCbsC3CA0bw4OmPazAaEIH0iIo7ro4RJ1qgnpokaB3UXcq8qd8+fizqD8drlIfE+L8S4TlaRxyphcbPjb+Sk8qarIZjJsbZ3O4j/FuW+yCjSafzKPDdSOu3w==

lehni commented 10 years ago

Found it! Thanks for spotting this. It's a bad one so I'll roll a new version out asap.

lehni commented 10 years ago

The new version's up already!

cyrildiagne commented 10 years ago

wow that was quick! thanks a lot!