kopia lustrzana https://github.com/backface/turtlestitch
tweaks - mostly for LINT
rodzic
d744da2832
commit
d9edaa7ab6
4
gui.js
4
gui.js
|
@ -5204,7 +5204,9 @@ IDE_Morph.prototype.initializeCloud = function () {
|
||||||
myself.source = 'cloud';
|
myself.source = 'cloud';
|
||||||
if (!isNil(response.days_left)) {
|
if (!isNil(response.days_left)) {
|
||||||
new DialogBoxMorph().inform(
|
new DialogBoxMorph().inform(
|
||||||
'Unverified account: ' + response.days_left + ' days left',
|
'Unverified account: ' +
|
||||||
|
response.days_left +
|
||||||
|
' days left',
|
||||||
'You are now logged in, and your account\n' +
|
'You are now logged in, and your account\n' +
|
||||||
'is enabled for three days.\n' +
|
'is enabled for three days.\n' +
|
||||||
'Please use the verification link that\n' +
|
'Please use the verification link that\n' +
|
||||||
|
|
|
@ -1163,7 +1163,7 @@
|
||||||
|
|
||||||
/*global window, HTMLCanvasElement, FileReader, Audio, FileList*/
|
/*global window, HTMLCanvasElement, FileReader, Audio, FileList*/
|
||||||
|
|
||||||
var morphicVersion = '2018-February-06';
|
var morphicVersion = '2018-March-19';
|
||||||
var modules = {}; // keep track of additional loaded modules
|
var modules = {}; // keep track of additional loaded modules
|
||||||
var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug
|
var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug
|
||||||
|
|
||||||
|
|
16
objects.js
16
objects.js
|
@ -81,7 +81,7 @@ modules, IDE_Morph, VariableDialogMorph, HTMLCanvasElement, Context, List,
|
||||||
SpeechBubbleMorph, RingMorph, isNil, FileReader, TableDialogMorph,
|
SpeechBubbleMorph, RingMorph, isNil, FileReader, TableDialogMorph,
|
||||||
BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize,
|
BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize,
|
||||||
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph,
|
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph,
|
||||||
AlignmentMorph, Process*/
|
AlignmentMorph, Process, XML_Element, VectorPaintEditorMorph*/
|
||||||
|
|
||||||
modules.objects = '2018-March-19';
|
modules.objects = '2018-March-19';
|
||||||
|
|
||||||
|
@ -8449,14 +8449,20 @@ SVG_Costume.prototype.parseShapes = function () {
|
||||||
|
|
||||||
element.parseString(contents);
|
element.parseString(contents);
|
||||||
|
|
||||||
if (this.shapes.length == 0 && element.attributes['snap']) {
|
if (this.shapes.length === 0 && element.attributes.snap) {
|
||||||
this.shapes = element.children.map(function (child) {
|
this.shapes = element.children.map(function (child) {
|
||||||
return window[child.attributes.prototype].fromSVG(child);
|
return window[child.attributes.prototype].fromSVG(child);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SVG_Costume.prototype.edit = function (aWorld, anIDE, isnew, oncancel, onsubmit) {
|
SVG_Costume.prototype.edit = function (
|
||||||
|
aWorld,
|
||||||
|
anIDE,
|
||||||
|
isnew,
|
||||||
|
oncancel,
|
||||||
|
onsubmit
|
||||||
|
) {
|
||||||
var myself = this,
|
var myself = this,
|
||||||
editor;
|
editor;
|
||||||
|
|
||||||
|
@ -8478,7 +8484,7 @@ SVG_Costume.prototype.edit = function (aWorld, anIDE, isnew, oncancel, onsubmit)
|
||||||
myself.version = Date.now();
|
myself.version = Date.now();
|
||||||
aWorld.changed();
|
aWorld.changed();
|
||||||
if (anIDE) {
|
if (anIDE) {
|
||||||
if (isnew) { anIDE.currentSprite.addCostume(myself) };
|
if (isnew) {anIDE.currentSprite.addCostume(myself); }
|
||||||
anIDE.currentSprite.wearCostume(myself);
|
anIDE.currentSprite.wearCostume(myself);
|
||||||
anIDE.hasChangedMedia = true;
|
anIDE.hasChangedMedia = true;
|
||||||
}
|
}
|
||||||
|
|
23
paint.js
23
paint.js
|
@ -5,7 +5,7 @@
|
||||||
inspired by the Scratch paint editor.
|
inspired by the Scratch paint editor.
|
||||||
|
|
||||||
written by Kartik Chandra
|
written by Kartik Chandra
|
||||||
Copyright (C) 2016 by Kartik Chandra
|
Copyright (C) 2018 by Kartik Chandra
|
||||||
|
|
||||||
This file is part of Snap!.
|
This file is part of Snap!.
|
||||||
|
|
||||||
|
@ -67,17 +67,18 @@
|
||||||
Apr 10 - getGlobalPixelColor adjustment for Chrome & retina (Jens)
|
Apr 10 - getGlobalPixelColor adjustment for Chrome & retina (Jens)
|
||||||
2018
|
2018
|
||||||
Jan 22 - floodfill alpha tweak (Bernat)
|
Jan 22 - floodfill alpha tweak (Bernat)
|
||||||
|
Mar 19 - vector paint editor (Bernat)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*global Point, Rectangle, DialogBoxMorph, AlignmentMorph, PushButtonMorph,
|
/*global Point, Rectangle, DialogBoxMorph, AlignmentMorph, PushButtonMorph,
|
||||||
Color, SymbolMorph, newCanvas, Morph, TextMorph, Costume, SpriteMorph, nop,
|
Color, SymbolMorph, newCanvas, Morph, TextMorph, Costume, SpriteMorph, nop,
|
||||||
localize, InputFieldMorph, SliderMorph, ToggleMorph, ToggleButtonMorph,
|
localize, InputFieldMorph, SliderMorph, ToggleMorph, ToggleButtonMorph,
|
||||||
BoxMorph, modules, radians, MorphicPreferences, getDocumentPositionOf,
|
BoxMorph, modules, radians, MorphicPreferences, getDocumentPositionOf,
|
||||||
StageMorph, isNil*/
|
StageMorph, isNil, SVG_Costume*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.paint = '2018-January-22';
|
modules.paint = '2018-March-19';
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
|
|
||||||
|
@ -274,7 +275,13 @@ PaintEditorMorph.prototype.buildScaleBox = function () {
|
||||||
this.scaleBox.fixLayout();
|
this.scaleBox.fixLayout();
|
||||||
};
|
};
|
||||||
|
|
||||||
PaintEditorMorph.prototype.openIn = function (world, oldim, oldrc, callback, anIDE) {
|
PaintEditorMorph.prototype.openIn = function (
|
||||||
|
world,
|
||||||
|
oldim,
|
||||||
|
oldrc,
|
||||||
|
callback,
|
||||||
|
anIDE
|
||||||
|
) {
|
||||||
// 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;
|
||||||
this.callback = callback || nop;
|
this.callback = callback || nop;
|
||||||
|
@ -646,7 +653,10 @@ PaintCanvasMorph.prototype.calculateCanvasCenter = function(canvas) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// Can't use canvasBounds.center(), it rounds down.
|
// Can't use canvasBounds.center(), it rounds down.
|
||||||
return new Point((canvasBounds.origin.x + canvasBounds.corner.x) / 2, (canvasBounds.origin.y + canvasBounds.corner.y) / 2);
|
return new Point(
|
||||||
|
(canvasBounds.origin.x + canvasBounds.corner.x) / 2,
|
||||||
|
(canvasBounds.origin.y + canvasBounds.corner.y) / 2
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// If we are in automaticCrosshairs mode, recalculate the rotationCenter.
|
// If we are in automaticCrosshairs mode, recalculate the rotationCenter.
|
||||||
|
@ -982,7 +992,8 @@ PaintCanvasMorph.prototype.mouseMove = function (pos) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "crosshairs":
|
case "crosshairs":
|
||||||
// Disable automatic crosshairs: user has now chosen where they should be.
|
// Disable automatic crosshairs:
|
||||||
|
// user has now chosen where they should be.
|
||||||
this.automaticCrosshairs = false;
|
this.automaticCrosshairs = false;
|
||||||
this.rotationCenter = relpos.copy();
|
this.rotationCenter = relpos.copy();
|
||||||
this.drawcrosshair(mctx);
|
this.drawcrosshair(mctx);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
written by Jens Mönig
|
written by Jens Mönig
|
||||||
jens@moenig.org
|
jens@moenig.org
|
||||||
|
|
||||||
Copyright (C) 2017 by Jens Mönig
|
Copyright (C) 2018 by Jens Mönig
|
||||||
|
|
||||||
This file is part of Snap!.
|
This file is part of Snap!.
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.symbols = '2017-September-26';
|
modules.symbols = '2018-March-19';
|
||||||
|
|
||||||
var SymbolMorph;
|
var SymbolMorph;
|
||||||
|
|
||||||
|
@ -1608,7 +1608,8 @@ SymbolMorph.prototype.drawSymbolOctagonOutline = function (canvas, color) {
|
||||||
return canvas;
|
return canvas;
|
||||||
};
|
};
|
||||||
|
|
||||||
SymbolMorph.prototype.drawSymbolClosedBrushPath = SymbolMorph.prototype.drawSymbolCloudOutline;
|
SymbolMorph.prototype.drawSymbolClosedBrushPath =
|
||||||
|
SymbolMorph.prototype.drawSymbolCloudOutline;
|
||||||
|
|
||||||
SymbolMorph.prototype.drawSymbolNotes = function (canvas, color) {
|
SymbolMorph.prototype.drawSymbolNotes = function (canvas, color) {
|
||||||
// answer a canvas showing two musical notes
|
// answer a canvas showing two musical notes
|
||||||
|
|
|
@ -46,9 +46,12 @@
|
||||||
Bernat Romagosa rewrote most of the code in 2017
|
Bernat Romagosa rewrote most of the code in 2017
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*global Point, Object, Rectangle, ToggleButtonMorph, AlignmentMorph, Morph,
|
/*global Point, Object, Rectangle, AlignmentMorph, Morph, XML_Element, nop,
|
||||||
PaintColorPickerMorph, Color, SliderMorph, InputFieldMorph, ToggleMorph,
|
PaintColorPickerMorph, Color, SliderMorph, InputFieldMorph, ToggleMorph,
|
||||||
TextMorph, Image, VectorPaintEditorMorph, newCanvas */
|
TextMorph, Image, newCanvas, PaintEditorMorph, StageMorph, Costume, isNil,
|
||||||
|
localize, PaintCanvasMorph, detect, modules*/
|
||||||
|
|
||||||
|
modules.vectorPaint = '2018-March-19';
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
|
|
||||||
|
@ -64,13 +67,13 @@ var VectorPaintCanvasMorph;
|
||||||
|
|
||||||
// VectorShape
|
// VectorShape
|
||||||
|
|
||||||
VectorShape.prototype = new Object();
|
VectorShape.prototype = {};
|
||||||
VectorShape.prototype.constructor = VectorShape;
|
VectorShape.prototype.constructor = VectorShape;
|
||||||
VectorShape.uber = Object.prototype;
|
VectorShape.uber = Object.prototype;
|
||||||
|
|
||||||
function VectorShape (borderWidth, borderColor, fillColor) {
|
function VectorShape (borderWidth, borderColor, fillColor) {
|
||||||
this.init(borderWidth, borderColor, fillColor);
|
this.init(borderWidth, borderColor, fillColor);
|
||||||
};
|
}
|
||||||
|
|
||||||
VectorShape.prototype.init = function (borderWidth, borderColor, fillColor) {
|
VectorShape.prototype.init = function (borderWidth, borderColor, fillColor) {
|
||||||
this.borderWidth = (borderColor && borderColor.a) ? borderWidth : 0;
|
this.borderWidth = (borderColor && borderColor.a) ? borderWidth : 0;
|
||||||
|
@ -226,7 +229,7 @@ VectorRectangle.uber = VectorShape.prototype;
|
||||||
function VectorRectangle (borderWidth, borderColor, fillColor, origin, destination) {
|
function VectorRectangle (borderWidth, borderColor, fillColor, origin, destination) {
|
||||||
VectorRectangle.uber.init.call(this, borderWidth, borderColor, fillColor);
|
VectorRectangle.uber.init.call(this, borderWidth, borderColor, fillColor);
|
||||||
this.init(origin, destination);
|
this.init(origin, destination);
|
||||||
};
|
}
|
||||||
|
|
||||||
VectorRectangle.prototype.init = function (origin, destination) {
|
VectorRectangle.prototype.init = function (origin, destination) {
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
|
@ -331,7 +334,7 @@ VectorLine.uber = VectorShape.prototype;
|
||||||
function VectorLine (borderWidth, borderColor, origin, destination) {
|
function VectorLine (borderWidth, borderColor, origin, destination) {
|
||||||
VectorLine.uber.init.call(this, borderWidth, borderColor);
|
VectorLine.uber.init.call(this, borderWidth, borderColor);
|
||||||
this.init(origin, destination);
|
this.init(origin, destination);
|
||||||
};
|
}
|
||||||
|
|
||||||
VectorLine.prototype.init = function(origin, destination) {
|
VectorLine.prototype.init = function(origin, destination) {
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
|
@ -433,7 +436,7 @@ VectorEllipse.uber = VectorShape.prototype;
|
||||||
function VectorEllipse (borderWidth, borderColor, fillColor, origin, destination) {
|
function VectorEllipse (borderWidth, borderColor, fillColor, origin, destination) {
|
||||||
VectorEllipse.uber.init.call(this, borderWidth, borderColor, fillColor);
|
VectorEllipse.uber.init.call(this, borderWidth, borderColor, fillColor);
|
||||||
this.init(origin, destination);
|
this.init(origin, destination);
|
||||||
};
|
}
|
||||||
|
|
||||||
VectorEllipse.prototype.init = function (origin, destination) {
|
VectorEllipse.prototype.init = function (origin, destination) {
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
|
@ -497,7 +500,7 @@ VectorEllipse.prototype.bounds = function () {
|
||||||
|
|
||||||
VectorEllipse.prototype.containsPoint = function (aPoint) {
|
VectorEllipse.prototype.containsPoint = function (aPoint) {
|
||||||
return (Math.pow(aPoint.x - this.origin.x, 2) / Math.pow(this.hRadius() + this.borderWidth / 2, 2) +
|
return (Math.pow(aPoint.x - this.origin.x, 2) / Math.pow(this.hRadius() + this.borderWidth / 2, 2) +
|
||||||
Math.pow(aPoint.y - this.origin.y, 2) / Math.pow(this.vRadius() + this.borderWidth / 2, 2)) < 1
|
Math.pow(aPoint.y - this.origin.y, 2) / Math.pow(this.vRadius() + this.borderWidth / 2, 2)) < 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
VectorEllipse.prototype.asSVG = function () {
|
VectorEllipse.prototype.asSVG = function () {
|
||||||
|
@ -553,7 +556,7 @@ VectorPolygon.uber = VectorShape.prototype;
|
||||||
function VectorPolygon (borderWidth, borderColor, fillColor, points, isClosed, isFreeHand) {
|
function VectorPolygon (borderWidth, borderColor, fillColor, points, isClosed, isFreeHand) {
|
||||||
VectorPolygon.uber.init.call(this, borderWidth, borderColor, fillColor);
|
VectorPolygon.uber.init.call(this, borderWidth, borderColor, fillColor);
|
||||||
this.init(points, isClosed, isFreeHand);
|
this.init(points, isClosed, isFreeHand);
|
||||||
};
|
}
|
||||||
|
|
||||||
VectorPolygon.prototype.init = function (points, isClosed, isFreeHand) {
|
VectorPolygon.prototype.init = function (points, isClosed, isFreeHand) {
|
||||||
this.points = points || [ ];
|
this.points = points || [ ];
|
||||||
|
@ -583,7 +586,7 @@ VectorPolygon.fromSVG = function (svg) {
|
||||||
|
|
||||||
points, // points
|
points, // points
|
||||||
points[0].eq(points[points.length - 1]), // isClosed
|
points[0].eq(points[points.length - 1]), // isClosed
|
||||||
false, // isFreeHand, does only matter when drawing it
|
false // isFreeHand, does only matter when drawing it
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -765,10 +768,10 @@ function VectorSelection (origin, destination) {
|
||||||
this,
|
this,
|
||||||
1, // borderWidth
|
1, // borderWidth
|
||||||
new Color(0, 0, 0, 255), // borderColor
|
new Color(0, 0, 0, 255), // borderColor
|
||||||
null, // fillColor
|
null // fillColor
|
||||||
);
|
);
|
||||||
this.init(origin, destination);
|
this.init(origin, destination);
|
||||||
};
|
}
|
||||||
|
|
||||||
VectorSelection.prototype.init = function (origin, destination) {
|
VectorSelection.prototype.init = function (origin, destination) {
|
||||||
VectorSelection.uber.init.call(this, origin, destination);
|
VectorSelection.uber.init.call(this, origin, destination);
|
||||||
|
@ -795,8 +798,6 @@ VectorSelection.prototype.cornerAt = function (aPoint) {
|
||||||
};
|
};
|
||||||
|
|
||||||
VectorSelection.prototype.cornerOppositeTo = function (aPoint) {
|
VectorSelection.prototype.cornerOppositeTo = function (aPoint) {
|
||||||
var threshold = this.threshold;
|
|
||||||
|
|
||||||
return this.corners().reduce(function(a, b) {
|
return this.corners().reduce(function(a, b) {
|
||||||
return (aPoint.distanceTo(a) > aPoint.distanceTo(b)) ? a : b;
|
return (aPoint.distanceTo(a) > aPoint.distanceTo(b)) ? a : b;
|
||||||
});
|
});
|
||||||
|
@ -829,7 +830,7 @@ VectorSelection.prototype.drawOn = function (aCanvasMorph) {
|
||||||
2 * Math.PI
|
2 * Math.PI
|
||||||
);
|
);
|
||||||
context.stroke();
|
context.stroke();
|
||||||
};
|
}
|
||||||
|
|
||||||
drawCircle(bounds.left(), bounds.top());
|
drawCircle(bounds.left(), bounds.top());
|
||||||
drawCircle(bounds.left(), bounds.bottom());
|
drawCircle(bounds.left(), bounds.bottom());
|
||||||
|
@ -848,7 +849,7 @@ Crosshair.uber = VectorShape.prototype;
|
||||||
|
|
||||||
function Crosshair (center, paper) {
|
function Crosshair (center, paper) {
|
||||||
this.init(center, paper);
|
this.init(center, paper);
|
||||||
};
|
}
|
||||||
|
|
||||||
Crosshair.prototype.init = function (center, paper) {
|
Crosshair.prototype.init = function (center, paper) {
|
||||||
this.center = center;
|
this.center = center;
|
||||||
|
@ -880,11 +881,9 @@ VectorPaintEditorMorph.uber = PaintEditorMorph.prototype;
|
||||||
|
|
||||||
function VectorPaintEditorMorph() {
|
function VectorPaintEditorMorph() {
|
||||||
this.init();
|
this.init();
|
||||||
};
|
}
|
||||||
|
|
||||||
VectorPaintEditorMorph.prototype.init = function () {
|
VectorPaintEditorMorph.prototype.init = function () {
|
||||||
var myself = this;
|
|
||||||
|
|
||||||
// additional properties:
|
// additional properties:
|
||||||
this.paper = null; // paint canvas
|
this.paper = null; // paint canvas
|
||||||
this.shapes = [];
|
this.shapes = [];
|
||||||
|
@ -1061,7 +1060,7 @@ VectorPaintEditorMorph.prototype.openIn = function (world, oldim, oldrc, callbac
|
||||||
/* Ctrl + Z */
|
/* Ctrl + Z */
|
||||||
if (this.ctrl) {
|
if (this.ctrl) {
|
||||||
this.undo();
|
this.undo();
|
||||||
};
|
}
|
||||||
break;
|
break;
|
||||||
case 67:
|
case 67:
|
||||||
/* Ctrl + C */
|
/* Ctrl + C */
|
||||||
|
@ -1079,7 +1078,7 @@ VectorPaintEditorMorph.prototype.openIn = function (world, oldim, oldrc, callbac
|
||||||
if (this.ctrl && this.paper.bounds.containsPoint(pos)) {
|
if (this.ctrl && this.paper.bounds.containsPoint(pos)) {
|
||||||
this.paper.pasteAt(pos);
|
this.paper.pasteAt(pos);
|
||||||
this.updateHistory();
|
this.updateHistory();
|
||||||
};
|
}
|
||||||
break;
|
break;
|
||||||
case 65:
|
case 65:
|
||||||
/* Ctrl + A */
|
/* Ctrl + A */
|
||||||
|
@ -1135,7 +1134,7 @@ VectorPaintEditorMorph.prototype.buildContents = function() {
|
||||||
this.refreshToolButtons();
|
this.refreshToolButtons();
|
||||||
this.fixLayout();
|
this.fixLayout();
|
||||||
this.drawNew();
|
this.drawNew();
|
||||||
}
|
};
|
||||||
|
|
||||||
VectorPaintEditorMorph.prototype.buildToolbox = function () {
|
VectorPaintEditorMorph.prototype.buildToolbox = function () {
|
||||||
var tools = {
|
var tools = {
|
||||||
|
@ -1194,7 +1193,7 @@ VectorPaintEditorMorph.prototype.populatePropertiesMenu = function () {
|
||||||
var c = this.controls,
|
var c = this.controls,
|
||||||
myself = this,
|
myself = this,
|
||||||
pc = this.propertiesControls,
|
pc = this.propertiesControls,
|
||||||
alpen = new AlignmentMorph("row", this.padding);
|
alpen = new AlignmentMorph("row", this.padding),
|
||||||
alignColor = new AlignmentMorph("row", this.padding);
|
alignColor = new AlignmentMorph("row", this.padding);
|
||||||
|
|
||||||
pc.primaryColorViewer = new Morph();
|
pc.primaryColorViewer = new Morph();
|
||||||
|
@ -1233,7 +1232,7 @@ VectorPaintEditorMorph.prototype.populatePropertiesMenu = function () {
|
||||||
pc.penSizeField = new InputFieldMorph("3", true, null, false);
|
pc.penSizeField = new InputFieldMorph("3", true, null, false);
|
||||||
pc.penSizeField.contents().minWidth = 20;
|
pc.penSizeField.contents().minWidth = 20;
|
||||||
pc.penSizeField.setWidth(25);
|
pc.penSizeField.setWidth(25);
|
||||||
pc.penSizeField.accept = function () {
|
pc.penSizeField.accept = function (num) {
|
||||||
var val = parseFloat(pc.penSizeField.getValue());
|
var val = parseFloat(pc.penSizeField.getValue());
|
||||||
pc.penSizeSlider.value = val;
|
pc.penSizeSlider.value = val;
|
||||||
pc.penSizeSlider.drawNew();
|
pc.penSizeSlider.drawNew();
|
||||||
|
@ -1277,12 +1276,13 @@ VectorPaintEditorMorph.prototype.populatePropertiesMenu = function () {
|
||||||
|
|
||||||
VectorPaintEditorMorph.prototype.selectColor = function (color, isSecondary) {
|
VectorPaintEditorMorph.prototype.selectColor = function (color, isSecondary) {
|
||||||
var myself = this,
|
var myself = this,
|
||||||
isSecondary = isSecondary || this.paper.isShiftPressed(),
|
|
||||||
propertyName = (isSecondary ? 'secondary' : 'primary') + 'Color',
|
propertyName = (isSecondary ? 'secondary' : 'primary') + 'Color',
|
||||||
ni = newCanvas(this.propertiesControls[propertyName + 'Viewer'].extent()),
|
ni = newCanvas(this.propertiesControls[propertyName + 'Viewer'].extent()),
|
||||||
ctx = ni.getContext('2d'),
|
ctx = ni.getContext('2d'),
|
||||||
i, j;
|
i, j;
|
||||||
|
|
||||||
|
if (!isSecondary) {isSecondary = this.paper.isShiftPressed(); }
|
||||||
|
|
||||||
this.paper.settings[(propertyName)] = color;
|
this.paper.settings[(propertyName)] = color;
|
||||||
|
|
||||||
if (this.selection.length) {
|
if (this.selection.length) {
|
||||||
|
@ -1306,7 +1306,7 @@ VectorPaintEditorMorph.prototype.selectColor = function (color, isSecondary) {
|
||||||
} else {
|
} else {
|
||||||
ctx.fillStyle = color.toString();
|
ctx.fillStyle = color.toString();
|
||||||
ctx.fillRect(0, 0, 180, 15);
|
ctx.fillRect(0, 0, 180, 15);
|
||||||
};
|
}
|
||||||
|
|
||||||
//Brush size
|
//Brush size
|
||||||
ctx.strokeStyle = 'black';
|
ctx.strokeStyle = 'black';
|
||||||
|
@ -1362,8 +1362,7 @@ VectorPaintEditorMorph.prototype.changeSelectionLayer = function (destination) {
|
||||||
};
|
};
|
||||||
|
|
||||||
VectorPaintEditorMorph.prototype.dragSelection = function (pos) {
|
VectorPaintEditorMorph.prototype.dragSelection = function (pos) {
|
||||||
var myself = this,
|
var origin,
|
||||||
origin,
|
|
||||||
ratio,
|
ratio,
|
||||||
delta;
|
delta;
|
||||||
|
|
||||||
|
@ -1461,7 +1460,7 @@ VectorPaintEditorMorph.prototype.getSVG = function () {
|
||||||
VectorPaintEditorMorph.prototype.getBounds = function (shapeCollection) {
|
VectorPaintEditorMorph.prototype.getBounds = function (shapeCollection) {
|
||||||
var shapeBounds = shapeCollection.map(function(each) { return each.bounds(); });
|
var shapeBounds = shapeCollection.map(function(each) { return each.bounds(); });
|
||||||
|
|
||||||
if (shapeBounds.length == 0) { return null; }
|
if (shapeBounds.length === 0) { return null; }
|
||||||
|
|
||||||
return shapeBounds.reduce(
|
return shapeBounds.reduce(
|
||||||
function(previous, current) {
|
function(previous, current) {
|
||||||
|
@ -1496,7 +1495,7 @@ VectorPaintEditorMorph.prototype.ok = function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
shapeOrigin = this.getBounds(this.shapes).origin,
|
shapeOrigin = this.getBounds(this.shapes).origin;
|
||||||
originDelta = shapeOrigin.subtract(this.paper.bounds.origin);
|
originDelta = shapeOrigin.subtract(this.paper.bounds.origin);
|
||||||
|
|
||||||
this.paper.updateAutomaticCenter();
|
this.paper.updateAutomaticCenter();
|
||||||
|
@ -1525,11 +1524,13 @@ VectorPaintEditorMorph.prototype.undo = function () {
|
||||||
oldSum = this.checksum(),
|
oldSum = this.checksum(),
|
||||||
newSum = oldSum;
|
newSum = oldSum;
|
||||||
|
|
||||||
|
function draw(shape) {
|
||||||
|
shape.drawOn(paper);
|
||||||
|
}
|
||||||
|
|
||||||
while (this.shapes.length && oldSum == newSum) {
|
while (this.shapes.length && oldSum == newSum) {
|
||||||
this.shapes = this.history.pop() || [];
|
this.shapes = this.history.pop() || [];
|
||||||
this.shapes.forEach(function (shape) {
|
this.shapes.forEach(draw);
|
||||||
shape.drawOn(paper);
|
|
||||||
});
|
|
||||||
newSum = this.checksum();
|
newSum = this.checksum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1552,7 +1553,7 @@ VectorPaintCanvasMorph.uber = PaintCanvasMorph.prototype;
|
||||||
|
|
||||||
function VectorPaintCanvasMorph (shift) {
|
function VectorPaintCanvasMorph (shift) {
|
||||||
this.init(shift);
|
this.init(shift);
|
||||||
};
|
}
|
||||||
|
|
||||||
VectorPaintCanvasMorph.prototype.init = function (shift) {
|
VectorPaintCanvasMorph.prototype.init = function (shift) {
|
||||||
VectorPaintCanvasMorph.uber.init.call(this, shift);
|
VectorPaintCanvasMorph.uber.init.call(this, shift);
|
||||||
|
@ -1566,8 +1567,7 @@ VectorPaintCanvasMorph.prototype.init = function (shift) {
|
||||||
};
|
};
|
||||||
|
|
||||||
VectorPaintCanvasMorph.prototype.calculateCanvasCenter = function () {
|
VectorPaintCanvasMorph.prototype.calculateCanvasCenter = function () {
|
||||||
var editor = this.parentThatIsA(VectorPaintEditorMorph);
|
var canvasBounds = this.bounds;
|
||||||
canvasBounds = this.bounds;
|
|
||||||
|
|
||||||
// Can't use canvasBounds.center(), it rounds down.
|
// Can't use canvasBounds.center(), it rounds down.
|
||||||
return new Point(
|
return new Point(
|
||||||
|
@ -1632,7 +1632,7 @@ VectorPaintCanvasMorph.prototype.drawNew = function () {
|
||||||
this.merge(this.paper, canvas);
|
this.merge(this.paper, canvas);
|
||||||
|
|
||||||
editor.shapes.forEach(function(each) {
|
editor.shapes.forEach(function(each) {
|
||||||
myself.merge(each.image, canvas)
|
myself.merge(each.image, canvas);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (editor.currentShape) {
|
if (editor.currentShape) {
|
||||||
|
|
Ładowanie…
Reference in New Issue