[Pharo-dev] How to draw an ellipse with Athens?

Alexandre Bergel alexandre.bergel at me.com
Sun Nov 17 10:48:21 EST 2013


Hi!

In Roassal, I have the following to draw an ellipse:

-=-=-=-=-=-=-=-=-=-=
fillOval: aRectangle color: aColor borderWidth: aBorderWidth borderColor: aBorderColor

	|p rect stroke |
	
	rect := self virtualToRealRectangle: aRectangle.

	nativeCanvas pathTransform restoreAfter: [
		p:= nativeCanvas createPath: [:path | 
				|halfPi |
				halfPi := Float pi /2.
				path 
					absolute;
					moveTo: rect topCenter;
					cwArcTo: rect rightCenter angle: halfPi;
					cwArcTo: rect bottomCenter angle: halfPi;
					cwArcTo: rect leftCenter angle: halfPi;
					cwArcTo: rect topCenter angle: halfPi].
		nativeCanvas setShape: p.
		nativeCanvas setPaint: aColor.
		nativeCanvas draw.
		stroke := nativeCanvas setStrokePaint: aBorderColor.
		stroke width: aBorderWidth.
		nativeCanvas draw
		]
-=-=-=-=-=-=-=-=-=-=
I feel this is not quite right.

It produces something like:


With the following Roassal script:

-=-=-=-=-=-=-=-=-=-=
| view el |
view := ROView new.
el := ROElement on: 'hello world'.
el + ROLabel + ROEllipse.
el @ RODraggable.
view add: el.
view open
-=-=-=-=-=-=-=-=-=-=


It is has if the halfPi variable does not have the right value. 
I have found example on the web (e.g., https://developer.gnome.org/gtkmm-tutorial/3.2/sec-cairo-drawing-arcs.html.en)
However I was not able to map them in Athens.

Help appreciated. This is a bug in Roassal that has been there for too long :-)

Cheers,
Alexandre

-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20131117/7902215e/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2013-11-17 at 12.46.15 PM.png
Type: image/png
Size: 8349 bytes
Desc: not available
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20131117/7902215e/attachment.png>


More information about the Pharo-dev mailing list