2018-10-22 17:05:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Hue slot morph
|
|
|
|
|
|
|
|
var HueSlotMorph;
|
|
|
|
|
|
|
|
HueSlotMorph.prototype = new ColorSlotMorph();
|
|
|
|
HueSlotMorph.prototype.constructor = HueSlotMorph;
|
|
|
|
HueSlotMorph.uber = ColorSlotMorph.prototype;
|
|
|
|
|
|
|
|
function HueSlotMorph(clr) {
|
|
|
|
this.init(clr);
|
2017-01-13 14:33:53 +00:00
|
|
|
}
|
2018-10-22 17:05:13 +00:00
|
|
|
|
|
|
|
HueSlotMorph.prototype.init = function (clr) {
|
|
|
|
HueSlotMorph.uber.init.call(this, null, true); // silently
|
|
|
|
this.setColor(clr || new Color(127.5, 0, 0));
|
|
|
|
};
|
|
|
|
|
|
|
|
HueSlotMorph.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,
|
|
|
|
pal = new HueWheelMorph(null, new Point(
|
|
|
|
this.fontSize * 12,
|
|
|
|
this.fontSize * 12
|
|
|
|
));
|
|
|
|
world.add(pal);
|
|
|
|
pal.setPosition(this.bottomLeft().add(new Point(0, this.edge)));
|
|
|
|
pal.addShadow(new Point(2, 2), 80);
|
|
|
|
|
|
|
|
hand.processMouseMove = function (event) {
|
|
|
|
hand.setPosition(new Point(
|
|
|
|
event.pageX - posInDocument.x,
|
|
|
|
event.pageY - posInDocument.y
|
|
|
|
));
|
|
|
|
myself.setColor(world.getGlobalPixelColor(hand.position()));
|
|
|
|
};
|
|
|
|
|
|
|
|
hand.processMouseDown = nop;
|
|
|
|
|
|
|
|
hand.processMouseUp = function () {
|
|
|
|
pal.destroy();
|
|
|
|
hand.processMouseMove = mouseMoveBak;
|
|
|
|
hand.processMouseDown = mouseDownBak;
|
|
|
|
hand.processMouseUp = mouseUpBak;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// labelPart() proxy
|
|
|
|
SyntaxElementMorph.prototype.originalLabelPart = SyntaxElementMorph.prototype.labelPart;
|
|
|
|
SyntaxElementMorph.prototype.labelPart = function (spec) {
|
|
|
|
var part;
|
|
|
|
switch (spec) {
|
2018-10-23 12:41:02 +00:00
|
|
|
case '%hsb':
|
|
|
|
part = new InputSlotMorph(
|
|
|
|
null,
|
|
|
|
false,
|
|
|
|
{
|
|
|
|
'hue' : ['hue'],
|
|
|
|
'saturation' : ['saturation'],
|
|
|
|
'brightness' : ['brightness'],
|
|
|
|
},
|
|
|
|
true
|
|
|
|
);
|
|
|
|
break;
|
2018-10-22 17:05:13 +00:00
|
|
|
case '%huewheel':
|
|
|
|
part = new HueSlotMorph();
|
|
|
|
part.isStatic = true;
|
2021-07-08 09:39:09 +00:00
|
|
|
break;
|
2018-10-22 17:05:13 +00:00
|
|
|
default:
|
|
|
|
part = this.originalLabelPart(spec);
|
2018-11-01 10:47:13 +00:00
|
|
|
break;
|
2018-10-22 17:05:13 +00:00
|
|
|
}
|
|
|
|
return part;
|
|
|
|
};
|