kopia lustrzana https://github.com/backface/turtlestitch
Paint Editor: Pipette tool
and code formatting adjustments for JSLintpull/3/merge
rodzic
7eba03eaf1
commit
1a8b2658db
|
@ -1805,3 +1805,8 @@ ______
|
||||||
* Blocks: fixed occasional flickering in scripting areas (caused by deleted feedback morphs, a bug that surfaced in Chrome 28 on OSX and may be due to a possible Chrome GC issue)
|
* Blocks: fixed occasional flickering in scripting areas (caused by deleted feedback morphs, a bug that surfaced in Chrome 28 on OSX and may be due to a possible Chrome GC issue)
|
||||||
* Blocks: preserve nested blocks in the scripting area when replacing a variadic input list with another input ("kick out" the nested blocks instead of "swallowing" them)
|
* Blocks: preserve nested blocks in the scripting area when replacing a variadic input list with another input ("kick out" the nested blocks instead of "swallowing" them)
|
||||||
* Blocks, Threads: new floor() function in monadic math reporter's drop-down
|
* Blocks, Threads: new floor() function in monadic math reporter's drop-down
|
||||||
|
|
||||||
|
130712
|
||||||
|
------
|
||||||
|
* Blocks: Pipette symbol
|
||||||
|
* Paint: Pipette tool
|
||||||
|
|
46
paint.js
46
paint.js
|
@ -46,8 +46,9 @@
|
||||||
revision history
|
revision history
|
||||||
----------------
|
----------------
|
||||||
May 10 - first full release (Kartik)
|
May 10 - first full release (Kartik)
|
||||||
May 14 - bugfixes (bugfixes, Snap integration (Jens)
|
May 14 - bugfixes, Snap integration (Jens)
|
||||||
May 16 - flat design adjustments (Jens)
|
May 16 - flat design adjustments (Jens)
|
||||||
|
July 12 - pipette tool, code formatting adjustments (Jens)
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -56,12 +57,12 @@
|
||||||
CostumeIconMorph, IDE_Morph, Costume, SpriteMorph, nop, Image, WardrobeMorph,
|
CostumeIconMorph, IDE_Morph, Costume, SpriteMorph, nop, Image, WardrobeMorph,
|
||||||
TurtleIconMorph, localize, MenuMorph, InputFieldMorph, SliderMorph,
|
TurtleIconMorph, localize, MenuMorph, InputFieldMorph, SliderMorph,
|
||||||
ToggleMorph, ToggleButtonMorph, BoxMorph, modules, radians,
|
ToggleMorph, ToggleButtonMorph, BoxMorph, modules, radians,
|
||||||
MorphicPreferences
|
MorphicPreferences, getDocumentPositionOf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.paint = '2013-May-16';
|
modules.paint = '2013-July-12';
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
|
|
||||||
|
@ -166,7 +167,9 @@ PaintEditorMorph.prototype.buildToolbox = function() {
|
||||||
circleSolid:
|
circleSolid:
|
||||||
"Filled Ellipse\n(shift: circle)",
|
"Filled Ellipse\n(shift: circle)",
|
||||||
paintbucket:
|
paintbucket:
|
||||||
"Fill a region"
|
"Fill a region",
|
||||||
|
pipette:
|
||||||
|
"Pipette tool\n(pick a color anywhere)"
|
||||||
},
|
},
|
||||||
myself = this,
|
myself = this,
|
||||||
left = this.toolbox.left(),
|
left = this.toolbox.left(),
|
||||||
|
@ -381,6 +384,9 @@ PaintEditorMorph.prototype.toolButton = function(icon, hint) {
|
||||||
myself.paper.currentTool = icon;
|
myself.paper.currentTool = icon;
|
||||||
myself.paper.toolChanged(icon);
|
myself.paper.toolChanged(icon);
|
||||||
myself.refreshToolButtons();
|
myself.refreshToolButtons();
|
||||||
|
if (icon === 'pipette') {
|
||||||
|
myself.getUserColor();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
new SymbolMorph(icon, 18),
|
new SymbolMorph(icon, 18),
|
||||||
function () {return myself.paper.currentTool === icon; }
|
function () {return myself.paper.currentTool === icon; }
|
||||||
|
@ -402,6 +408,38 @@ PaintEditorMorph.prototype.pushButton = function(title, action, hint) {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PaintEditorMorph.prototype.getUserColor = function () {
|
||||||
|
var myself = this,
|
||||||
|
world = this.world(),
|
||||||
|
hand = world.hand,
|
||||||
|
posInDocument = getDocumentPositionOf(world.worldCanvas),
|
||||||
|
mouseMoveBak = hand.processMouseMove,
|
||||||
|
mouseDownBak = hand.processMouseDown,
|
||||||
|
mouseUpBak = hand.processMouseUp;
|
||||||
|
|
||||||
|
hand.processMouseMove = function (event) {
|
||||||
|
var color;
|
||||||
|
hand.setPosition(new Point(
|
||||||
|
event.pageX - posInDocument.x,
|
||||||
|
event.pageY - posInDocument.y
|
||||||
|
));
|
||||||
|
color = world.getGlobalPixelColor(hand.position());
|
||||||
|
myself.propertiesControls.colorpicker.action(color);
|
||||||
|
myself.paper.settings.primarycolor = color;
|
||||||
|
};
|
||||||
|
|
||||||
|
hand.processMouseDown = nop;
|
||||||
|
|
||||||
|
hand.processMouseUp = function () {
|
||||||
|
myself.paper.currentTool = 'brush';
|
||||||
|
myself.paper.toolChanged('brush');
|
||||||
|
myself.refreshToolButtons();
|
||||||
|
hand.processMouseMove = mouseMoveBak;
|
||||||
|
hand.processMouseDown = mouseDownBak;
|
||||||
|
hand.processMouseUp = mouseUpBak;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
// AdvancedColorPickerMorph //////////////////
|
// AdvancedColorPickerMorph //////////////////
|
||||||
|
|
||||||
// A large hsl color picker
|
// A large hsl color picker
|
||||||
|
|
Ładowanie…
Reference in New Issue