[Pharo-dev] [bloc] shape size?

stepharo stepharo at free.fr
Sat Apr 2 17:38:19 EDT 2016


> How to make square element with filled circle inside:
>
> 1) Subclass BlElement -> BlCell
> 2) Override
>
>     drawOnSpartaCanvas: aCanvas
>     super drawOnSpartaCanvas: aCanvas.
>     aCanvas
>     setShape: self localBounds;
>     setStrokePaint: Color blue;
>     stroke
>
> 3) Override initialize to have circle shape:
>
>     initialize
>     super initialize.
>     self shapeDo: [ :aShape | aShape
>     path: BlCirclePath new;
>     fillPaint: Color red ].
>
> 4) Open cell in word
>
> Easy :)

Except that I do not understand it.
I do not understand why I should do
setShape: self localBounds;

and why I should do shapeDo: in the initialize

This is totally unclear to me. So this means that I cannot program 
anything I want
with it. Imagine I could not find anything simpler than a box with a 
circle drawn on it
and even with the solution I cannot understand it.

You see in Morphic this is simple: you have a drawOn: aCanvas method and 
you know how to draw: aCanvas
I do not get the interaction between the draw and the initialize.
This is totally unclear.

Now I tried and this code did not work in the build 26 so I tried with 
drawOnAthensCanvas: and it crashed.
So I stop.
No need to reply to this email and thread.


Stef


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20160402/48edd07b/attachment.html>


More information about the Pharo-dev mailing list