Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stuaxo/shoebot-scenegraph-experiment
Building a scenegraph based graphics engine for shoebot
https://github.com/stuaxo/shoebot-scenegraph-experiment
Last synced: about 6 hours ago
JSON representation
Building a scenegraph based graphics engine for shoebot
- Host: GitHub
- URL: https://github.com/stuaxo/shoebot-scenegraph-experiment
- Owner: stuaxo
- Created: 2014-06-02T09:22:29.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-11-18T22:00:51.000Z (almost 10 years ago)
- Last Synced: 2024-10-13T01:28:34.305Z (about 1 month ago)
- Language: Python
- Size: 184 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Scenegraph renderer experiment.
Implements a simple nodebox/shoebot like grammar end renders using a scenegraph.
Example, rendering to cairo.
```python
import cairocffi as cairo
import drivers.cairofrom scenegraph import *
if __name__=="__main__":
c = Canvas()
c.fill("blue")
c.stroke(0, 1, 0)
p = c.path()
p.moveto(0, 0)
p.lineto(100, 0)
p.lineto(100, 100)
p.lineto(0, 100)
p.lineto(0, 0)# Render to a cairo surface
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 200, 200)
ctx = cairo.Context(surface)
drivers.cairo.render(c.scenegraph, ctx)
surface.write_to_png("output.png")# Display the graph we just rendered
debug(c)
```The simple commands, add elements to the scenegraph, for instance - the example
above creates the following scenegraph:```
```Drivers render the graph by traversing it and instanciating classes that mirror
those in the scenegraph, but that can do the rendering.Finding classes:
================In the cairo driver, classes are nested, the TraverserMixn can find the
implementation by looking inside the child class.```python
class Canvas(TraverserMixin):
....
class Path(TraverserMixin):
class PathElement(CmdMxin):
def lineto(self, traverser, x, y):
traverser.ctx.line_to(x, y)def moveto(self, traverser, x, y):
traverser.ctx.move_to(x, y)def rect(self, traverser, width, height):
traverser.ctx.rectangle(0, 0, width, height)```
Commands
--------In the code above some PathElement is a CmdMixin - this allows functions to be
used.TODO
====State passed around needs to be much more simple.