Skip to content

bil-bas/gale

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Gale

Ruby gem to read info and data from a Graphics Gale (.gal) animation file.

Note: Only works on Windows and requires the Graphics Gale DLL (galefile.dll), available for download from http://www.humanbalance.net/gale/us/ (I have to ask for permission to distribute it with the gem, but haven't had a reply yet).

Installation

gem install gale

Examples

# By default, gale has no external dependencies, but can only export bitmaps.
require 'gale'
animation = Gale::File.open "jumping.gal" do
  puts animation.size                                           #=> 3, which is the number of frames.
  puts [animation.width, animation.height]                      #=> [64, 32]
  puts animation[0].name                                        #=> "Dog getting ready to jump"
  puts animation[0][0].name                                     #=> "Dog's Body"
  animation[0].export_bitmap "jump_0.bmp"                       # Saves the first frame as a bitmap.
  animation[0][0].export_alpha_channel "jump_0_0_alpha.bmp"     # Saves the first layer's alpha channel
  animation[0][0].export_bitmap "jump_0_0.bmp"                  # Saves the first layer as a bitmap.
  animation.export_yaml "jump.yml", [:name, :delay]             # Saves a YAML data file containing info about each frame.
end

# If using Gosu/TexPlay, then it is possible to export directly to a Gosu::Image, with transparency.
require 'gale/gosu' # Will require the gosu and texplay gems for you.
animation = Gale::File.open "jumping.gal" do
  gosu_frame = animation[0].to_image                            #=> a Gosu::Image, being the first frame.
  gosu_layer = animation[0][0].to_image                         #=> a Gosu::Image, being the first layer.
  gosu_frames = animation.map {|f| f.to_image }                 #=> Array of Gosu::Image, one for each frame.

  gosu_spritesheet = animation.to_spritesheet                   #=> a Gosu::Image, being a horizontal series of frames.
  gosu_spritesheet.save "jumping.png"                           # Gosu images can be saved in png or bmp format.

  gosu_color = Gosu::Color.from_gale animation.background_color #=> a Gosu::Color
end

About

Reads Graphics Gale (.gal) files

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages