From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:49:40 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <class> <name>Walker</name> <environment>Smalltalk</environment> <super>Core.Object</super> <private>false</private> none <imports></imports> <category>UIApplications-New</category> <attributes> <package>Animation-Example</package> </attributes> </class> <comment> Walker
A simple example of double-buffering for animation.
</comment> <methods> Walker class <category>resources</category>
first ^OpaqueImage figure: self firstFigure shape: self firstShape
fourth ^OpaqueImage figure: self fourthFigure shape: self fourthShape
second ^OpaqueImage figure: self secondFigure shape: self secondShape
third ^OpaqueImage figure: self thirdFigure shape: self thirdShape
</methods> <methods> Walker class <category>examples</category>
runWalker " self runWalker" | window gc first firstRev second secondRev third thirdRev fourth fourthRev delay scratch scratchGC | "Set up a graphics context" window := (ApplicationWindow openNewIn: (Rectangle origin: 0@0 extent: 400@75)). gc := window graphicsContext. "Create the images" first := Walker first. firstRev := OpaqueImage figure: first figure asImage reflectedInX shape: first shape asImage reflectedInX. second := Walker second. secondRev := OpaqueImage figure: second figure asImage reflectedInX shape: second shape asImage reflectedInX. third := Walker third. thirdRev := OpaqueImage figure: third figure asImage reflectedInX shape: third shape asImage reflectedInX. fourth := Walker fourth. fourthRev := OpaqueImage figure: fourth figure asImage reflectedInX shape: fourth shape asImage reflectedInX. "Set the timing for speed" delay := Delay forMilliseconds: 100. "Create an off-screen surface" scratch := (Pixmap extent: gc medium extent) . scratchGC := scratch graphicsContext. "Run animation, two walkers, in a single thread" [0 to: 30 do: [ :x | scratchGC clear. first displayOn: scratchGC at: x*12 @ 54. firstRev displayOn: scratchGC at: 400-(firstRev extent x)-(x*12) @ 54. delay wait. scratch displayOn: gc. scratchGC clear. second displayOn: scratchGC at: x*12+2 @ 54. secondRev displayOn: scratchGC at: 400-(firstRev extent x)-(x*12+2) @ 54. delay wait. scratch displayOn: gc. scratchGC clear. third displayOn: scratchGC at: x*12+4 @ 54. thirdRev displayOn: scratchGC at: 400-(firstRev extent x)-(x*12+4) @ 54. delay wait. scratch displayOn: gc. scratchGC clear. fourth displayOn: scratchGC at: x*12+6 @ 54. fourthRev displayOn: scratchGC at: 400-(firstRev extent x)-(x*12+6) @ 54. delay wait. scratch displayOn: gc. scratchGC clear. third displayOn: scratchGC at: x*12+8 @ 54. thirdRev displayOn: scratchGC at: 400-(firstRev extent x)-(x*12+8) @ 54. delay wait. scratch displayOn: gc. scratchGC clear. second displayOn: scratchGC at: x*12+10 @ 54. secondRev displayOn: scratchGC at: 400-(firstRev extent x)-(x*12+10) @ 54. delay wait. scratch displayOn: gc ]] fork.
</methods> <methods> Walker class <category>resources</category>
firstFigure "Tools.UIMaskEditor new openOnClass: self andSelector: #first" <resource: #image> ^CachedImage on: (Image extent: 28@21 depth: 2 bitsPerPixel: 2 palette: (Graphics.MappedPalette withColors: (#(#(#{Graphics.ColorValue} #scaledRed:scaledGreen:scaledBlue: #(0 0 0)) #(#{Graphics.ColorValue} #scaledRed:scaledGreen:scaledBlue: #(4096 0 0)) #(#{Graphics.ColorValue} #scaledRed:scaledGreen:scaledBlue: #(8191 8191 8191)) ) collect: [:each | (each at: 1) value perform: (each at: 2) withArguments: (each at: 3)])) usingBits: #[170 170 170 170 170 170 170 0 170 170 170 170 170 166 170 0 150 170 170 170 170 166 170 0 166 170 170 170 170 149 106 0 166 170 170 170 169 85 26 0 165 170 170 170 165 85 86 0 169 106 170 170 149 85 90 0 170 85 85 85 85 85 170 0 170 165 85 85 85 86 170 0 170 165 85 85 85 90 170 0 170 149 85 85 85 90 170 0 170 85 85 85 85 106 170 0 170 85 85 85 85 42 170 0 169 84 10 170 148 106 170 0 169 81 90 170 89 106 170 0 165 101 106 170 90 90 170 0 165 105 106 169 106 90 170 0 165 170 106 169 106 154 170 0 166 170 90 169 170 150 170 0 165 170 150 169 106 165 170 0 170 170 170 170 170 170 170 0])
firstShape "Tools.UIMaskEditor new openOnClass: self andSelector: #firstMask" <resource: #image> ^CachedImage on: (Image extent: 28@21 depth: 1 bitsPerPixel: 1 palette: CoveragePalette monoMaskPalette usingBits: #[0 0 0 0 0 0 2 0 96 0 2 0 32 0 7 128 32 0 31 192 48 0 63 224 24 0 127 192 15 255 255 0 3 255 254 0 3 255 252 0 7 255 252 0 15 255 248 0 15 255 248 0 31 192 120 0 31 192 216 0 59 128 204 0 57 129 140 0 48 129 132 0 32 193 6 0 48 97 131 0 0 0 0 0])
fourthFigure "Tools.UIMaskEditor new openOnClass: self andSelector: #fourth" <resource: #image> ^CachedImage on: (Image extent: 28@21 depth: 2 bitsPerPixel: 2 palette: (Graphics.MappedPalette withColors: (#(#(#{Graphics.ColorValue} #scaledRed:scaledGreen:scaledBlue: #(0 0 0)) #(#{Graphics.ColorValue} #scaledRed:scaledGreen:scaledBlue: #(4096 0 0)) #(#{Graphics.ColorValue} #scaledRed:scaledGreen:scaledBlue: #(8191 8191 8191)) ) collect: [:each | (each at: 1) value perform: (each at: 2) withArguments: (each at: 3)])) usingBits: #[170 170 170 170 170 170 170 0 170 170 170 170 170 166 170 0 150 170 170 170 170 166 170 0 166 170 170 170 170 149 106 0 166 170 170 170 169 85 26 0 165 170 170 170 165 85 86 0 169 106 170 170 149 85 90 0 170 85 85 85 85 85 170 0 170 165 85 85 85 86 170 0 170 165 85 85 85 90 170 0 170 149 85 85 85 90 170 0 170 149 85 85 85 106 170 0 170 149 85 85 85 106 170 0 170 149 170 170 149 106 170 0 170 21 170 170 148 170 170 0 170 69 170 170 148 170 170 0 170 101 170 170 145 106 170 0 169 102 170 170 89 106 170 0 169 165 170 170 106 106 170 0 170 169 106 170 170 90 170 0 170 170 170 170 170 170 170 0])
fourthShape "Tools.UIMaskEditor new openOnClass: self andSelector: #fourthMask" <resource: #image> ^(Image extent: 28@21 depth: 1 bitsPerPixel: 1 palette: CoveragePalette monoMaskPalette usingBits: #[0 0 0 0 0 0 2 0 96 0 2 0 32 0 7 128 32 0 31 192 48 0 63 224 24 0 127 192 15 255 255 0 3 255 254 0 3 255 252 0 7 255 252 0 7 255 248 0 7 255 248 0 7 0 120 0 15 0 112 0 15 0 112 0 11 0 120 0 26 0 216 0 19 0 136 0 1 128 12 0 0 0 0 0])
secondFigure "Tools.UIMaskEditor new openOnClass: self andSelector: #second" <resource: #image> ^CachedImage on: (Image extent: 28@21 depth: 2 bitsPerPixel: 2 palette: (Graphics.MappedPalette withColors: (#(#(#{Graphics.ColorValue} #scaledRed:scaledGreen:scaledBlue: #(0 0 0)) #(#{Graphics.ColorValue} #scaledRed:scaledGreen:scaledBlue: #(4096 0 0)) #(#{Graphics.ColorValue} #scaledRed:scaledGreen:scaledBlue: #(8191 8191 8191)) ) collect: [:each | (each at: 1) value perform: (each at: 2) withArguments: (each at: 3)])) usingBits: #[170 170 170 170 170 170 170 0 170 170 170 170 170 166 170 0 150 170 170 170 170 166 170 0 166 170 170 170 170 149 106 0 166 170 170 170 169 85 26 0 165 170 170 170 165 85 86 0 169 106 170 170 149 85 90 0 170 85 85 85 85 85 170 0 170 165 85 85 85 86 170 0 170 165 85 85 85 90 170 0 170 149 85 85 85 90 170 0 170 149 85 85 85 106 170 0 170 149 85 85 85 106 170 0 170 149 170 170 148 106 170 0 170 85 170 170 144 170 170 0 170 84 170 170 145 170 170 0 170 97 170 170 145 106 170 0 169 102 170 170 89 106 170 0 169 165 170 170 106 106 170 0 170 169 106 170 170 90 170 0 170 170 170 170 170 170 170 0])
secondShape "Tools.UIMaskEditor new openOnClass: self andSelector: #secondMask" <resource: #image> ^(Image extent: 28@21 depth: 1 bitsPerPixel: 1 palette: CoveragePalette monoMaskPalette usingBits: #[0 0 0 0 0 0 2 0 96 0 2 0 32 0 7 128 32 0 31 192 48 0 63 224 24 0 127 192 15 255 255 0 3 255 254 0 3 255 252 0 7 255 252 0 7 255 248 0 7 255 248 0 7 0 120 0 15 0 112 0 15 0 112 0 11 0 120 0 26 0 216 0 19 0 136 0 1 128 12 0 0 0 0 0])
thirdFigure "Tools.UIMaskEditor new openOnClass: self andSelector: #third" <resource: #image> ^CachedImage on: (Image extent: 28@21 depth: 2 bitsPerPixel: 2 palette: (Graphics.MappedPalette withColors: (#(#(#{Graphics.ColorValue} #scaledRed:scaledGreen:scaledBlue: #(0 0 0)) #(#{Graphics.ColorValue} #scaledRed:scaledGreen:scaledBlue: #(4096 0 0)) #(#{Graphics.ColorValue} #scaledRed:scaledGreen:scaledBlue: #(8191 8191 8191)) ) collect: [:each | (each at: 1) value perform: (each at: 2) withArguments: (each at: 3)])) usingBits: #[170 170 170 170 170 170 170 0 170 170 170 170 170 166 170 0 150 170 170 170 170 166 170 0 166 170 170 170 170 149 106 0 166 170 170 170 169 85 26 0 165 170 170 170 165 85 86 0 169 106 170 170 149 85 90 0 170 85 85 85 85 85 170 0 170 165 85 85 85 86 170 0 170 165 85 85 85 90 170 0 170 145 85 85 85 90 170 0 170 65 85 85 85 106 170 0 170 69 85 85 85 106 170 0 169 69 90 170 129 106 170 0 169 69 90 170 89 106 170 0 165 101 106 170 90 90 170 0 165 105 106 169 106 90 170 0 165 170 106 169 106 154 170 0 166 170 90 169 170 150 170 0 165 170 150 169 106 165 170 0 170 170 170 170 170 170 170 0])
thirdShape "Tools.UIMaskEditor new openOnClass: self andSelector: #thirdMask" <resource: #image> ^CachedImage on: (Image extent: 28@21 depth: 1 bitsPerPixel: 1 palette: CoveragePalette monoMaskPalette usingBits: #[0 0 0 0 0 0 2 0 96 0 2 0 32 0 7 128 32 0 31 192 48 0 63 224 24 0 127 192 15 255 255 0 3 255 254 0 3 255 252 0 7 255 252 0 15 255 248 0 15 255 248 0 31 192 120 0 31 192 216 0 59 128 204 0 57 129 140 0 48 129 132 0 32 193 6 0 48 97 131 0 0 0 0 0])
</methods> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>Object</name> <environment>Core</environment> <super></super> <private>false</private> none <imports></imports> <category>Kernel-Objects</category> <attributes> <package>Kernel-Objects</package> </attributes> </class>