Implement Item#getGlobalMatrix(), #globalToLocal() and #localToGlobal()

Closes .
This commit is contained in:
Jürg Lehni 2013-12-08 20:04:10 +01:00
parent 696b5f29b9
commit 97fcd6ff38
3 changed files with 23 additions and 16 deletions
src/project

View file

@ -59,8 +59,8 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
this.view = view instanceof View ? view : View.create(view);
this._selectedItems = {};
this._selectedItemCount = 0;
// See Item#draw() for an explanation of _drawCount
this._drawCount = 0;
// See Item#draw() for an explanation of _updateCount
this._updateCount = 0;
// Change tracking, not in use for now. Activate once required:
// this._changes = [];
// this._changesById = {};
@ -421,9 +421,9 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
*/
draw: function(ctx, matrix, ratio) {
// Increase the drawCount before the draw-loop. After that, items that
// are visible will have their drawCount set to the new value.
this._drawCount++;
// Increase the _updateCount before the draw-loop. After that, items
// that are visible will have their _updateCount set to the new value.
this._updateCount++;
ctx.save();
matrix.applyToContext(ctx);
// Use new Base() so we can use param.extend() to easily override
@ -450,7 +450,7 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
ctx.strokeWidth = 1;
for (var id in this._selectedItems) {
var item = this._selectedItems[id];
if (item._drawCount === this._drawCount
if (item._updateCount === this._updateCount
&& (item._drawSelected || item._boundsSelected)) {
// Allow definition of selected color on a per item and per
// layer level, with a fallback to #009dec