Skip to content
This repository
tree: 04c0a0ab53
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 62 lines (42 sloc) 1.817 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
PRender is a way to use Processing from inside Python. Like this:

Draw an X and save it as a "x.png":

  from prender import processing
  pr = processing.BaseRenderer()
  pr.start(200,200)
  pr.line(0,0,100,100)
  pr.line(0,100,100,0)
  pr.saveLocal( "x.png" )
  pr.stop()
  
If python throws an unhandled exception while the renderer is running, it will stall forever. Some sugar to handle that:

  from prender import processing
  pr = processing.BaseRenderer()
  
  def draw(xx):
    xx.line(0,0,100,100)
    xx.line(0,100,100,0)
    xx.saveLocal( "x.png" )
    raise Exception( "random problem" )
  
  pr.execute( 200, 200, draw )
  
The execute() method runs the function draw() until it finishes or catches an exception, at which point it stops the renderer.

The class "MapRenderer" is helpful for rendering maps

  from prender import processing
  mr = processing.MapRenderer()
  mr.start(-500,-500,500,500,500) #left,bottom,right,top,width
  mr.background(255,255,255)
  mr.line(-500,-500,500,500) #from lower-lefthand to upper-righthand
  mr.saveLocal("map.png")
  mr.stop()

==== INSTALLATION INSTRUCTIONS ====

--== Compile rendering server ==--

1) Open renderer/renderer.pde in Processing
2) Run it. It may throw an error along the lines of.
  "java.lang.ClassCastException: renderer cannot be cast to processing.core.PApplet
    at processing.core.PApplet.main(PApplet.java:6486)"
3) Go to "File"->"Export Application" and export a linux or mac application, depending on your platform.

--== Install rendering server ==--

$ sudo make install

--== Install python client library ==--

$ sudo python setup install

--== Test ==--

$ cd prender
$ python processing.py

If everything is working properly, several images should show up in the local directory. You can delete them; they don't do anything.
Something went wrong with that request. Please try again.