removed tolerance margin in Costume's shrinkWrap()

Chrome no longer needs this kludge. Removing it also fixes an "empty
costume" bug when drawing over the edges of the paint editor
pull/3/merge
jmoenig 2013-07-02 13:50:14 +02:00
rodzic 09e3a296c2
commit 78f416be9a
2 zmienionych plików z 9 dodań i 9 usunięć

Wyświetl plik

@ -1773,3 +1773,7 @@ ______
130628 130628
------ ------
* Morphic, GUI: improved importing costumes by dragging in pictures from other web pages * Morphic, GUI: improved importing costumes by dragging in pictures from other web pages
130702
------
* Objects: took out "security margin" in Costume's shrinkWrap() method b/c Chrome no longer needs it -> fixed empty costume bug when drawing over the paint editor's bounds

Wyświetl plik

@ -123,7 +123,7 @@ PrototypeHatBlockMorph*/
// Global stuff //////////////////////////////////////////////////////// // Global stuff ////////////////////////////////////////////////////////
modules.objects = '2013-June-27'; modules.objects = '2013-July-02';
var SpriteMorph; var SpriteMorph;
var StageMorph; var StageMorph;
@ -4595,19 +4595,15 @@ Costume.prototype.bounds = function () {
Costume.prototype.shrinkWrap = function () { Costume.prototype.shrinkWrap = function () {
// adjust my contents' bounds to my visible bounding box // adjust my contents' bounds to my visible bounding box
// add a tolerance margin for Chrome's anti-aliasing issue
var bb = this.boundingBox(), var bb = this.boundingBox(),
space = new Point(480, 360).subtract(bb.extent()).floorDivideBy(2), ext = bb.extent(),
margin = new Point(3, 3).min(space.max(new Point(0, 0))),
area = bb.expandBy(margin),
ext = area.extent(),
pic = newCanvas(ext), pic = newCanvas(ext),
ctx = pic.getContext('2d'); ctx = pic.getContext('2d');
ctx.drawImage( ctx.drawImage(
this.contents, this.contents,
area.origin.x, bb.origin.x,
area.origin.y, bb.origin.y,
ext.x, ext.x,
ext.y, ext.y,
0, 0,
@ -4615,7 +4611,7 @@ Costume.prototype.shrinkWrap = function () {
ext.x, ext.x,
ext.y ext.y
); );
this.rotationCenter = this.rotationCenter.subtract(area.origin); this.rotationCenter = this.rotationCenter.subtract(bb.origin);
this.contents = pic; this.contents = pic;
this.version = Date.now(); this.version = Date.now();
}; };