[Pharo-dev] [bloc] shape size?

Tudor Girba tudor at tudorgirba.com
Sat Apr 2 18:44:00 EDT 2016


Hi Stef,

I think the example that Alex provided is less advisable and it is misleading :). It’s indeed interesting that you can do what he shows, but I do not think this is the example that people should see first.

I got my hands on an image. Here is an example that is composing two elements:

element := BlElement new
	layoutStrategy: BlBasicLayoutStrategy new;
	shape: (BlShape new 
				path: BlRectanglePath new;
				strokePaint: (BlStrokePaint new
			paint: Color blue;
			width: 4));
	extent: 500 at 500;
	position: 0 at 0;
	addChild: (BlElement new
		shape: (BlShape new 
			path: BlCirclePath new; 
			fillPaint: Color red);
		extent: 450 at 450;
		position: 25 at 25).
element openInWorld.

Is this what you had in mind?

Cheers,
Doru


> On Apr 2, 2016, at 11:38 PM, stepharo <stepharo at free.fr> wrote:
> 
> 
>> 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
> 
> 

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

"We can create beautiful models in a vacuum.
But, to get them effective we have to deal with the inconvenience of reality."




More information about the Pharo-dev mailing list