Coder Social home page Coder Social logo

glsvg's Introduction

glsvg

A python library for parsing and displaying SVG files using opengl, with a focus on being usable for games.


Usage

    import glsvg

    # initialize opengl context
    # ...

    # load svg file
    svg_doc = glsvg.SVGDoc(filename)

    # draw svg file
    svg_doc.draw(x,y)

Status

Requires:

  • PyOpenGL

Supported game libraries:

  • PyGame
  • Pyglet

Supported SVG features:

  • All SVG path commands (arc/curves/lines/etc.)
  • Basic SVG shapes (rectangle, ellipse)
  • Per-Pixel Linear and Radial Gradients
  • Parsable color names
  • Variable line widths and miter/bevel joints

SVG Features In Progress:

  • SVG patterns
  • SVG effects (Drop shadow, blur, etc.)
  • More sophisticated line effects (patterns, arc joints, etc.)

Likely to be not supported:

  • Animation
  • Text (this would be likely to require too many extra dependencies for fonts, but an easy workaround is to convert text objects to paths in your editor, ie Inkscape or Illustrator)
  • CSS based style tags

Credits:

Based on the squirtle mini-library by Martin O'Leary:

http://www.pyweek.org/d/1783/

glsvg's People

Contributors

fathat avatar lvh avatar boris-ulyanov avatar stuaxo avatar

Stargazers

James Blackburn avatar Peter DeVita avatar Timon de Groot avatar Maksim Surguy avatar origami dance avatar bboissy avatar Patrick avatar Carlos avatar  avatar  avatar The Algebraist avatar Michael Schuller avatar Darek Kedra avatar Islam Ali avatar  avatar

Watchers

 avatar  avatar

glsvg's Issues

Please support retained mode to allow OpenGL ES compatibility

Awesome to see squirtle getting some love and attention!

I'd like to request that you implement the drawing using retained mode instead of immediate mode; this would allow the library to be used with OpenGL ES applications such as those running on Android / iOS and other OpenGL ES platforms.

How do I draw an SVGDoc multiple times?

Only the last .draw call appears to have any effect. From some of the methods/attributes on SVGDoc, I was hoping Sprite + Batch would work; but it doesn't.

(If you explain me how to do this, I'll gladly document it for you.)

Documentation on pypi is wrong

I tried the example on pypi and got this:

Traceback (most recent call last):
File "go2.py", line 8, in
svg_doc = glsvg.SVG(filename)
AttributeError: 'module' object has no attribute 'SVG'

TypeError: float() argument must be a string or a number

This smiley svg on wikipedia causes an error

https://upload.wikimedia.org/wikipedia/commons/8/85/Smiley.svg

Exception while parsing element <Element '{http://www.w3.org/2000/svg}circle' at 0x7f6fda20f390>
Traceback (most recent call last):
  File "go2.py", line 9, in <module>
    svg_doc = glsvg.SVGDoc(filename)
  File "/mnt/data/home/stu/.virtualenvs/3d/local/lib/python2.7/site-packages/glsvg/svg.py", line 146, in __init__
    self.parse_root(self.root)
  File "/mnt/data/home/stu/.virtualenvs/3d/local/lib/python2.7/site-packages/glsvg/svg.py", line 177, in parse_root
    self._parse_element(e)
  File "/mnt/data/home/stu/.virtualenvs/3d/local/lib/python2.7/site-packages/glsvg/svg.py", line 192, in _parse_element
    renderable = SVGPath(self, e, parent)
  File "/mnt/data/home/stu/.virtualenvs/3d/local/lib/python2.7/site-packages/glsvg/svg_path.py", line 237, in __init__
    self.config)
  File "/mnt/data/home/stu/.virtualenvs/3d/local/lib/python2.7/site-packages/glsvg/svg_path_builder.py", line 111, in read_xml_svg_element
    cx = float(e.get('cx'))
TypeError: float() argument must be a string or a number

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.