Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interacting with a SVG in Pharo?

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

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

but clicking the SVG makes the picture dissapear. However all examples I have seen were using a web browser. Is this possible using Athens? There is any other work in this area?

like image 988
user183928 Avatar asked Dec 06 '25 08:12

user183928


2 Answers

That's because you are drawing it in display canvas, which is refreshed every time... so is natural that you lost it...

What you need to do is:

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

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

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

at the end, you will probably want it inside some other morph that you create, but debugging anyone of the solutions above with show you how to proceed :)

like image 159
EstebanLM Avatar answered Dec 08 '25 21:12

EstebanLM


Yes, as Esteban pointed, to keep morph on desktop, you should add it to world, i.e. use

openInWorld, or #openInWindow.

ASVGMorph is very basic, however, and not intended to serve all possible use cases. For more advanced uses, it is preferred to use ASVGRoot instance and draw it in own morph or compose with other drawings.

like image 23
Igor Stasenko Avatar answered Dec 08 '25 22:12

Igor Stasenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!