Added debugging mode to gif2c, where it will print overviews of which pixels of each frame changed.
This commit is contained in:
parent
1d693f34e9
commit
bfaf1a9d7a
@ -9,6 +9,8 @@ require 'pp'
|
|||||||
# The data format is described in animations.h
|
# The data format is described in animations.h
|
||||||
###
|
###
|
||||||
|
|
||||||
|
DEBUG = true
|
||||||
|
|
||||||
def compress(data, use_cutoff=true)
|
def compress(data, use_cutoff=true)
|
||||||
cutoff = 3
|
cutoff = 3
|
||||||
escape = 255
|
escape = 255
|
||||||
@ -106,6 +108,7 @@ puts "uint8_t animation_#{name}_colors[] PROGMEM = {#{colors[2..-1].map{|c| [c>>
|
|||||||
p_frame = nil
|
p_frame = nil
|
||||||
frames_data = []
|
frames_data = []
|
||||||
times = []
|
times = []
|
||||||
|
|
||||||
frames.each_with_index do |frame, index|
|
frames.each_with_index do |frame, index|
|
||||||
data = []
|
data = []
|
||||||
if index==0 # first frame
|
if index==0 # first frame
|
||||||
@ -144,6 +147,16 @@ frames.each_with_index do |frame, index|
|
|||||||
times << old_time + time
|
times << old_time + time
|
||||||
end
|
end
|
||||||
p_frame = frame
|
p_frame = frame
|
||||||
|
|
||||||
|
if DEBUG
|
||||||
|
puts "Frame ##{index}:"
|
||||||
|
total_y.times do |y|
|
||||||
|
total_x.times do |x|
|
||||||
|
print data[x + y*total_x]==0 ? "." : "X"
|
||||||
|
end
|
||||||
|
puts
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
data = frames_data.map{|d| compress(d, true)}
|
data = frames_data.map{|d| compress(d, true)}
|
||||||
@ -153,7 +166,7 @@ puts "uint16_t animation_#{name}_delays[] = {#{times.join(",")}};"
|
|||||||
s=0
|
s=0
|
||||||
puts "uint16_t animation_#{name}_offsets[] = {#{(data.map{|d| t=s; s+=d.count; t} + [s]).join(",")}};"
|
puts "uint16_t animation_#{name}_offsets[] = {#{(data.map{|d| t=s; s+=d.count; t} + [s]).join(",")}};"
|
||||||
|
|
||||||
puts "AnimationData animation_#{name} = {&animation_#{name}_colors[0], &animation_#{name}_data[0], &animation_#{name}_offsets[0], &animation_#{name}_delays[0], #{individual_frame_times}, #{colors.count-2}, #{frames_data.count}, #{frames.first.columns}, #{frames.first.rows}};"
|
puts "AnimationData animation_#{name} = {&animation_#{name}_colors[0], &animation_#{name}_data[0], &animation_#{name}_offsets[0], &animation_#{name}_delays[0], #{individual_frame_times}, #{colors.count-2}, #{frames_data.count}, #{total_x}, #{total_y}};"
|
||||||
puts
|
puts
|
||||||
STDERR.puts
|
STDERR.puts
|
||||||
STDERR.puts "Space usage:"
|
STDERR.puts "Space usage:"
|
||||||
|
Loading…
Reference in New Issue
Block a user