Reduce the amount of file I/O and the number of image files we need

This commit is contained in:
Anna Rose 2012-04-19 00:28:45 -04:00
parent 2fd0523078
commit 902f34395f
9 changed files with 16 additions and 29 deletions

View File

Before

Width:  |  Height:  |  Size: 921 B

After

Width:  |  Height:  |  Size: 921 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 656 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 656 B

After

Width:  |  Height:  |  Size: 656 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -221,14 +221,27 @@ def _build_img_res():
height = ret['bT'].get_height()
triangle.composite(ret['bT'], 0, 0, width, height, 0, 0, 1, 1, gtk.gdk.INTERP_NEAREST, 255)
for d in ('u', 'd', 'l', 'r', 'm', 'dl', 'dr', 'ul', 'ur', 'h', 'w', 'b'):
base = _load_png('go_corner.png')
ret['ul'] = base
ret['dl'] = base.copy().rotate_simple(90)
ret['dr'] = base.copy().rotate_simple(180)
ret['ur'] = base.copy().rotate_simple(270)
base = _load_png('go_edge.png')
ret['u'] = base
ret['l'] = base.copy().rotate_simple(90)
ret['d'] = base.copy().rotate_simple(180)
ret['r'] = base.copy().rotate_simple(270)
for d in ('m', 'h', 'w', 'b'):
ret[d] = _load_png('go_' + d + '.png')
ret[d + 'C'] = _load_png('go_' + d + '.png')
for d in ('u', 'd', 'l', 'r', 'm', 'dl', 'dr', 'ul', 'ur', 'h', 'w', 'b'):
ret[d + 'C'] = ret[d].copy()
width = ret[d + 'C'].get_width()
height = ret[d + 'C'].get_height()
circle.composite(ret[d + 'C'], 0, 0, width, height, 0, 0, 1, 1, gtk.gdk.INTERP_NEAREST, 255)
return ret
@ -237,30 +250,4 @@ def _load_png(name):
fullname = os.path.join('ui/res/', name)
image = gtk.gdk.pixbuf_new_from_file(fullname)
# if alpha is not None:
# image = _set_alpha(image, alpha)
return image
# _trans_png = None
# def _set_alpha(image, alpha):
# """
# change_opacity - changes the opacity of pixbuf by combining
# the pixbuf with a pixbuf derived from a transparent .png
# returns: a pixbuf of image made alpha more composite
# """
# global _trans_png
# if _trans_png == None:
# _trans_png = _load_png('transparent.png')
# width = image.get_width()
# height = image.get_height()
# trans= _trans_png.scale_simple(width,height,gtk.gdk.INTERP_NEAREST)
# trans.composite(image, 0, 0, width, height, 0, 0, 1, 1, gtk.gdk.INTERP_NEAREST, alpha)
# return trans