On 14 April 2014 13:53, Juraj Kubelka <juraj.kube...@gmail.com> wrote:

>
> El 14-04-2014, a las 8:21, Juraj Kubelka <juraj.kube...@gmail.com>
> escribió:
>
> Thank you Stef,
>
> the example helped me a lot to understand how to play with Athens.
>
> The solution is not what I am looking for. If someone starts to play with
> alpha canal, s/he will get unexpected results.
>
> I have finally found an example in C language. It look like this:
> -=-=-=-=-
> cairo_set_line_width (cr, 0.1);
> cairo_save (cr);
> cairo_scale (cr, 1, 0.2);
> cairo_arc (cr, 1.5, 1.5, 1, 0, 2 * M_PI);
> cairo_restore (cr);
>         cairo_set_source_rgba (cr, 0, 1, 0, 0.50);
> cairo_stroke (cr);
> -=-=-=-=-
> <tips-ellipse.png>
>
> I do not know how to write the same instructions with Athens.
>
> First, they draw one arc (cairo_arc (cr, 1.5, 1.5, 1, 0, 2 * M_PI);), I
> draw 4 arcs:
> -=-=-=-=-
> canvas
> createPath: [ :builder |
> builder
> absolute;
> moveTo: 0 @ 0.5;
> ccwArcTo: 0.5 @ 0.0 angle: 90 degreesToRadians;
> ccwArcTo: 0.0 @ -0.5 angle: 90 degreesToRadians;
> ccwArcTo: -0.5 @ 0.0 angle: 90 degreesToRadians;
> ccwArcTo: 0 @ 0.5 angle: 90 degreesToRadians ].
> -=-=-=-=-
>
>
> OK, now I can draw ellipse with just one arc:
> -=-=-=-
> canvas
> createPath: [ :builder |
> builder
> absolute;
> moveTo: 0.5 @ 0;
> arcCenterX: 0 centerY: 0 radius: 0.5 startAngle: 0 endAngle: Float twoPi
> -=-=-=-
>
> Why is this method in private protocol? Why I should not use it?
>
>
because its private.. and implementation specific.
other implementations may not have this method at all, and your code will
simply throw DNU.
And that's why you got the horizontal line btw.. because of using private
protocol bypassing coordinate tracking.


> Why I have to use “moveTo:”? In C-example they do not use it. But I have
> to, otherwise there is an extra line on the canvas:
>
> Well, I see in AthensCairoPathBuilder>>createPath:, there is call of "self
> moveToX: 0 Y: 0.”. If I remove it, I do not have to write “moveTo: 0.5@0”.
> So, I understand why I have to write it in my code. The question is what is
> the purpose of "self moveToX: 0 Y: 0.”? I guess it simplify some
> situations, am I right? Which one?
>

the initial moveTo: command lets you set the origin (starting point) of
your path.
if you don't start path with moveTo: command, it is implicitly set to 0@0.


>
> There is actual Athens example:
> -=-=-=-
> AthensSceneView new scene: [ :can |
> | path |
> path := can createPath: [ :builder |
> builder
> absolute;
> moveTo: 0.5 @ 0;
> arcCenterX: 0 centerY: 0 radius: 0.5 startAngle: 0 endAngle: Float twoPi ].
> can pathTransform restoreAfter: [
> can pathTransform scaleBy: 200 @ 50.
>
> (can setStrokePaint: Color red) width: 0.1.
> can drawShape:  path.
> ].
> ] ;
> openInWindow
> -=-=-=-
>
> Thank you,
> Juraj
>
>
> Second, they set line width, before any other action (like cairo_save). I
> do:
> -=-=-=-=-
> canvas pathTransform scaleBy: 200 @ 50.
> (can setStrokePaint: Color red) *width: 0.1*.
> can drawShape:  path.
> -=-=-=-=-
>
> So, my result in Athens is like this:
> <Captura de pantalla 2014-04-14 a la(s) 8.18.38.png>
>
> Any idea? The example is explained 
> here<http://cairographics.org/tutorial/#L2linewidth>,
> C source code is here <http://cairographics.org/tutorial/tips-ellipse.c> (by
> clicking on the image in the 
> page<http://cairographics.org/tutorial/#L2linewidth>
> ).
>
> Thank you,
> Jura
>
> El 12-04-2014, a las 4:01, Pharo4Stef <pharo4s...@free.fr> escribió:
>
> AthensSceneView new
> scene: [ :can |
>  | path |
>  path := can
>   createPath: [ :builder |
>   builder
>    absolute;
>    moveTo: 0 @ 0.5;
>    ccwArcTo: 0.5 @ 0.0 angle: 90 degreesToRadians;
>    ccwArcTo: 0.0 @ -0.5 angle: 90 degreesToRadians;
>    ccwArcTo: -0.5 @ 0.0 angle: 90 degreesToRadians;
>    ccwArcTo: 0 @ 0.5 angle: 90 degreesToRadians ].
>
>  can pathTransform
>  restoreAfter: [
>  can pathTransform scaleBy: 200 .
>  can
>   setPaint: Color red ;
>   drawShape:  path.
>   "(athensCanvas setStrokePaint: strokePaint)
>   width: (self strokeWidth / self scale) asFloat."
>  can drawShape:  path.].
>  can pathTransform
>  restoreAfter: [
>  can pathTransform scaleBy: 190 .
>  can
>   setPaint: Color blue ;
>   drawShape:  path.
>   "(athensCanvas setStrokePaint: strokePaint)
>   width: (self strokeWidth / self scale) asFloat."
>  can drawShape:  path
>
>  ]
>  ] ;
> openInWindow
>
>
> <Screen Shot 2014-04-12 at 09.01.09.pdf>
>
>
>
>


-- 
Best regards,
Igor Stasenko.

Reply via email to