summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2009-06-15 13:30:03 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2009-06-15 13:30:03 +0000
commite55bdff3509fa978f4a8c9b7a62c662bba401d33 (patch)
tree8e9875b46c7d6631cc4aa080e7c2e0e791a49755 /apps/plugins
parent33c87e08e5617c75e164fc18316264af2f94d64d (diff)
downloadrockbox-e55bdff3509fa978f4a8c9b7a62c662bba401d33.tar.gz
rockbox-e55bdff3509fa978f4a8c9b7a62c662bba401d33.zip
Fix helloworld.lua on grayscale targets
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21290 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/helloworld.lua26
1 files changed, 18 insertions, 8 deletions
diff --git a/apps/plugins/helloworld.lua b/apps/plugins/helloworld.lua
index fcdd4de026..047e31a644 100644
--- a/apps/plugins/helloworld.lua
+++ b/apps/plugins/helloworld.lua
@@ -32,7 +32,12 @@ end
32-- Helper function which draws a transparent image at the center of the screen 32-- Helper function which draws a transparent image at the center of the screen
33function draw_image(img) 33function draw_image(img)
34 local x, y = (rb.LCD_WIDTH - img:width()) / 2, (rb.LCD_HEIGHT - img:height()) / 2 34 local x, y = (rb.LCD_WIDTH - img:width()) / 2, (rb.LCD_HEIGHT - img:height()) / 2
35 rb.lcd_bitmap_transparent_part(img, 0, 0, img:width(), x, y, img:width(), img:height()) 35
36 local func = rb.lcd_bitmap_transparent_part
37 if(func == nil) then
38 func = rb.lcd_bitmap_part -- Fallback version for mono targets
39 end
40 func(img, 0, 0, img:width(), x, y, img:width(), img:height())
36 rb.lcd_update() 41 rb.lcd_update()
37end 42end
38 43
@@ -99,18 +104,23 @@ rb.lcd_clear_display()
99rb.lcd_drawline(0, 0, rb.LCD_WIDTH, rb.LCD_HEIGHT) 104rb.lcd_drawline(0, 0, rb.LCD_WIDTH, rb.LCD_HEIGHT)
100rb.lcd_drawline(rb.LCD_WIDTH, 0, 0, rb.LCD_HEIGHT) 105rb.lcd_drawline(rb.LCD_WIDTH, 0, 0, rb.LCD_HEIGHT)
101 106
102local rectangle = rb.new_image(10, 15) -- Create a new image with width 10 and height 15 107if(rb.lcd_rgbpack ~= nil) then -- Only do this when we're on a color target, i.e. when LCD_RGBPACK is available
103for i=1, 10 do 108 local rectangle = rb.new_image(10, 15) -- Create a new image with width 10 and height 15
104 for j=1, 15 do 109 for i=1, 10 do
105 rectangle:set(i, j, rb.lcd_rgbpack(200, i*20, j*20)) -- Set the pixel at position i, j to the specified color 110 for j=1, 15 do
111 rectangle:set(i, j, rb.lcd_rgbpack(200, i*20, j*20)) -- Set the pixel at position i, j to the specified color
112 end
106 end 113 end
107end
108 114
109-- rb.lcd_bitmap_part(src, src_x, src_y, stride, x, y, width, height) 115 -- rb.lcd_bitmap_part(src, src_x, src_y, stride, x, y, width, height)
110rb.lcd_bitmap_part(rectangle, 0, 0, 10, rb.LCD_WIDTH/2-5, rb.LCD_HEIGHT/10-1, 10, 10) -- Draws our rectangle at the top-center of the screen 116 rb.lcd_bitmap_part(rectangle, 0, 0, 10, rb.LCD_WIDTH/2-5, rb.LCD_HEIGHT/10-1, 10, 10) -- Draws our rectangle at the top-center of the screen
117end
111 118
112-- Load a BMP file in the variable backdrop 119-- Load a BMP file in the variable backdrop
113local backdrop = rb.read_bmp_file("/.rockbox/icons/tango_small_viewers.bmp") -- This image should always be present? 120local backdrop = rb.read_bmp_file("/.rockbox/icons/tango_small_viewers.bmp") -- This image should always be present?
121if(backdrop == nil) then
122 backdrop = rb.read_bmp_file("/.rockbox/icons/tango_small_viewers_mono.bmp") -- Try using the mono version
123end
114-- Draws the image using our own draw_image() function; see up 124-- Draws the image using our own draw_image() function; see up
115draw_image(backdrop) 125draw_image(backdrop)
116 126