Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to import/compose SVG files? #41

Open
nickclare opened this issue Nov 23, 2022 · 3 comments
Open

Any way to import/compose SVG files? #41

nickclare opened this issue Nov 23, 2022 · 3 comments

Comments

@nickclare
Copy link

I was wondering if there was a way to create objects from existing SVG images, or any existing converter that would allow me to create new functions from SVG files?

For reference, I'm trying to see if MetaPict can be useful for creating system architecture diagrams, particularly using the AWS Architecture Icons, which they provide in SVG format.

I've only just started looking at metapict and racket, and its been many years since I wrote any lisp code at all, so while I'm willing to dive in and try make this work myself, I wanted to check if there were any existing ways before I wasted my time

@soegaard
Copy link
Owner

soegaard commented Nov 23, 2022 via email

@soegaard
Copy link
Owner

@nickclare

I am happy to report, that librsvg still works!

Turns out the C api has changed in years, so installing a new version of librsvg using Homebrew worked for me.

I installed C librarylibrsvg with
brew install librsvg

And the Racket library rsvg with:
raco pkg install rsvg

A small test with random svg file worked fine:

#lang racket
(require racket/runtime-path
         rsvg
         metapict)

(define-runtime-path logo.svg "python-logo.svg")
(define logo (svg-file->pict logo.svg))

(set-curve-pict-size 400 400)
logo

(draw (rotate (scale 0.5 logo) (rad 15))
      (text-color "white" (text "Python"))
      (text "Python"))

image

@nickclare
Copy link
Author

Thanks so much for the quick response. I'll definitely try this out and let you know how it goes. Ideally what I want to do is have a library of high-level functions that draw the AWS components according to their style guide, but being able to draw the SVG files they give is a huge first step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants