# .----------------------------------[ icedragon@quickfox.org ]--. # # | sample-ghost.py | FS2 Image Ghosting Script [EXAMPLE] | # # |--------------------------------------------------------------| # # | This script will take a preset FS2 file and will make a kind | # # | of "ghost" effect by applying transparency chessboard on the | # # | images. | # # `--------------------------------------------------------------' # ###--# Imports #--### # Imports the two classes we'll use - FS2_File and FS2_Shape along # with FLAG_ENCODED pseudo-constant. from libfs2 import * ###--# Functions #--### def mkGhost ( shape ): """This function will apply the ghost effect on a specific shape it gets.""" for x in range(shape.width): for y in range(shape.height): if bool( x%2 - y%2 ): shape.setPixel( (x,y), 0 ) ###--# Startup #--### # Assign an FS2 file we'll be working with. fs2 = FS2_File('input.fs2') # We'll be using IDs so we don't create pseudo-variables - we need to mod the FS2! for shapeID in range( len(fs2.shapes) ): # Passing the address of the shape variable so it doesn't create a new variable. mkGhost( eval( 'fs2.shapes[shapeID]' ) ) # Adding a tail to the file for personalization. Not a good thing, but Furc won't mind... ;) fs2.tail = "Created by Artex/IceDragon [http://icerealm.theden.ws/info/]" # When all is done, save the FS2 file to disk and terminate. fs2.saveFile('output.fs2') print "Done."