'From Squeak5.3alpha of 6 September 2019 [latest update: #18873] on 9 September 2019 at 2:52:44 pm'!
BorderedMorph subclass: #PasteUpMorph
	instanceVariableNames: 'presenter model cursor padding backgroundMorph turtleTrailsForm turtlePen lastTurtlePositions isPartsBin indicateCursor wantsMouseOverHalos worldState griddingOn nonTranslucentFillStyle'
	classVariableNames: 'DisableDeferredUpdates GlobalCommandKeysEnabled MinCycleLapse StillAlive WindowEventHandler'
	poolDictionaries: ''
	category: 'Morphic-Worlds'!

!Color methodsFor: 'conversions' stamp: 'ct 9/9/2019 14:43'!
withoutTranslucency
	"for polymorphism with Form and FillStyle"

	^ self asNontranslucentColor! !


!FillStyle methodsFor: 'converting' stamp: 'ct 9/9/2019 14:43'!
withoutTranslucency

	^ self subclassResponsibility! !


!Form methodsFor: 'converting' stamp: 'ct 9/9/2019 14:44'!
withoutTranslucency

	^ self collectColors: #withoutTranslucency! !


!GradientFillStyle methodsFor: 'converting' stamp: 'ct 9/9/2019 14:45'!
mixed: fraction with: aColor

	^ self transformColors: [:color | color mixed: fraction with: aColor]! !

!GradientFillStyle methodsFor: 'converting' stamp: 'ct 9/9/2019 14:45'!
transformColors: aTransformator

	^ self copy
		colorRamp: (colorRamp collect: [:assoc|
			assoc key -> (aTransformator value: assoc value)]);
		yourself! !

!GradientFillStyle methodsFor: 'converting' stamp: 'ct 9/9/2019 14:44'!
withoutTranslucency

	^ self transformColors: #withoutTranslucency! !


!InfiniteForm methodsFor: 'converting' stamp: 'ct 9/9/2019 14:45'!
withoutTranslucency

	^ self class with: self form withoutTranslucency! !


!PasteUpMorph methodsFor: 'accessing' stamp: 'ct 9/9/2019 14:47'!
color: aColor

	super color: aColor.
	nonTranslucentFillStyle := nil.! !

!PasteUpMorph methodsFor: 'accessing' stamp: 'ct 9/9/2019 14:43'!
nonTranslucentFillStyle

	^ nonTranslucentFillStyle ifNil: [
		nonTranslucentFillStyle := self fillStyle withoutTranslucency].! !

!PasteUpMorph methodsFor: 'drawing' stamp: 'ct 9/9/2019 14:45'!
drawOn: aCanvas 
	"Draw in order:
	- background color
	- grid, if any
	- background sketch, if any
	- Update and draw the turtleTrails form. See the comment in updateTrailsForm.
	- cursor box if any

	Later (in drawSubmorphsOn:) I will skip drawing the background sketch."

	"draw background fill"
	self owner
		ifNotNil: [super drawOn: aCanvas]
		ifNil: [
			"We are a world morph"
			aCanvas frameAndFillRectangle: self bounds fillStyle: self nonTranslucentFillStyle borderStyle: self borderStyle].

	"draw grid"
	(self griddingOn and: [self gridVisible]) 
		ifTrue: 
			[aCanvas fillRectangle: self bounds
				fillStyle: (self 
						gridFormOrigin: self gridOrigin
						grid: self gridModulus
						background: nil
						line: Color lightGray)].

	"draw background sketch."
	backgroundMorph ifNotNil: [
		self clipSubmorphs ifTrue: [
			aCanvas clipBy: self clippingBounds
				during: [ :canvas | canvas fullDrawMorph: backgroundMorph ]]
			ifFalse: [ aCanvas fullDrawMorph: backgroundMorph ]].

	"draw turtle trails"
	(lastTurtlePositions isNil or: [lastTurtlePositions isEmpty]) ifFalse:[
		self updateTrailsForm.
	].
	turtleTrailsForm 
		ifNotNil: [aCanvas paintImage: turtleTrailsForm at: self position].

	"draw cursor"
	(submorphs notEmpty and: [self indicateCursor]) 
		ifTrue: 
			[aCanvas 
				frameRectangle: self selectedRect
				width: 2
				color: Color black]! !

!PasteUpMorph methodsFor: 'visual properties' stamp: 'ct 9/9/2019 14:49'!
fillStyle: aFormOrColorOrFillStyle

	super fillStyle: (aFormOrColorOrFillStyle isForm
		ifTrue: [InfiniteForm with: aFormOrColorOrFillStyle]
		ifFalse: [aFormOrColorOrFillStyle isColor
			ifTrue: [SolidFillStyle color: aFormOrColorOrFillStyle]
			ifFalse: [aFormOrColorOrFillStyle]]).
	nonTranslucentFillStyle := nil.! !


!SolidFillStyle methodsFor: 'converting' stamp: 'ct 9/9/2019 14:45'!
withoutTranslucency

	^ self class color: self color asNontranslucentColor! !

