Home | Trees | Indices | Help |
---|
|
object --+ | dict --+ | BagOfStuff
Loads and holds stuff: Images, Fonts and SVG files.
bos = BagOfStuff(); bos.add("apic.jpg", "logo")
Then you can use bos["logo"].pixbuf to get the pixel buffer for Python-Cairo.
Make one bag in your app, before you create your main AllThings object. This way it can install your fonts before GTK starts. Once GTK starts, there's no way to add new fonts to your app.
bos = BagOfStuff()
bos.add('some file','some_key')
Once you have an instance, you can extract/use stuff:
Instance Methods | |||
new empty dictionary |
|
||
|
|||
|
|||
Inherited from Inherited from |
Class Variables | |
imagetypes =
|
|
fonttypes =
|
|
vectortypes =
|
|
Inherited from |
Properties | |
Inherited from |
Method Details |
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
|
x[y]
|
Add resources to your "bag". This is a simple way to get SVG (Inkscape) files and images and fonts into your animation; and then refer to them by keys. Usebos = BagOfStuff() bos.add(filename, key) This adds stuff to your bag of ..well.. stuff -- think of it as a repository of elements for your scenes and animations. Each item in a bag has a variety of methods, like bos['alien'].draw(). See the classes Sprite, Loop, Path, Mask as well as .. .. .. SVG filesNB: Within your SVG file, ensure the main elements have their own UNIQUE ids. KeysEach id (in the SVG file) will be joined to the key (given to the add method) to form the master key for this bag. Example: bos.add('some.svg','walking'). Thereafter, stuff within the bag will be keyed as 'walking:funnywalk', 'walking:run' assuming you have ids within the SVG called 'funnywalk' and 'run'. You set ids on objects in Inkscape by using the Object Properties dialog. LAYOUT OF YOUR SVG FILESThis is quite important to get right. Use only these layer names and rules: spritesA 'sprite' is a GROUP of shapes. Use as many sprites on this layer as you need. Each a unique group with and id. Clones: Create and use freely within each sprite. Just watch complexity because that slows things down. Groups: You can use sub-groups within a sprite. They do not need ids. All other Inkscape tools can be used -- effects like blur may not work. loopsA 'loop' is a SUB-LAYER of GROUPS. The idea is that you would draw animations like walk-cycles, or explosions -- frame-by-frame stuff -- in a "loop". Given a sub-layer called "walking", you would have individual groups within that called "walk1", "walk2" and so on. Each sub group must be given an incremental id: walk1, walk2, walk3 etc. These will be pulled-out and keyed by that id. All other rules the same as for sprites. masksA 'mask' is a simple, closed path that can be used for clipping or hit-testing. Do NOT group these vectors. Draw a single path (and convert to curves) and give it an id. pathsA 'path' is a simple open path (convert to curves). Do NOT group it. Paths are used for making Things follow along them. (You could also simply draw them to the screen.) SUB-LAYERSImportant. On each MAIN LAYER, you *must* add SUB LAYERS (use Inkscape's layer dialog) and keep each of your objects on their OWN LAYER. For example: In your 'sprites' layer, you have "redaliens" and "bluealiens" layers under it. In the "redalien" sub-layer, you have a group with id="redalien1". You can also add other sprites, let's add id="boss_monster". In your "bluealiens" sub-layer (hide the redaliens one) and draw a group with id="bluebug". Now you have: sprites |____redaliens | |_______redalien1 | | | |_______boss_monster | |____bluealiens |_______bluebug . This has several advantages, not least of which is that you can draw many things in one svg file and use the visibility tool to focus on one thing at a time. HIDING THINGSSuppose you use a rectangle as a means to guide your drawing, but don't want it in the final animation: In Inkscape, under the object properties dialog, give the rectangle a Label of hidden and it will be. Adding imagesYou can load png, jpg and jpeg files. Use: bos.add('path/to/somepic.png','my_big_ugly_logo') See class AnImage for more info. Adding fontsAt the moment you can only use ttf files. Use: bos.add('path/to/somefont.ttf','key') In the case of fonts, the key is not used, but you must pass it. You use fonts via pango, and that takes a family name. Adding soundsI suggest that you practice using lips, tongue and bits of shrubbery to make the sounds you expect to hear. Try to time this with the animation. This will have to do until I get a clue about how-to include sound, doo-bee-doo. The add() method
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Tue May 26 16:03:26 2009 | http://epydoc.sourceforge.net |