6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/sprite_animation/sprite_animation_helper.rb', line 6
def animate_sprite(image_src, frame_count, params = {})
scale = params[:scale] || 1
img_width, img_height = ImageSize.size(image_src).map { |d| d*scale }
orientation = params[:orientation] ||
guess_orientation(img_width, img_height)
frame =
send(orientation,*[img_width,img_height,frame_count])
image = image_tag(image_url(image_src), class: "animated",
frameCount: frame_count,
frameLength: frame[:length],
frameSide: frame[:margin],
style: frame[:style])
content_tag(:div, image,
style: animated_div_style(frame[:width],frame[:height]))
end
|