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?
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?
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, C source code is
here (by clicking on the image in the
page).
Thank you,
Jura
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>