kopia lustrzana https://github.com/backface/turtlestitch
commit
d984836bed
41
paint.js
41
paint.js
|
@ -53,6 +53,7 @@
|
||||||
Jan 08 - mouse leave dragging fix (Kartik)
|
Jan 08 - mouse leave dragging fix (Kartik)
|
||||||
Feb 11 - dynamically adjust to stage dimensions (Jens)
|
Feb 11 - dynamically adjust to stage dimensions (Jens)
|
||||||
Apr 30 - localizations (Manuel)
|
Apr 30 - localizations (Manuel)
|
||||||
|
June 3 - transformations (Kartik)
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.paint = '2014-May-02';
|
modules.paint = '2014-June-3';
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
|
|
||||||
|
@ -133,6 +134,10 @@ PaintEditorMorph.prototype.buildContents = function () {
|
||||||
this.buildToolbox();
|
this.buildToolbox();
|
||||||
this.controls.add(this.toolbox);
|
this.controls.add(this.toolbox);
|
||||||
|
|
||||||
|
this.scaleBox = new AlignmentMorph('row', this.padding);
|
||||||
|
this.buildScaleBox();
|
||||||
|
this.controls.add(this.scaleBox);
|
||||||
|
|
||||||
this.propertiesControls = {
|
this.propertiesControls = {
|
||||||
colorpicker: null,
|
colorpicker: null,
|
||||||
penSizeSlider: null,
|
penSizeSlider: null,
|
||||||
|
@ -218,6 +223,27 @@ PaintEditorMorph.prototype.buildEdits = function () {
|
||||||
this.edits.fixLayout();
|
this.edits.fixLayout();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PaintEditorMorph.prototype.buildScaleBox = function () {
|
||||||
|
var paper = this.paper;
|
||||||
|
this.scaleBox.add(this.pushButton(
|
||||||
|
"grow",
|
||||||
|
function () {paper.scale(0.05, 0.05); }
|
||||||
|
));
|
||||||
|
this.scaleBox.add(this.pushButton(
|
||||||
|
"shrink",
|
||||||
|
function () {paper.scale(-0.05, -0.05); }
|
||||||
|
));
|
||||||
|
this.scaleBox.add(this.pushButton(
|
||||||
|
"flip ↔",
|
||||||
|
function () {paper.scale(-2, 0); }
|
||||||
|
));
|
||||||
|
this.scaleBox.add(this.pushButton(
|
||||||
|
"flip ↕",
|
||||||
|
function () {paper.scale(0, -2); }
|
||||||
|
));
|
||||||
|
this.scaleBox.fixLayout();
|
||||||
|
};
|
||||||
|
|
||||||
PaintEditorMorph.prototype.openIn = function (world, oldim, oldrc, callback) {
|
PaintEditorMorph.prototype.openIn = function (world, oldim, oldrc, callback) {
|
||||||
// Open the editor in a world with an optional image to edit
|
// Open the editor in a world with an optional image to edit
|
||||||
this.oldim = oldim;
|
this.oldim = oldim;
|
||||||
|
@ -558,6 +584,19 @@ PaintCanvasMorph.prototype.init = function (shift) {
|
||||||
this.buildContents();
|
this.buildContents();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PaintCanvasMorph.prototype.scale = function(x, y) {
|
||||||
|
this.mask = newCanvas(this.extent());
|
||||||
|
var c = newCanvas(this.extent());
|
||||||
|
c.getContext("2d").save();
|
||||||
|
c.getContext("2d").translate(this.rotationCenter.x, this.rotationCenter.y);
|
||||||
|
c.getContext("2d").scale(1 + x, 1 + y);
|
||||||
|
c.getContext("2d").drawImage(this.paper, -this.rotationCenter.x, -this.rotationCenter.y);
|
||||||
|
c.getContext("2d").restore();
|
||||||
|
this.paper = c;
|
||||||
|
this.drawNew();
|
||||||
|
this.changed();
|
||||||
|
};
|
||||||
|
|
||||||
PaintCanvasMorph.prototype.cacheUndo = function () {
|
PaintCanvasMorph.prototype.cacheUndo = function () {
|
||||||
var cachecan = newCanvas(this.extent());
|
var cachecan = newCanvas(this.extent());
|
||||||
this.merge(this.paper, cachecan);
|
this.merge(this.paper, cachecan);
|
||||||
|
|
Ładowanie…
Reference in New Issue