SVG Icons

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

SVG Icons

Steven R. Baker
Heya folks!

I need to load SVG images (for icons) in my application. I've searched
my 6.1 image for SVG, but haven't found anything.

Is there a library for loading SVGs? I'd really like to get them
directly into instances of Form if possible, but I'm flexible. :)

Thanks!

-Steven



Reply | Threaded
Open this post in threaded view
|

Re: SVG Icons

Peter Uhnak
Hi,

this is not really tested, but you can try to do the following

(installation)
a) install XMLParser from catalog
b) in monticello browser open Pharo/Athens and load latest version of Athens-SVG package

(usage)
Then you import SVG XML using Converter and paint it on a surface, which you convert to Form.

```
contents := (ZnEasy get: 'https://s.cdpn.io/3/kiwi.svg') contents.

xmlDoc := XMLDOMParser parse: contents.

svg := AthensSVGConverter new importXMLDocument: xmlDoc.
svg transform: 'scale(0.5)'.

extent := 500 @ 500.

surface := AthensCairoSurface extent: extent.
surface drawDuring: [ :aCanvas | svg renderOn: aCanvas ].
surface asForm.
```

Inline image 1

Peter

On Thu, Oct 5, 2017 at 1:50 PM, Steven R. Baker <[hidden email]> wrote:
Heya folks!

I need to load SVG images (for icons) in my application. I've searched
my 6.1 image for SVG, but haven't found anything.

Is there a library for loading SVGs? I'd really like to get them
directly into instances of Form if possible, but I'm flexible. :)

Thanks!

-Steven




Reply | Threaded
Open this post in threaded view
|

Re: SVG Icons

Sven Van Caekenberghe-2
That is a very cool example !

Some nit picking (just trying to help make examples/snippets even more sexy).

The shortest expression to get to the contents of a URL, using only unary selectors is

  'https://s.cdpn.io/3/kiwi.svg' asUrl retrieveContents.

XMLDomParser's API also has the option #parseURL: so the following would also work

  XMLDomParser parseURL: 'https://s.cdpn.io/3/kiwi.svg'.

I believe that call actually has some additional functionality too.

> On 5 Oct 2017, at 15:24, Peter Uhnák <[hidden email]> wrote:
>
> Hi,
>
> this is not really tested, but you can try to do the following
>
> (installation)
> a) install XMLParser from catalog
> b) in monticello browser open Pharo/Athens and load latest version of Athens-SVG package
>
> (usage)
> Then you import SVG XML using Converter and paint it on a surface, which you convert to Form.
>
> ```
> contents := (ZnEasy get: 'https://s.cdpn.io/3/kiwi.svg') contents.
>
> xmlDoc := XMLDOMParser parse: contents.
>
> svg := AthensSVGConverter new importXMLDocument: xmlDoc.
> svg transform: 'scale(0.5)'.
>
> extent := 500 @ 500.
>
> surface := AthensCairoSurface extent: extent.
> surface drawDuring: [ :aCanvas | svg renderOn: aCanvas ].
> surface asForm.
> ```
>
> <image.png>
>
> Peter
>
> On Thu, Oct 5, 2017 at 1:50 PM, Steven R. Baker <[hidden email]> wrote:
> Heya folks!
>
> I need to load SVG images (for icons) in my application. I've searched
> my 6.1 image for SVG, but haven't found anything.
>
> Is there a library for loading SVGs? I'd really like to get them
> directly into instances of Form if possible, but I'm flexible. :)
>
> Thanks!
>
> -Steven
>
>
>
>