'From Squeak3.1alpha of 28 February 2001 [latest update: #4088] on 27 May 2001 at 4:52:32 pm'! "Change Set: BetterPoohPaint-ar Date: 27 May 2001 Author: Andreas Raab Makes Pooh painting use antialiased strokes (hey, we got 32bpp so why not use it :-)"! WonderlandMorph subclass: #WonderlandCameraMorph instanceVariableNames: 'myCamera myControls eventFocus lastCursorPoint mouseUpButton firstPersonControls mode outline currentActor currentPosition currentCanvas currentColor currentNib lastPosition paintMode palette restore backup pickedPoint pickedActor myRenderer ' classVariableNames: 'CachedNibs ' poolDictionaries: 'WonderlandConstants ' category: 'Balloon3D-Wonderland Morphs'! !Form methodsFor: 'testing' stamp: 'ar 5/27/2001 16:34'! isColorForm ^false! ! !ColorForm methodsFor: 'testing' stamp: 'ar 5/27/2001 16:34'! isColorForm ^true! ! !TranslucentColor methodsFor: 'conversions' stamp: 'ar 5/27/2001 16:30'! pixelValueForDepth: d "Return the pixel value for this color at the given depth. Translucency only works in RGB; this color will appear either opaque or transparent at all other depths." | basicPixelWord | alpha = 0 ifTrue: [^ 0]. basicPixelWord _ super pixelValueForDepth: d. d < 32 ifTrue: [^ basicPixelWord] ifFalse: [^ (basicPixelWord bitAnd: 16rFFFFFF) bitOr: (alpha bitShift: 24)]. ! ! !WonderlandCameraMorph methodsFor: 'event handling' stamp: 'ar 5/27/2001 16:36'! mouseMovePaint: evt | newEvent | newEvent _ self convertEvent: evt. newEvent ifNil:[^self]. newEvent getVertex ifNil:[^self]. ^self perform: palette action with: newEvent! ! !WonderlandCameraMorph methodsFor: 'event handling' stamp: 'ar 5/27/2001 16:36'! mouseUpPaint: evt | newEvent | newEvent _ self convertEvent: evt. newEvent ifNil: [^ self]. newEvent getVertex ifNil:[^self]. ^ self perform: palette action with: newEvent! ! !WonderlandCameraMorph methodsFor: 'pooh-actions' stamp: 'ar 5/27/2001 16:42'! paint: newEvent | bb newPosition | newPosition _ newEvent getVertex texCoords * currentCanvas extent - (currentNib extent // 2). bb _ BitBlt toForm: currentCanvas form. bb sourceForm: currentNib; sourceRect: currentNib boundingBox; colorMap: (currentNib colormapIfNeededFor: bb destForm); combinationRule: Form blend; drawFrom: currentPosition asIntegerPoint to: newPosition asIntegerPoint. currentPosition _ newPosition.! ! !WonderlandCameraMorph methodsFor: 'pooh-actions' stamp: 'ar 5/27/2001 16:35'! prepareAction: newEvent | range palNib | currentColor _ palette getColor. palNib _ palette getNib. (currentNib notNil and:[currentNib extent = palNib extent and:[currentNib isColorForm and:[currentNib depth = 8 and:[currentNib colors last = currentColor]]]]) ifFalse:[ currentNib _ self roundNibOfSize: (palette getNib extent). currentNib colors:((0 to: 255) collect:[:i| currentColor alpha: i / 255.0])]. currentActor _ newEvent getActor. currentCanvas _ (currentActor getTexturePointer getCanvas). range _ currentCanvas extent. currentPosition _ newEvent getVertex texCoords * range - (currentNib extent // 2).! ! !WonderlandCameraMorph methodsFor: 'pooh-actions' stamp: 'ar 5/27/2001 16:32'! roundNibOfSize: extent "Create a round nib for antialiased painting" | largeForm smallForm warp colorForm | CachedNibs ifNil:[CachedNibs _ Dictionary new]. colorForm _ CachedNibs at: extent ifAbsent:[nil]. colorForm ifNotNil:[^colorForm]. largeForm _ Form extent: extent * 4 depth: 32. largeForm getCanvas fillOval: largeForm boundingBox color: Color white. smallForm _ Form extent: extent depth: 32. warp _ WarpBlt toForm: smallForm. warp sourceForm: largeForm destRect: smallForm boundingBox. warp cellSize: 4. "oh yes" warp warpBits. largeForm _ nil. colorForm _ smallForm asGrayScale. CachedNibs at: extent put: colorForm. ^colorForm! !