[squeak-dev] The Inbox: Morphic-kfr.2022.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Jul 31 20:30:49 UTC 2022


A new version of Morphic was added to project The Inbox:
http://source.squeak.org/inbox/Morphic-kfr.2022.mcz

==================== Summary ====================

Name: Morphic-kfr.2022
Author: kfr
Time: 31 July 2022, 10:30:40.822224 pm
UUID: 61c16925-b73b-9c47-9487-6a6dedfa1624
Ancestors: Morphic-eem.2021

Add possibility to process images in an AnimatedImageMorph. Makes it possible to resize gif etc:  'self process:[:each| each scaledToSize: 100 at 75]'

=============== Diff against Morphic-eem.2021 ===============

Item was added:
+ ----- Method: AnimatedImageMorph>>process: (in category 'processing') -----
+ process: aBlock 
+ 	"self process:[:each| each scaledToSize: 100 at 75]"
+ 	| result |
+ 	result := self copy renderImages.
+ 	'Processing image:' translated
+ 		displayProgressFrom: 0
+ 		to: result images size
+ 		during: [:bar | result images
+ 				withIndexDo: [:each :i | 
+ 					bar value: i.
+ 					bar value: 'Processing image:' translated , i printString , ' of:' translated, result images size printString.
+ 					result images
+ 						at: i
+ 						put: (aBlock value: each)]].
+ 	result image: result images first.
+ 	^ result openInHand!

Item was added:
+ ----- Method: AnimatedImageMorph>>renderImages (in category 'processing') -----
+ renderImages
+ 	| disposal canvas current |
+ 	"render all frames to be full images before processing"
+ 	
+ 	(1 to: images size) do:[ :imageIndex|
+ 	current := images at: imageIndex.
+ 
+ 	"If this is the first image in the sequence, we don't
+ 	have a previous disposal to look at. So just paint
+ 	the image -- equiv to #leaveCurrent"
+ 	canvas := image getCanvas.
+ 	(imageIndex == 1)
+ 		ifTrue: [
+ 			image getCanvas drawImage: current at: current offset ]
+ 		ifFalse: [
+ 			"Otherwise, we need to look at the previous image's disposal method
+ 			to see if we should restore the background"
+ 			disposal := disposals at: imageIndex - 1.
+ 			(disposal == #restoreBackground)
+ 				ifTrue: [
+ 					"canvas 
+ 						fillRectangle: self bounds
+ 						color: self color"
+ 					canvas := (Form extent: canvas extent depth: 32) getCanvas.
+ 					canvas fillRectangle: ((current offset) corner: (current offset + current extent)) color: self color.
+ 					canvas drawImage: current at: current offset ]
+ 				ifFalse: [ canvas paintImage: current at: current offset ]
+ 			 ].
+ 	images at: imageIndex put: canvas form copy]!



More information about the Squeak-dev mailing list