Interoperating with SVG in Pharo?

I want to get a very basic interaction with SVG loaded via Athens in Pharo using Morphic. This example shows what I'm looking for. I used

(ASVGMorph fromFile: 'lion.svg') drawOn: Display getCanvas

      

but when clicking on SVG the image disappears. However, all the examples I've seen use a web browser. Is this possible using Athens? Is there any other work in this area?

+3


source to share


2 answers


This is because you paint it on a canvas that is updated every time ... so naturally you lost it ...

What you need to do:

(ASVGMorph fromFile: 'lion.svg') openInWorld.

      



or better, you probably want to put it on a window:

(ASVGMorph fromFile: 'lion.svg') openInWindow.

      

at the end, you probably want it in some other morph you create, but debug any of the above solutions showing how to proceed :)

+3


source


Yes, as Esteban pointed out, in order to save the morph to the desktop, you have to add it to the world i.e. use

openInWorld, or #openInWindow.



ASVGMorph is very simple and is not intended to be used in every possible use case. For more complex applications, it is preferable to use an instance of ASVGRoot and draw it in your own morph or compose it using other drawings.

+2


source







All Articles