JuliaGraphics / Luxor.jl

Simple drawings using vector graphics; Cairo "for tourists!"

Home Page:http://juliagraphics.github.io/Luxor.jl/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to define an id to a path?

davibarreira opened this issue · comments

Hey @cormullion , me again. I was wondering if there is a way to assing id tags to the svg elemnts. For example:

d = Drawing(200,200,:svg)
origin()
circle(O,20,:fill)
circle(O+Point(30,0),20,:fill)
preview()
finish()

The svg for this looks something like:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200pt" height="200pt" viewBox="0 0 200 200" version="1.1">
<g id="surface16">
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 120 100 C 120 111.046875 111.046875 120 100 120 C 88.953125 120 80 111.046875 80 100 C 80 88.953125 88.953125 80 100 80 C 111.046875 80 120 88.953125 120 100 "></path>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 150 100 C 150 111.046875 141.046875 120 130 120 C 118.953125 120 110 111.046875 110 100 C 110 88.953125 118.953125 80 130 80 C 141.046875 80 150 88.953125 150 100 "></path>
</g>
</svg>

I'd like to know if it's possible to attirbute an id tag, as in <path id="circle1" style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 120 100 C 120 111.046875 111.046875 120 100 120 C 88.953125 120 80 111.046875 80 100 C 80 88.953125 88.953125 80 100 80 C 111.046875 80 120 88.953125 120 100 "></path>.

It would also be great if it was possible to encapsulate a whole bunch of paths inside a <g> tag with also an specific id.

If it were possible, there would have to be some functions in here - https://cairographics.org/manual/cairo-SVG-Surfaces.html - that we could use. But it doesn't look promising, to me at least. Compose.jl writes its own SVG files, but I can't see how Cairo could do it...

I'm a complete noob in terms of Cairo... What about wrapping things with the <g> tag? The svg output does seems to place things within a <g id="surface16">. Perhaps something like:

<g id="surface16">

  <g id="MYID1">
  <path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 120 100 C 120 111.046875 111.046875 120 100 120 C 88.953125 120 80 111.046875 80 100 C 80 88.953125 88.953125 80 100 80 C 111.046875 80 120 88.953125 120 100 "></path>
  </g>
  <g id="MYID2">
  <path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 150 100 C 150 111.046875 141.046875 120 130 120 C 118.953125 120 110 111.046875 110 100 C 110 88.953125 118.953125 80 130 80 C 141.046875 80 150 88.953125 150 100 "></path>
  </g>
</g>

Oh, I thought Cairo generated the SVG... If it doesn't, then how is the svg specifyied in Luxor?

Shoot, :(

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.