Display MozCanvas on screen?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Display MozCanvas on screen?

David Richards

| canvas |
. canvas := BlSpartaMozCanvasBuilder extent: 600@400

How do I display this MosCanvas on screen?

Does anyone know where I can get documentation on how to do graphics in Pharo? The comments in the code are not understandable to a beginner.
Reply | Threaded
Open this post in threaded view
|

Re: Display MozCanvas on screen?

Tudor Girba-2
Hi,

Look for the examples that are shipped with GT/Brick/Bloc/Sparta.

The simplest  way you play with the canvas is through the inspector.

For example, paste this code in a Playground:

canvas := BlSpartaMozCanvasBuilder extent: 600@400.
canvas fill
paint: Color white;
path: canvas bounds;
draw.
path := canvas path
moveTo: 150@50;
lineTo: 250@250;
curveVia: 150@300 to: 50@250;
close;
finish.
canvas stroke
paint: Color red;
path: path;
strokeOptions: (canvas strokeOptions
width: 5);
draw.
canvas

Then inspect the result (Cmd+g), and choose the Preview view from the inspector.

Here is how it looks like in the new GT Playground:


Cheers,
Doru


On Feb 25, 2019, at 11:09 PM, David Richards <[hidden email]> wrote:


| canvas |

. canvas := BlSpartaMozCanvasBuilder extent: 600@400

How do I display this MosCanvas on screen?

Does anyone know where I can get documentation on how to do graphics in Pharo? The comments in the code are not understandable to a beginner.

--
www.feenk.com

"We cannot reach the flow of things unless we let go."