Mercurial > rinkhals
changeset 160:8a11bbafa07f
Add support for creting xbm cursors
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Thu, 03 Sep 2009 22:15:35 +0000 |
parents | 7bb8d9d6858a |
children | 9b4213f6ea7f |
files | data/cursors/chkn.xbm data/cursors/egg.xbm data/cursors/equip_knife.xbm data/cursors/equip_rifle.xbm regenerate-pngs.py |
diffstat | 5 files changed, 52 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/cursors/chkn.xbm Thu Sep 03 22:15:35 2009 +0000 @@ -0,0 +1,7 @@ +#define im_width 16 +#define im_height 16 +static char im_bits[] = { +0x1c,0x00,0x3c,0x3c,0x3e,0x7c,0x7c,0x7c,0xf8,0x3f,0xf8,0x7f,0xf8,0x3f,0xfc, +0x3f,0xfc,0x3f,0xf8,0x1f,0xf8,0x1f,0xe0,0x1f,0xc0,0x0f,0x80,0x07,0xc0,0x07, +0xe0,0x01 +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/cursors/egg.xbm Thu Sep 03 22:15:35 2009 +0000 @@ -0,0 +1,7 @@ +#define im_width 16 +#define im_height 16 +static char im_bits[] = { +0xf8,0x03,0xfc,0x07,0xfe,0x0f,0xfe,0x0f,0xff,0x1f,0xff,0x1f,0xff,0x1f,0xff, +0x1f,0xff,0x1f,0xff,0x1f,0xff,0x1f,0xff,0x1f,0xff,0x1f,0xfe,0x0f,0xfc,0x07, +0xf8,0x03 +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/cursors/equip_knife.xbm Thu Sep 03 22:15:35 2009 +0000 @@ -0,0 +1,7 @@ +#define im_width 16 +#define im_height 16 +static char im_bits[] = { +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x18,0xe0, +0x1f,0xff,0x0f,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00 +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/cursors/equip_rifle.xbm Thu Sep 03 22:15:35 2009 +0000 @@ -0,0 +1,7 @@ +#define im_width 16 +#define im_height 16 +static char im_bits[] = { +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x18,0xc0, +0x1f,0xff,0x0f,0xfe,0xff,0x00,0xf0,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00 +};
--- a/regenerate-pngs.py Thu Sep 03 22:00:28 2009 +0000 +++ b/regenerate-pngs.py Thu Sep 03 22:15:35 2009 +0000 @@ -3,6 +3,7 @@ import cairo import rsvg import os +from Image import open def svg_to_png(svg_name, png_name, w, h): """Convert an SVG file to a PNG file.""" @@ -35,10 +36,24 @@ png_name = os.path.join(sprite_path, name) + ".png" svg_to_png(svg_name, png_name, width, height) +def process_cursor(name, width, height, sprite_path, cursor_path): + # We bounce through png to get something PIL understands + svg_name = os.path.join(sprite_path, name) + '.svg' + png_name = os.path.join(cursor_path, name) + '.png' + xbm_name = os.path.join(cursor_path, name) + '.xbm' + svg_to_png(svg_name, png_name, width, height) + # We need to bounce through 'L' first to handle transparency OK + pixeldata = open(png_name).convert('L') + # Everything > 0 goes to white + lut = [0] + [1]*255 + pixeldata.point(lut, mode='1').save(xbm_name) + os.remove(png_name) + if __name__ == "__main__": tile_path = "data/tiles" sprite_path = "data/sprites" image_path = "data/images" + cursor_path = "data/cursors" sprites = [ ("chkn", 20, 20), ("select_chkn", 20, 20), @@ -62,6 +77,13 @@ ("emptynest", 20, 20), ] + cursors = [ + ("chkn", 16, 16), + ("equip_knife", 16, 16), + ("equip_rifle", 16, 16), + ("egg", 16, 16), + ] + process_svg_folder("data/tiles", 20, 20) process_svg_folder("data/icons", 40, 40) for name, width, height in sprites: @@ -69,3 +91,5 @@ process_sprite("splash", 800, 600, image_path) process_sprite("gameover_win", 800, 600, image_path) process_sprite("gameover_lose", 800, 600, image_path) + for name, width, height in cursors: + process_cursor(name, width, height, sprite_path, cursor_path)