[ENH]Enhancement to PaintBoxMorph
Karl Ramberg
karl.ramberg at chello.se
Mon Apr 24 13:20:54 UTC 2000
Well, I don't really know if this is a enhancement but it makes the
PaintBoxMorph cursors a little more consistent ( A paint brush cursor
and a eyedropper cursor) These cursors are already in the PaintBoxMorph
but not used or shut off ? Check it out. Enjoy some pixel painting and
see if you like it. Any feedback is welcome.
I really have to thank Bob Arning who did all the stuff I was not
capable of.
Karl
-------------- next part --------------
'From Squeak2.8alpha of 19 February 2000 [latest update: #2005] on 24 April 2000 at 3:04:25 pm'!
!PaintBoxMorph methodsFor: 'actions' stamp: 'kfr 4/24/2000 15:04'!
actionCursor
"Return the cursor to use with this painting action/tool. Offset of the form must be set."
| ff width co larger box |
action == #paint: ifTrue: ["Make a cursor from the brush and the color"
width _ self getNib width.
co _ (currentCursor offset - ((width negated )@34)) min: (0 at 0).
larger _ width negated + 10 at 0 extent: currentCursor extent + (width-10 at width).
ff _ currentCursor copy: larger.
ff colors at: 1 put: Color transparent.
ff colors at: 2 put: Color transparent.
ff fill: (box _ co negated extent: (width at width))
fillColor: (Color r: 0.5 g: 0.5 b: 1.0).
ff fill: (box insetBy: 1 at 1) fillColor: Color transparent.
ff offset: co - (width at width //2).
^ ff].
action == #erase: ifTrue: ["Make a cursor from the cursor and the color"
width _ self getNib width.
co _ (currentCursor offset + (width//2 at 4)) min: (0 at 0).
larger _ 0 at 0 extent: currentCursor extent + (width at width).
ff _ currentCursor copy: larger.
ff fill: (box _ co negated extent: (width at width))
fillColor: (Color r: 0.5 g: 0.5 b: 1.0).
ff fill: (box insetBy: 1 at 1) fillColor: Color transparent.
ff offset: co - (width at width //2).
^ ff].
^ currentCursor
! !
-------------- next part --------------
'From Squeak2.8alpha of 19 February 2000 [latest update: #2005] on 24 April 2000 at 3:05:57 pm'!
!PaintBoxMorph methodsFor: 'actions' stamp: 'kfr 4/24/2000 15:05'!
eyedropper: aButton action: aSelector cursor: aCursor
"Take total control and pick up a color!!!!"
| pt feedbackColor |
aButton state: #on.
tool ifNotNil: [tool state: #off].
currentCursor _ aCursor.
self activeHand
showTemporaryCursor: currentCursor
hotSpotOffset: 6 negated @ 4 negated. "<<<< the form was changed a bit??"
feedbackColor _ Display colorAt: Sensor cursorPoint.
self addMorphFront: colorMemory.
"Full color picker"
[Sensor anyButtonPressed]
whileFalse:
[pt _ Sensor cursorPoint.
"deal with the fact that 32 bit displays may have garbage in the alpha bits"
feedbackColor _ Display depth = 32 ifTrue: [
Color colorFromPixelValue: ((Display pixelValueAt: pt)
bitOr: 16rFF000000) depth: 32
] ifFalse: [
Display colorAt: pt
].
"the hand needs to be drawn"
self activeHand position: pt.
self world displayWorldSafely.
Display fill: colorPatch bounds fillColor: feedbackColor].
Sensor waitButton.
self activeHand showTemporaryCursor: nil hotSpotOffset: 0 @ 0.
self currentColor: feedbackColor.
colorMemory delete.
tool
ifNotNil:
[tool state: #on.
currentCursor _ tool arguments at: 3].
aButton state: #off! !
More information about the Squeak-dev
mailing list
|