<s> '''<STR_LIT>''' <EOL> import sys , getopt , os <EOL> import pyglet . ext . scene2d <EOL> import pyglet . window <EOL> import pyglet . window . event <EOL> from pyglet import clock <EOL> import pyglet . image <EOL> from pyglet . ext . scene2d . debug import gen_hex_map , gen_rect_map , gen_recthex_map <EOL> try : <EOL> optlist , args = getopt . getopt ( sys . argv [ <NUM_LIT:1> : ] , '<STR_LIT>' ) <EOL> except getopt . GetoptError , error : <EOL> print error <EOL> print __doc__ % sys . argv [ <NUM_LIT:0> ] <EOL> sys . exit ( ) <EOL> size = ( <NUM_LIT:5> , <NUM_LIT:5> ) <EOL> renderer = pyglet . ext . scene2d . FlatView <EOL> maptype = None <EOL> filename = { '<STR_LIT:r>' : '<STR_LIT>' , '<STR_LIT:e>' : '<STR_LIT>' } <EOL> for opt , value in optlist : <EOL> if opt == '<STR_LIT>' : <EOL> maptype = '<STR_LIT>' <EOL> ch = int ( value ) <EOL> filename [ '<STR_LIT:x>' ] = '<STR_LIT>' % ch <EOL> elif opt == '<STR_LIT>' : <EOL> maptype = '<STR_LIT>' <EOL> ch = int ( value ) <EOL> filename [ '<STR_LIT:x>' ] = '<STR_LIT>' % ch <EOL> elif opt == '<STR_LIT>' : <EOL> maptype = '<STR_LIT>' <EOL> args = map ( int , value . split ( '<STR_LIT:U+002C>' ) ) <EOL> if len ( args ) == <NUM_LIT:1> : <EOL> args *= <NUM_LIT:2> <EOL> cw , ch = args <EOL> filename [ '<STR_LIT:x>' ] = '<STR_LIT>' % tuple ( args ) <EOL> elif opt == '<STR_LIT>' : <EOL> size = map ( int , value . split ( '<STR_LIT:U+002C>' ) ) <EOL> filename [ '<STR_LIT:e>' ] = '<STR_LIT>' % tuple ( size ) <EOL> elif opt == '<STR_LIT>' : <EOL> renderer = pyglet . ext . scene2d . FlatView <EOL> filename [ '<STR_LIT:r>' ] = '<STR_LIT>' <EOL> elif opt == '<STR_LIT>' : <EOL> renderer = pyglet . ext . scene2d . AxiometricView <EOL> scale = ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> filename [ '<STR_LIT:r>' ] = '<STR_LIT>' <EOL> elif opt == '<STR_LIT>' : <EOL> renderer = pyglet . ext . scene2d . AxiometricView <EOL> scale = map ( float , value . split ( '<STR_LIT:U+002C>' ) ) <EOL> filename [ '<STR_LIT:r>' ] = '<STR_LIT>' % scale <EOL> if maptype is None : <EOL> print '<STR_LIT>' <EOL> print __doc__ % sys . argv [ <NUM_LIT:0> ] <EOL> sys . exit ( ) <EOL> filename = '<STR_LIT>' % filename <EOL> w = pyglet . window . Window ( width = <NUM_LIT:1> , height = <NUM_LIT:1> , visible = False , alpha_size = <NUM_LIT:8> ) <EOL> mw , mh = size <EOL> if maptype == '<STR_LIT>' : <EOL> m = gen_recthex_map ( [ [ { } ] * mh ] * mw , ch ) <EOL> elif maptype == '<STR_LIT>' : <EOL> m = gen_hex_map ( [ [ { } ] * mh ] * mw , ch ) <EOL> else : <EOL> m = gen_rect_map ( [ [ { } ] * mh ] * mw , cw , ch ) <EOL> pxw = m . pxw <EOL> pxh = m . pxh <EOL> w . set_size ( width = pxw , height = pxh ) <EOL> w . set_visible ( ) <EOL> r = pyglet . ext . scene2d . FlatView ( <NUM_LIT:0> , <NUM_LIT:0> , pxw , pxh , layers = [ m ] ) <EOL> class SaveHandler : <EOL> def on_text ( self , text ) : <EOL> if text != '<STR_LIT:s>' : return pyglet . window . event . EVENT_UNHANDLED <EOL> image = pyglet . image . BufferImage ( ) . get_raw_image ( ) <EOL> fn = filename + '<STR_LIT>' <EOL> n = <NUM_LIT:1> <EOL> while os . path . exists ( fn ) : <EOL> fn = filename + str ( n ) + '<STR_LIT>' <EOL> n += <NUM_LIT:1> <EOL> print "<STR_LIT>" % fn <EOL> image . save ( fn ) <EOL> w . push_handlers ( SaveHandler ( ) ) <EOL> clock . set_fps_limit ( <NUM_LIT:10> ) <EOL> while not w . has_exit : <EOL> clock . tick ( ) <EOL> w . dispatch_events ( ) <EOL> r . clear ( ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> r . draw ( ) <EOL> w . flip ( ) </s>
