# -*- coding: latin-1 -*- ''' Letter-Monster Engine v0.2.9 Copyright © 2009, Cristi Constantin. All rights reserved. This module generates a test LMGL file to play with. You can use it for Spawn, Spit or Execute. ''' import os, sys sys.path.insert( 0, os.getcwd() ) from _classes import * from _letter_monster import LetterMonster lm = LetterMonster() lm.DEBUG = True r = Raster( name = 'raster1', visible = True, transparent = u' ', z = 3, offset = (0,0), data = lm.VA._Transform('s2a', 'R a s t e r 1\nsome data'), ) lm.body[ r.name ] = r del r r = Raster( name = 'raster2', visible = True, transparent = u' ', z = 2, offset = (0,0), data = lm.VA._Transform('s2a', '00 00\n11 11\n22 22\n33 33\n44 44'), ) lm.body[ r.name ] = r del r r = Raster( name = 'raster3', visible = True, transparent = u' .', z = 4, offset = (0,0), data = lm.VA._Transform('s2a', '. .\n. .\nlast line of raster3'), ) lm.body[ r.name ] = r del r instruct = [
# -*- coding: latin-1 -*- ''' Letter-Monster Engine v0.3 Copyright © 2009, Cristi Constantin. All rights reserved. This one is Letter-Monster's SECOND animation ! It requires Pygame. Enjoy. The original image is called "grinkitty" and it's made by Samantha McGunagle. Check her profile : http://cryztaldreamz.deviantart.com ''' import os, sys sys.path.insert( 0, os.getcwd().replace('Animations','')[:-1] ) from _letter_monster import LetterMonster lm = LetterMonster() lm.DEBUG = True lm.Number_Of_Threads = 1 lm.Load( 'LM_Grin_Kitty.lmgl' ) # Change LMGL file here. lm.Render( 'pygame', size=(330,590), txtcolor=(0, 0, 0), bgcolor=(233, 199, 166) )
# -*- coding: latin-1 -*- ''' Letter-Monster Engine v0.2.9 Copyright © 2009, Cristi Constantin. All rights reserved. This module transforms a GIF animated pic into a LMGL file. You can use the LMGL file for ASCII animations. ''' import os, sys, shutil import Image sys.path.insert( 0, os.getcwd() ) from _letter_monster import LetterMonster lm = LetterMonster() lm.DEBUG = True # This is the name of your GIF animated picture. vImageName = 'bug.gif' # Create a directory to store the resulted images. try: os.mkdir( os.getcwd() + '/' + 'Gif_2_LMGL' ) except: pass vFrames = 0 # Save frame number. im = Image.open( vImageName ) for frame in range(999): try: im.seek(frame) vFrames = frame+1 except: break print 'Image has %i frames.' % vFrames
# -*- coding: latin-1 -*- ''' Letter-Monster Engine v0.2.9 Copyright © 2009, Cristi Constantin. All rights reserved. This module demonstrates executing instructions stored inside a vector layer, in one LMGL file. ''' import os, sys sys.path.insert(0, os.getcwd()) from _letter_monster import LetterMonster lm = LetterMonster() lm.DEBUG = True lm.Load('test.lmgl') print 'Executing vector instructions...\n' lm._Execute('vect1') print 'Executing macro instructions...\n' lm._Execute('macro1') print lm.body os.system('echo Done.&pause') #
# -*- coding: latin-1 -*- ''' Letter-Monster Engine v0.2.9 Copyright © 2009, Cristi Constantin. All rights reserved. This is a simple example for rendering a LMGL file on the screen, via Pygame. ''' import os, sys sys.path.insert( 0, os.getcwd() ) from _letter_monster import LetterMonster lm = LetterMonster() lm.DEBUG = True lm.Number_Of_Threads = 1 lm.Load( 'test_event.lmgl' ) print lm.Render('pygame', size=(300,200), fontsize=10, txtcolor=(166, 166, 255), bgcolor=(33, 33, 33)) os.system( 'echo Done.&pause' ) #
# -*- coding: latin-1 -*- ''' Letter-Monster Engine v0.2.9 Copyright © 2009, Cristi Constantin. All rights reserved. This module generates a test LMGL file to play with. You can use it for Spawn, Spit or Execute. ''' import os, sys sys.path.insert(0, os.getcwd()) from _classes import * from _letter_monster import LetterMonster lm = LetterMonster() lm.DEBUG = True r = Raster( name='raster1', visible=True, transparent=u' ', z=3, offset=(0, 0), data=lm.VA._Transform('s2a', 'R a s t e r 1\nsome data'), ) lm.body[r.name] = r del r r = Raster( name='raster2', visible=True, transparent=u' ', z=2,
# -*- coding: latin-1 -*- ''' Letter-Monster Engine v0.2.9 Copyright © 2009, Cristi Constantin. All rights reserved. This module generates a test LMGL file to play with. You can use it for Spawn, Spit or Render. ''' import os, sys sys.path.insert(0, os.getcwd()) from _classes import * from _letter_monster import LetterMonster lm = LetterMonster() lm.DEBUG = True # Background layer. r = Raster( name='raster1', visible=True, transparent=u'', data=lm.VA._Transform( 's2a', '#' * 30 + '\n' + 10 * ('#' + '.' * 28 + '#\n') + '#' * 30), z=1, ) lm.body[r.name] = r del r # Some text layer. r = Raster( name='raster2',
# -*- coding: latin-1 -*- ''' Letter-Monster Engine v0.3 Copyright © 2009, Cristi Constantin. All rights reserved. This one is Letter-Monster's SECOND animation ! It requires Pygame. Enjoy. The original image is called "grinkitty" and it's made by Samantha McGunagle. Check her profile : http://cryztaldreamz.deviantart.com ''' import os, sys sys.path.insert(0, os.getcwd().replace('Animations', '')[:-1]) from _letter_monster import LetterMonster lm = LetterMonster() lm.DEBUG = True lm.Number_Of_Threads = 1 lm.Load('LM_Grin_Kitty.lmgl') # Change LMGL file here. lm.Render('pygame', size=(330, 590), txtcolor=(0, 0, 0), bgcolor=(233, 199, 166))
Letter-Monster Engine v0.2.9 Copyright © 2009, Cristi Constantin. All rights reserved. This module demonstrates transforming an Image into a LMGL file. This file can be later rendered (check Spit example) or exported (check Spawn example). The transformation can be direct from Image to ASCII : call Consume, then Spawn as txt. You can choose another pattern for transformation. Filters can be applied on the image, separated by "|" (vertical line). For the list of valid patterns and filters check "LetterMonster" class, function "__init__". ''' import os, sys sys.path.insert(0, os.getcwd()) from _letter_monster import LetterMonster lm = LetterMonster() lm.DEBUG = True lm.Consume(image='Logo.png', x=0, y=0, pattern='default', filter='') try: os.remove('test_cons.lmgl') except: pass lm.Save('test_cons.lmgl', 'y') print 'Body 1: ', lm.body, '\n' print 'Data is len:', len(lm.body['raster1'].data) print 'Data[0] is len:', len(lm.body['raster1'].data[0]), '\n' print("Please, use Lucida Console Bold, size 4 for viewing.")
# -*- coding: latin-1 -*- ''' Letter-Monster Engine v0.3 Copyright © 2009, Cristi Constantin. All rights reserved. This one is Letter-Monster's FIRST animation ! It requires Pygame. Enjoy. The original image is called "Rotating Skeleton" and it's made by Tomi J. Maksa. Check his profile : http://www.pixeljoint.com/p/22334.htm ''' import os, sys sys.path.insert( 0, os.getcwd().replace('Animations','')[:-1] ) from _letter_monster import LetterMonster lm = LetterMonster() lm.DEBUG = True lm.Number_Of_Threads = 1 lm.Load( 'LM_Rotating_Skeleton.lmgl' ) # Change LMGL file here. lm.Render( 'pygame', size=(323,577), txtcolor=(255, 255, 255), bgcolor=(33, 33, 66) )
# -*- coding: latin-1 -*- ''' Letter-Monster Engine v0.2.9 Copyright © 2009, Cristi Constantin. All rights reserved. This module demonstrates executing instructions stored inside a vector layer, in one LMGL file. ''' import os, sys sys.path.insert( 0, os.getcwd() ) from _letter_monster import LetterMonster lm = LetterMonster() lm.DEBUG = True lm.Load( 'test.lmgl' ) print 'Executing vector instructions...\n' lm._Execute( 'vect1' ) print 'Executing macro instructions...\n' lm._Execute( 'macro1' ) print lm.body os.system( 'echo Done.&pause' ) #
# -*- coding: latin-1 -*- ''' Letter-Monster Engine v0.2.9 Copyright © 2009, Cristi Constantin. All rights reserved. Spawn is in fact an Export function. Can export as 'txt', 'csv', 'html', 'bmp', 'gif', 'jpg', 'png', 'pdf', 'ps'. ''' import os, sys sys.path.insert( 0, os.getcwd() ) from _letter_monster import LetterMonster lm = LetterMonster() lm.DEBUG = True print( 'Loading...\n' ) lm.Load( 'test_cons.lmgl' ) print( 'Spawning...\n' ) #lm.Export( out='txt', filename='Export' ) lm.Spawn( out='txt', filename='Export' ) # Spawn == Export. os.system( 'echo Done.&pause' ) #
# -*- coding: latin-1 -*- ''' Letter-Monster Engine v0.3 Copyright © 2009, Cristi Constantin. All rights reserved. This one is Letter-Monster's THIRD animation ! It requires Pygame. Enjoy. The original image is called "bug.gif". I don't know who is the author, i'm sorry. ''' import os, sys sys.path.insert(0, os.getcwd().replace('Animations', '')[:-1]) from _letter_monster import LetterMonster lm = LetterMonster() lm.DEBUG = True lm.Number_Of_Threads = 1 lm.Load('Bug.lmgl') # Change LMGL file here. lm.Render('pygame', size=(250, 510), txtcolor=(0, 0, 0), bgcolor=(100, 155, 133))