Hi,

Good question.

The reason we want to have the morph be responsible because subclasses might 
decide to draw in a different way regardless of the shape being used. This 
gives us the maximum freedom for more specific blocs. Still, this is something 
to experiment with once we have more complicated examples built with Bloc.

Cheers,
Doru


> On Feb 25, 2016, at 9:56 AM, stepharo <[email protected]> wrote:
> 
> Hi Blockers
> 
> I do not really understand why drawOnAthensCanvas: is not defined on BlShape
> (especially when we see how many self space are defined in this method.
> And this is one of the few things I thought I understood from bloc (grouping 
> the rendering in a separate object).
> 
> 
> drawOnAthensCanvas: aCanvas
>    "Actually render receiver on aCanvas in local bounds.
>    Override to customize.
>    aCanvas is an instance of AthensCanvas
>    aCanvas must not be nil"
> 
>    | pathTransform |
>    pathTransform := aCanvas pathTransform.
>    "First we fill"
>    pathTransform
>        restoreAfter:
>            [ | path fillExtent fillTranslation |
>            "We fill inside natural element's bounds"
>            fillExtent := self shape path fillExtentFor: self shape inBounds: 
> self localBounds.
>            path := self shape path pathOn: aCanvas forExtent: fillExtent.
>            "Translate fill if needed"
>            fillTranslation := self shape path
>                fillTranslationFor: self shape
>                inBounds: self localBounds.
>            pathTransform translateBy: fillTranslation.
>            aCanvas
>                setPaint: self shape fillPaint;
>                drawShape: path ].
>    pathTransform
>        restoreAfter:
>            [ | path strokeExtent strokeTranslation |
>            "We stroke inside natural element's bounds"
>            strokeExtent := self shape path strokeExtentFor: self shape 
> inBounds: self localBounds.
>            path := self shape path pathOn: aCanvas forExtent: strokeExtent.
>            "Translate stroke if needed"
>            strokeTranslation := self shape path
>                strokeTranslationFor: self shape
>                inBounds: self localBounds.
>            pathTransform translateBy: strokeTranslation.
>            aCanvas
>                setPaint: self shape strokePaint;
>                drawShape: path ]
> 

--
www.tudorgirba.com
www.feenk.com

"Sometimes the best solution is not the best solution."


Reply via email to