Skip to content

Instantly share code, notes, and snippets.

@ghostganz
Created January 10, 2012 14:33
Show Gist options
  • Save ghostganz/1589361 to your computer and use it in GitHub Desktop.
Save ghostganz/1589361 to your computer and use it in GitHub Desktop.
Widening a PNG sprite on three places
require 'chunky_png'
original = ChunkyPNG::Image.from_file "original.png"
target = ChunkyPNG::Image.new(original.width + (355 * 3), original.height)
break_columns = [100, 310 + 100, 620 + 100]
target_x = 0
(0...original.width).each do |x|
col = original.column(x)
if break_columns.include? x
356.times do
target.replace_column!(target_x, col)
target_x += 1
end
else
target.replace_column!(target_x, col)
target_x += 1
end
end
target.save "/tmp/success.png"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment