diff --git a/src/item/PlacedSymbol.js b/src/item/PlacedSymbol.js index 0f881dcd..af9c0adf 100644 --- a/src/item/PlacedSymbol.js +++ b/src/item/PlacedSymbol.js @@ -103,12 +103,12 @@ var PlacedSymbol = this.PlacedSymbol = PlacedItem.extend(/** @lends PlacedSymbol }, draw: function(ctx, param) { - if (param.selection) { - Item.drawSelectedBounds(this.symbol._definition.getBounds(), ctx, - this._matrix); - } else { - Item.draw(this.symbol._definition, ctx, param); - } + Item.draw(this.symbol._definition, ctx, param); + }, + + drawSelected: function(ctx, matrix) { + Item.drawSelectedBounds(this.symbol._definition.getBounds(), ctx, + matrix); } // TODO: PlacedSymbol#embed() diff --git a/src/item/Raster.js b/src/item/Raster.js index a80a7676..5e586216 100644 --- a/src/item/Raster.js +++ b/src/item/Raster.js @@ -403,12 +403,12 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{ }, draw: function(ctx, param) { - if (param.selection) { - var bounds = new Rectangle(this._size).setCenter(0, 0); - Item.drawSelectedBounds(bounds, ctx, this._matrix); - } else { - ctx.drawImage(this._canvas || this._image, - -this._size.width / 2, -this._size.height / 2); - } + ctx.drawImage(this._canvas || this._image, + -this._size.width / 2, -this._size.height / 2); + }, + + drawSelected: function(ctx, matrix) { + Item.drawSelectedBounds(new Rectangle(this._size).setCenter(0, 0), ctx, + matrix); } }); diff --git a/src/path/Path.js b/src/path/Path.js index 36e29408..8a2586a5 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -1434,17 +1434,12 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{ // Prepare the canvas path if we have any situation that requires it // to be defined. - if (param.compound || param.selection || this._clipMask || fillColor + if (param.compound || this._clipMask || fillColor || strokeColor && !hasDash) { drawSegments(ctx, this); } - // If we are drawing the selection of a path, stroke it and draw - // its handles: - if (param.selection) { - ctx.stroke(); - drawHandles(ctx, this._segments); - } else if (this._clipMask) { + if (this._clipMask) { ctx.clip(); } else if (!param.compound && (fillColor || strokeColor)) { // If the path is part of a compound path or doesn't have a fill @@ -1464,6 +1459,14 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{ } ctx.restore(); } + }, + + drawSelected: function(ctx, matrix) { + ctx.beginPath(); + drawSegments(ctx, this, matrix); + // Now stroke it and draw its handles: + ctx.stroke(); + drawHandles(ctx, this._segments, matrix); } }; }, new function() { // Path Smoothing diff --git a/src/project/Project.js b/src/project/Project.js index 3f4c3943..f9f8c1f4 100644 --- a/src/project/Project.js +++ b/src/project/Project.js @@ -272,10 +272,13 @@ var Project = this.Project = PaperScopeItem.extend(/** @lends Project# */{ ctx.strokeWidth = 1; // TODO: use Layer#color ctx.strokeStyle = ctx.fillStyle = '#009dec'; - param = { selection: true }; - Base.each(this._selectedItems, function(item) { - item.draw(ctx, param); - }); + for (var id in this._selectedItems) { + var item = this._selectedItems[id], + mx = item.getGlobalMatrix(); + if (matrix) + mx.preConcatenate(matrix); + item.drawSelected(ctx, mx); + } ctx.restore(); } }