VectorPaint: fixed rotation center editing for existing costumes

upd4.2
jmoenig 2018-06-05 12:04:23 +02:00
rodzic b93ef8eac6
commit 9dde6a4fd8
3 zmienionych plików z 22 dodań i 11 usunięć

Wyświetl plik

@ -4119,3 +4119,7 @@ in development:
180604 180604
------ ------
* Blocks: tweaked layout of variadic C-shaped input slots * Blocks: tweaked layout of variadic C-shaped input slots
180605
------
* VectorPaint: fixed rotation center editing for existing costumes

Wyświetl plik

@ -83,7 +83,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize,
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph, TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph,
AlignmentMorph, Process, XML_Element, VectorPaintEditorMorph*/ AlignmentMorph, Process, XML_Element, VectorPaintEditorMorph*/
modules.objects = '2018-May-02'; modules.objects = '2018-June-05';
var SpriteMorph; var SpriteMorph;
var StageMorph; var StageMorph;
@ -8472,12 +8472,8 @@ SVG_Costume.prototype.edit = function (
editor.oncancel = oncancel || nop; editor.oncancel = oncancel || nop;
editor.openIn( editor.openIn(
aWorld, aWorld,
isnew ? isnew ? newCanvas(StageMorph.prototype.dimensions) : this.contents,
newCanvas(StageMorph.prototype.dimensions) : isnew ? new Point(240, 180) : myself.rotationCenter,
this.contents,
isnew ?
new Point(240, 180) :
myself.rotationCenter,
function (img, rc, shapes) { function (img, rc, shapes) {
myself.contents = img; myself.contents = img;
myself.rotationCenter = rc; myself.rotationCenter = rc;

Wyświetl plik

@ -44,6 +44,10 @@
------- -------
Carles Paredes wrote the first working prototype in 2015 Carles Paredes wrote the first working prototype in 2015
Bernat Romagosa rewrote most of the code in 2017 Bernat Romagosa rewrote most of the code in 2017
revision history
----------------
2018, June 5 - fixed initial rotation center for an existing costume (Jens)
*/ */
/*global Point, Object, Rectangle, AlignmentMorph, Morph, XML_Element, nop, /*global Point, Object, Rectangle, AlignmentMorph, Morph, XML_Element, nop,
@ -51,7 +55,7 @@ PaintColorPickerMorph, Color, SliderMorph, InputFieldMorph, ToggleMorph,
TextMorph, Image, newCanvas, PaintEditorMorph, StageMorph, Costume, isNil, TextMorph, Image, newCanvas, PaintEditorMorph, StageMorph, Costume, isNil,
localize, PaintCanvasMorph, detect, modules*/ localize, PaintCanvasMorph, detect, modules*/
modules.vectorPaint = '2018-March-19'; modules.vectorPaint = '2018-June-05';
// Declarations // Declarations
@ -987,12 +991,11 @@ VectorPaintEditorMorph.prototype.buildScaleBox = function () {
}; };
VectorPaintEditorMorph.prototype.openIn = function (world, oldim, oldrc, callback, anIDE, shapes) { VectorPaintEditorMorph.prototype.openIn = function (world, oldim, oldrc, callback, anIDE, shapes) {
var myself = this; var myself = this,
isEmpty = isNil(shapes) || shapes.length === 0;
VectorPaintEditorMorph.uber.openIn.call(this, world, null, oldrc, callback); VectorPaintEditorMorph.uber.openIn.call(this, world, null, oldrc, callback);
this.paper.automaticCrosshairs = isNil(shapes) || shapes.length === 0;
this.shapes = shapes.map(function (eachShape) { return eachShape.copy(); }); this.shapes = shapes.map(function (eachShape) { return eachShape.copy(); });
this.ide = anIDE; this.ide = anIDE;
@ -1003,6 +1006,14 @@ VectorPaintEditorMorph.prototype.openIn = function (world, oldim, oldrc, callbac
shape.drawOn(myself.paper); shape.drawOn(myself.paper);
}); });
// init the rotation center, if any
if (oldrc && !isEmpty) {
this.paper.automaticCrosshairs = false;
this.paper.rotationCenter = this.getBounds(this.shapes).origin.subtract(this.paper.bounds.origin).add(oldrc);
} else {
this.paper.automaticCrosshairs = true;
}
this.updateHistory(); this.updateHistory();
this.processKeyUp = function () { this.processKeyUp = function () {