--draws a passed image to coords (x, y)
function draw_image(img, x, y)
if not img then --make sure an image was passed, otherwise bail
rb.splash(rb.HZ, "No Image!")
return nil
end
--User supplied
--local x, y = (rb.LCD_WIDTH - img:width()) / 2, (rb.LCD_HEIGHT - img:height()) / 2
local imgx = 0
local imgy = 0
local func = rb.lcd_bitmap_transparent_part
or rb.lcd_bitmap_part -- Fallback version for grayscale targets
or rb.lcd_mono_bitmap_part -- Fallback version for mono targets
rb.lcd_clear_display()
func(img, imgx, imgy, img:width(), x, y, img:width(), img:height())
end
local src_bmp = backdrop
if (src_bmp) then
local sx = 0
-- local sy = 0
local last_sx = 0
local last_sy = 0
for sy = (rb.LCD_HEIGHT / 10), rb.LCD_HEIGHT do
--NOTE 'sy' is local to only this for loop
if (sy > 10) then
sx = sx + (rb.LCD_WIDTH / rb.LCD_HEIGHT + rb.LCD_HEIGHT / rb.LCD_WIDTH)
if (sx > rb.LCD_WIDTH - src_bmp:width()) then sx = rb.LCD_WIDTH - src_bmp:width() end
end
draw_image(src_bmp, sx, sy)
if(rb.lcd_update_rect) then
rb.lcd_update_rect(last_sx, last_sy, sx + src_bmp:width(), sy + src_bmp:height())
last_sx = sx
last_sy = sy
else
rb.lcd_update()
end
end
--and back...
sx = rb.LCD_WIDTH
for sy=rb.LCD_HEIGHT, 0, -1 do
--NOTE 'sy' is local to only this for loop
if (sy > 10) then
sx = sx - (rb.LCD_WIDTH / rb.LCD_HEIGHT + rb.LCD_HEIGHT / rb.LCD_WIDTH)
if (sx < 0) then sx = 0 end
end
draw_image(src_bmp, sx, sy)
if(rb.lcd_update_rect) then
rb.lcd_update_rect(last_sx, last_sy, sx + src_bmp:width(), sy + src_bmp:height())
last_sx = sx
last_sy = sy
else
rb.lcd_update()
end
end
end