Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Libraries

    SvgBatch 0.1.9

    Download button

    No screenshots available
    Downloads: 329  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Jonathan Hartley | More programs
    BSD License / FREE
    August 10th, 2009, 00:41 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    SvgBatch description

    Loads SVG files into pyglet Batch objects for OpenGL rendering.

    SvgBatch is a Python library to load SVG vector graphic files, and convert them into pyglet Batch objects, for OpenGL rendering.

    The polygons from the SVG file are tesselated using GLU functions, and used to create a pyglet Batch object of indexed vertex arrays. The Batch will aggregate all paths from an SVG file into a single OpenGL GL_TRIANGLES primitive for rendering. Each path is also exposed in its untessellated form, indexed by 'id' attribute, so the application could use them for collision detection, for example.

    Currently only a subset of SVG is handled - closed polygons, filled with solid color. These may comprise multiple loops (disjoint areas or holes), but must be made up from straight line edges. Arc polygon edges, gradient fills and other SVG entities (such as rectangles or text) are not currently handled.

    Usage:

    Very straightforward:

     svg = SvgBatch('data/logo.svg')
     batch = svg.create_batch()


    create_batch() returns a [http://www.pyglet.org/doc/api/index.html pyglet Batch object], which can be rendered in a pyglet program using batch.draw() (see demo.py.)

    Each path in the input SVG can include multiple loops, including holes or islands. The resulting batch is populated with one primitive for each filled path tag in the SVG. The primitives are all indexed vertices of GL_TRIANGLES, which I understand the batch will aggregate into a single large primitive.

    The untessellated geometry of the loaded paths can also be accessed for things other than rendering (eg. if your application wants to access the vertices of the loaded shape to create a collision boundary):

     path = svg.path_by_id['pathid']

    where pathid is the string ID of the path tag in the SVG file. This can be set from within Inkscape by selecting Object properties for the path. The returned Path object has the following attributes:

     * id: string, copied from the svg tag's id attribute
     * color: triple of unsigned bytes, (r, g, b)
     * loops: a list of loops. A loop is a list of vertices. A vertex is a pair of floats or ints.
     * bounds: an object which provides xmin, xmax, ymin, ymax, denoting the axis-aligned extents of the path
     * offset(x, y): a method which will add the given offset to all vertices in the path


    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    SVG loader | Batch objects | OpenGL rendering | OpenGL | SVG | batch

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM