Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Using .svg files — Gideros Forum

Using .svg files

totebototebo Member
edited November 2017 in General questions
I want to take advantage of the phenomenal vector support Gideros has. The tool I'm using, Sketch 3, outputs to the format below. Does anyone know if this is a standardised xml format for .svg?
<?xml version="1.0" encoding="UTF-8"?>
<svg width="106px" height="106px" viewBox="0 0 106 106" version="1.1" xmlns="<a href="http://www.w3.org/2000/svg&quot" rel="nofollow">http://www.w3.org/2000/svg&quot</a>; xmlns:xlink="<a href="http://www.w3.org/1999/xlink"&gt" rel="nofollow">http://www.w3.org/1999/xlink"&gt</a>;
    <!-- Generator: Sketch 47 (45396) - <a href="http://www.bohemiancoding.com/sketch" rel="nofollow">http://www.bohemiancoding.com/sketch</a> -->
    <title>Oval</title>
    <desc>Created with Sketch.</desc>
    <defs></defs>
    <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
        <circle id="Oval" stroke="#979797" stroke-width="5" fill="#D8D8D8" cx="53" cy="53" r="50"></circle>
    </g>
</svg>
I'm ultimately looking to abstract this to a function like Vector.new(filename), so I can use .svg files like I use .png files with Bitmap.new(Texture.new(filename)) now.
My Gideros games: www.totebo.com

Comments

  • antixantix Member
    edited November 2017
    I would say not...
    InkScape will not load it
    Internet Exploder just shows a blank window
    Firefox says this...
    XML Parsing Error: not well-formed
    Location: file:///C:/Users/Cliff/test.svg
    Line Number 2, Column 124:
    Chrome says...
    This page contains the following errors:
    error on line 2 at column 124: xmlns: 'http://www.w3.org/2000/svg" xmlns:xlink=' is not a valid URI
    Below is a rendering of the page up to the first error
    I would say look for options inside your program to export a valid SVG file, or find a new program :bz
  • hgy29hgy29 Maintainer
    Yes, it is, but gideros itself only handles the 'path' part of svg. Look at the banana exemple in reference manual about Path2D. Applied to your exemple this be become:
    p=Path2D.new()
    p:setSvgPath("M0,0 L493,0 L493,493 L0,493 L0,0 Z M246.5,376 C318.020875,376 376,318.020875 376,246.5 C376,174.979125 318.020875,117 246.5,117 C174.979125,117 117,174.979125 117,246.5 C117,318.020875 174.979125,376 246.5,376 Z") --Set the path from a SVG path description
    p:setLineThickness(1) -- Outline width (stroke-width)
    p:setFillColor(0x000000,0.0) --Fill color (transparent=no fill)
    p:setLineColor(0x000000) --Line color (nothing specified but let it be black)
    stage:addChild(p)
  • @hgy29 Okay, then I'll go ahead and parse this XML!

    @antix, could you post an example of what Inkscape outputs?
    My Gideros games: www.totebo.com
  • antixantix Member
    edited November 2017
    @totebo, here is a circle exported from InkScape...
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
     
     
     
     
     
            image/svg+xml
     
     
     
     
     
     
     
     
     
     
    That was exported as a plain SVG file
  • @antix, that's similar, maybe the same? It's missing quite a bit of the XML, probably because of the forum. Maybe attach as text?
    My Gideros games: www.totebo.com
  • antixantix Member
    edited November 2017
    @totebo, yes forum formatting grr. I've attached a zip with it in since the forum also forbids svg attachments :D
    zip
    zip
    test.zip
    613B
  • totebototebo Member
    edited November 2017
    Here is mine as a file!
    zip
    zip
    Oval.zip
    869B
    My Gideros games: www.totebo.com
  • They look exactly the same! I think we should be good getting this into Gideros.

    Likes: MoKaLux

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.