def timeout
@background.copy_area(0, 0, @background.width, @background.height,
@frame, 0, 0)
f = Float(@frame_num % CYCLE_LEN) / CYCLE_LEN;
xmid = @background.width / 2.0
ymid = @background.height / 2.0
radius = [xmid, ymid].min / 2.0
@images.each_with_index do |image, i|
ang = 2.0 * Math::PI * Float(i) / IMAGE_NAMES.length - f * 2.0 * Math::PI
r = radius + (radius / 3.0) * Math.sin(f * 2.0 * Math::PI)
xpos = (xmid + r * Math.cos(ang) - image.width / 2.0 + 0.5).floor
ypos = (ymid + r * Math.sin(ang) - image.height / 2.0 + 0.5).floor
k = if (i & 1) == 1
Math.sin(f * 2.0 * Math::PI)
else
Math.cos(f * 2.0 * Math::PI)
end
k = [0.25, 2.0 * k * k].max
r1 = Gdk::Rectangle.new(xpos, ypos, image.width * k, image.height * k)
r2 = Gdk::Rectangle.new(0, 0, @background.width, @background.height)
dest = r1.intersect(r2)
if dest
@frame.composite!(image, dest.x, dest.y, dest.width, dest.height,
xpos, ypos, k, k, Gdk::Pixbuf::INTERP_NEAREST,
if (i & 1) == 1
[
127,
(255 * Math.sin(f * 2.0 * Math::PI)).abs
].max
else
[
127,
(255 * Math.cos(f * 2.0 * Math::PI)).abs
].max
end)
end
end
@da.queue_draw
@frame_num += 1
true
end