Created
October 26, 2012 22:03
-
-
Save kot-behemoth/3961834 to your computer and use it in GitHub Desktop.
SpriteGluer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# Place the script in the directory with all the images, tweak `prefix` and `output` and just run it. | |
require 'rubygems' | |
require 'RMagick' | |
include Magick | |
Image_dims = 96 | |
prefix = 'swordskel attack' | |
output = 'p_dying' | |
output_fname = output + '_big.bmp' | |
# If the animation has too many frames, take every even one | |
#nums = %w( 0 2 3 5 6 7 9 11 ) | |
# Otherwise, just use the simple progression | |
nums = (0..7).to_a.map(&:to_s) | |
dirs = %w( n ne e se s sw w nw ) | |
Canvas = Image.new( 768, 768 ) { self.background_color = "black" } | |
puts 'Starting the script' | |
def draw_image( dir, num, image ) | |
offset = 0 | |
Canvas.store_pixels( num * Image_dims, | |
dir * Image_dims, | |
Image_dims, | |
Image_dims, | |
image.get_pixels(offset,offset,Image_dims,Image_dims) ) | |
end | |
dirs.each_index do |dir| | |
puts "For dir #{dirs[dir]}..." | |
nums.each do |num| | |
n = (num.to_i < 10) ? '0'+num : num | |
image_name = "#{prefix} #{dirs[dir]}00#{n.to_s}.bmp" | |
puts "Trying to push file \"#{image_name}\" to the ImageList" | |
draw_image( dir, nums.rindex(num), (Image.read(image_name))[0] ) | |
end | |
end | |
#Canvas.display | |
Canvas.write( output_fname ) | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment