Skip to content

Commit

Permalink
added simple cache for the image, added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lwenner committed Jun 5, 2021
1 parent ca8e99c commit 2be690e
Show file tree
Hide file tree
Showing 20 changed files with 106 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
codeGeneration
createAnimationFor: aMorph withDuration: aNumber
self targetDuration: aNumber.
self updateTargetImage.
^ AnimCompositeAnimation new
add: (AnimAlphaBlendAnimation new
morph: aMorph;
startValue: 1.0;
endValue: 0.0;
duration: (aNumber//2);
finishBlock: [aMorph image: (Form fromFileNamed: self targetSource)]);
finishBlock: [aMorph image: self targetImage]);
add: (AnimAlphaBlendAnimation new
morph: aMorph;
startValue: 0.0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
loadedSource: aFilename

loadedSource := aFilename.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
accessing
loadedSource
loadedSource
ifNil: [self loadedSource: self defaultTargetSource].

^ loadedSource.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
targetImage: aForm

targetImage := aForm.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
targetImage

^ targetImage.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
targetSource: anSource
targetSource: aFilename

targetSource := anSource.
targetSource := aFilename.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ accessing
targetSource
targetSource
ifNil: [self targetSource: self defaultTargetSource].

^ targetSource.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
codeGeneration
updateTargetImage

self targetSource == self loadedSource
ifFalse: [self targetImage: (Form fromFileNamed: self targetSource)].
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@
"canCreateAnimation" : "LW 6/5/2021 15:10",
"canRenderUI" : "LW 6/5/2021 15:10",
"createAnimationFor:" : "LW 6/5/2021 15:10",
"createAnimationFor:withDuration:" : "LW 6/5/2021 15:10",
"createAnimationFor:withDuration:" : "LW 6/5/2021 15:59",
"defaultTargetSource" : "LW 6/5/2021 15:10",
"initialize" : "LW 6/5/2021 15:10",
"loadedSource" : "LW 6/5/2021 16:00",
"loadedSource:" : "LW 6/5/2021 15:54",
"resetTargetMorph" : "LW 6/5/2021 15:10",
"targetSource" : "LW 6/5/2021 15:11",
"targetSource:" : "LW 6/5/2021 15:11" } }
"targetImage" : "LW 6/5/2021 15:50",
"targetImage:" : "LW 6/5/2021 15:50",
"targetSource" : "LW 6/5/2021 15:47",
"targetSource:" : "LW 6/5/2021 15:51",
"updateTargetImage" : "LW 6/5/2021 15:55" } }
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
],
"commentStamp" : "LW 6/5/2021 15:08",
"instvars" : [
"targetSource" ],
"targetSource",
"targetImage",
"loadedSource" ],
"name" : "AnimationsEditorPropertyImageSource",
"pools" : [
],
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
as yet unclassified
dummyImage
^ Form
extent: 4 @ 4
depth: 32
fromArray: #(4278190080 4278190080 4278190080 4278190080 4278190080 4278190080 4278190080 4278190080 4278190080 4278190080 4278190080 4278190080 4278190080 4278190080 4278190080 4278190080)
offset: 0 @ 0.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
propertyImageSource: anObject

propertyImageSource := anObject.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
propertyImageSource

^ propertyImageSource.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
as yet unclassified
setUp
super setUp.
self propertyImageSource: AnimationsEditorPropertyImageSource new.
self propertyImageSource targetDuration: 0.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
as yet unclassified
testCreateAnimationFor
| imageMorph animation |
imageMorph := ImageMorph new openInWorld.
animation := self propertyImageSource createAnimationFor: imageMorph.
self assert: (animation isKindOf: AnimAnimation).
imageMorph abandon.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
as yet unclassified
testInstanceCreation
self assert: (self propertyImageSource = nil) not.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
as yet unclassified
testPropertyAfterAnimation
| imageMorph animation |
imageMorph := ImageMorph new openInWorld.
self propertyImageSource targetImage: self dummyImage.
animation := self propertyImageSource createAnimationFor: imageMorph.
animation register;
start.

(Delay forSeconds: 1) wait.
self assert: (imageMorph image asString = self dummyImage asString).
imageMorph abandon.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"class" : {
},
"instance" : {
"dummyImage" : "LW 6/5/2021 15:35",
"propertyImageSource" : "LW 6/5/2021 15:37",
"propertyImageSource:" : "LW 6/5/2021 15:34",
"setUp" : "LW 6/5/2021 15:41",
"testCreateAnimationFor" : "LW 6/5/2021 15:57",
"testInstanceCreation" : "LW 6/5/2021 15:35",
"testPropertyAfterAnimation" : "LW 6/5/2021 16:35" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "AnimationsEditor-Tests",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"propertyImageSource" ],
"name" : "AnimationsEditorPropertyImageSourceTest",
"pools" : [
],
"super" : "TestCase",
"type" : "normal" }

0 comments on commit 2be690e

Please sign in to comment.