在AthensTutorial中画布来自哪里?

时间:2013-04-16 10:27:31

标签: graphics smalltalk cairo pharo athens

我正在做雅典教程,我理解第一步

surface := AthensCairoSurface extent: self extent asIntegerPoint.

然后第2步是

surface drawDuring: [:canvas |

"First, we clear the surface"
surface clear. 

"we can use 

surface clear: Color black.  

as well. A #clear is equivalent to: (surface clear: Color transparent).   "

"Let''s draw a simple green rectangle"
canvas setPaint: Color green.
canvas setShape: (40@40 corner: 100@100).
canvas draw.

]

画布来自哪里?在哪里定义?我只是不明白那一部分。

1 个答案:

答案 0 :(得分:7)

这将是您在各种Smalltalk框架中看到的技巧。 '画布'是传递给#drawDuring:的块的参数。你可以按照你想要的方式命名,这完全取决于你。方法#drawDuring:将创建一个canvas实例,并通过调用BlockClosure>> value:方法将其传递给您的块。