[squeak-dev] [OT] Two hacks with EToys

Javier Díaz Reinoso javier_diaz_r at mac.com
Mon May 9 23:57:48 UTC 2011


I known the etoys is almost dead in squeak (and really dead in pharo), but sometimes I need some quick tools like this:

- Histogram window with cursor:

	|form1 world gm w window|
	form1 := Form fromUser asGrayScale.
	world := PasteUpMorph new. world extent: 300 at 100.
	gm := GraphMorph new.
	gm data: form1 tallyPixelValues.
	world addMorph: gm.
	gm assuredPlayer.
	w := WatcherWrapper new.
	w unlabeledForPlayer: (gm player) getter: #getCursor.
	"w fancyForPlayer: (gm player) getter: #getCursor."
	w position: 150 at 90.
	world addMorph: w.
	w := WatcherWrapper new.
	w unlabeledForPlayer: (gm player) getter: #getSampleAtCursor.
	w position: 150 at 125.
	world addMorph: w.

	window:= SystemWindow new. window setLabel: 'Histogram'.
	window addMorph: world  frame: (0 at 0 corner: 1 at 1).
	window openInWorld; bounds: (100 at 100 corner: 475 at 300).

that is creating etoy widget programatically.

- MagnifierMorph with info, like Pixie in Mac OS X:

1.- open viewer for a MagnifierMorph
2.- create variable xy as default Number
3.- create variables rgb and hsb as String, perhaps you need to put the Preference allowEtoyUserCustomEvents to true before you can change the type to String (code rust).
4.- create a textual script with:

pixie
	|col|
	self setXy: (self costume) sourcePoint.
	col := (Display colorAt: (self getXy)).
	self setRgb: (col red * 255) asInteger asString, ' ', (col green * 255) asInteger asString, ' ', (col blue * 255) asInteger asString.
	self setHsb: (col hue printShowingDecimalPlaces:0),' ', (col saturation * 255) asInteger asString, ' ', (col brightness *255)  asInteger asString.

5.- create 3 viewers for the variables and run the script:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: lupa.jpg
Type: image/jpg
Size: 20398 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20110509/c081a2b0/lupa.jpg
-------------- next part --------------

Note that Pixie don't show the Hue as 0-360 degrees instead show as a byte value, Pages show the radius correct but the saturation and brightness are show as percent instead of bytes.
There is some bugs, for example try to put the cursor in  the green arrows.


More information about the Squeak-dev mailing list