From 902f34395f843f34c787a650f4d64ae3ab2f2152 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Thu, 19 Apr 2012 00:28:45 -0400 Subject: [PATCH] Reduce the amount of file I/O and the number of image files we need --- ui/res/{go_ul.png => go_corner.png} | Bin ui/res/go_d.png | Bin 656 -> 0 bytes ui/res/go_dl.png | Bin 1113 -> 0 bytes ui/res/go_dr.png | Bin 1114 -> 0 bytes ui/res/{go_u.png => go_edge.png} | Bin ui/res/go_l.png | Bin 666 -> 0 bytes ui/res/go_r.png | Bin 665 -> 0 bytes ui/res/go_ur.png | Bin 1108 -> 0 bytes widgets/gogame.py | 45 ++++++++++------------------ 9 files changed, 16 insertions(+), 29 deletions(-) rename ui/res/{go_ul.png => go_corner.png} (100%) delete mode 100644 ui/res/go_d.png delete mode 100644 ui/res/go_dl.png delete mode 100644 ui/res/go_dr.png rename ui/res/{go_u.png => go_edge.png} (100%) delete mode 100644 ui/res/go_l.png delete mode 100644 ui/res/go_r.png delete mode 100644 ui/res/go_ur.png diff --git a/ui/res/go_ul.png b/ui/res/go_corner.png similarity index 100% rename from ui/res/go_ul.png rename to ui/res/go_corner.png diff --git a/ui/res/go_d.png b/ui/res/go_d.png deleted file mode 100644 index f14f6b1fc914f47e29b0e2dad14912ecda3650d0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 656 zcmeAS@N?(olHy`uVBq!ia0y~yV0;L|EX+WW)hW`pK#H+A$lZxy-8q?;K#pR7Plzj! z&QJCK_;8<{nd;l?EAMQM*|8w^-0sQGPIN44aryT8isR=Sbs(Kd-tI089jvk*Kn`bt zM`SSr1Gg{;GcwGYBLNg-FY)wsWxvD1!D7nk`a??;sON>Ji(^Q|t+zK83Nk40usC}4 zEY#;|$_w1$(6-_Ff%CWW|JGgfGfti}V_1S8xf@kHCjpVxHoNQ;o9dOUhQkpQ>V9P7 Y{;ch~yq)hBFc~m-y85}Sb4q9e0NUO30{{R3 diff --git a/ui/res/go_dl.png b/ui/res/go_dl.png deleted file mode 100644 index ce5e48de8e6220d21a2853ec84f136629e9f782a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1113 zcmeAS@N?(olHy`uVBq!ia0y~yV0;L|9LzwGyeZ#ofD~hKkh>GZx^prwfgG~{pAc6d zouBIe@!`I=*H^aWSm>w-^YgIZ*&K6j_vB|MI`+>ASk&U;Wh1{~g4eg#S0X%AtqmmQ zBzX6Ro5q2ROY(MiVd!9$^#F1>3p^r=85p>QL70(Y)*K0-AbW|YuPgf<77i8*EB`iA zKL!ToIi4<#Ar-gY-Z;qHV8Fw2&_-b*N5_Tw%_0u0bJDFhxP3dEJ0)XVzNwmguR-FW z7EWO`pBbZ!;Tj14`U|FVU`Fx(ujTF*d*&8Ym_PhrcIc(bP0l+XkKRzP>i diff --git a/ui/res/go_dr.png b/ui/res/go_dr.png deleted file mode 100644 index fd529dc90fc319ff26071b5297796e76d7e05fe0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1114 zcmeAS@N?(olHy`uVBq!ia0y~yV0;L|9LzwGyeZ#ofD~hKkh>GZx^prwfgG~{pAc6d zouBIe@!`I=*H^aWSm>w-^YgIZ*&K6j_vB|MI?k;K+dn5@QHzV0jr_OQS0X%AtqmmQ zBzP;9itvJrOY(MiVd!9$^#F1>3p^r=85p>QL70(Y)*K0-AbW|YuPgf<77i9GWy#zB zc^DX&=X$z0hE&{od*w7|LjaG<#q9yibpgNg!(yTvXBJy?w4Yqjb8NfqlcGZ{oWg28 zGYk?(8N)OX?mYZ7g#$|*|BKdsc<-+3j&k;g&wN{|%S9hv)0KXB?|`PgRp^hd$buyw zYM$}@5WRPK)dsiD4IJGNWRNH*219B(hm;`5C!)m_hB%=rH*g5URf;9TR07o_6wiPg yi>w%7tj-~Xv91WkL(L7{NDe-vv}XTThJV|R|DD#p*#($)89ZJ6T-G@yGywp(^m~l} diff --git a/ui/res/go_u.png b/ui/res/go_edge.png similarity index 100% rename from ui/res/go_u.png rename to ui/res/go_edge.png diff --git a/ui/res/go_l.png b/ui/res/go_l.png deleted file mode 100644 index fb4ea55de2fe775d5711d10550c748a51ff3cb3f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 666 zcmeAS@N?(olHy`uVBq!ia0y~yV0;L|EX+WW)hW`pK#H+A$lZxy-8q?;K#pR7Plzj! z&QJCK_;8<{nd;l?EAMQM*|8w^-0sQGPIN44aryT8isR=Sbs(Kd-tI089jvk*Kn`bt zM`SSr1Gg{;GcwGYBLNg-FY)wsWxvD1!D7JR7@YP6sOOWXi(^Q|t+zK83Nk40upFGy zv2cCFF4v2WYL0JAKWzS%{C)aIDT#PTpJ54N)a?E~T~ncwgbvQj84gSEG5rzuJ(pYq T-wr`gnq%;E^>bP0l+XkK2q?L8 diff --git a/ui/res/go_r.png b/ui/res/go_r.png deleted file mode 100644 index 0baa3354e5ed88543884122f928e502ecaaa09cc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 665 zcmeAS@N?(olHy`uVBq!ia0y~yV0;L|EX+WW)hW`pK#H+A$lZxy-8q?;K#pR7Plzj! z&QJCK_;8<{nd;l?EAMQM*|8w^-0sQGPIN44aryT8isR=Sbs(Kd-tI089jvk*Kn`bt zM`SSr1Gg{;GcwGYBLNg-FY)wsWxvD1!D47oH!)ojsOO`ni(^Q|t+zKe@-is!Fdyuh zp;mn{V1urxwu;cM_yfDH1^!Ll^X-U*;cx^W;~!nVKTEXV%?Aye=g-3 Vbewv85ttqrJYD@<);T3K0RZxWn|=TQ diff --git a/ui/res/go_ur.png b/ui/res/go_ur.png deleted file mode 100644 index de238a16b47b91ef41e1e08ec8c193fc5f343624..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1108 zcmeAS@N?(olHy`uVBq!ia0y~yV0;L|9LzwGyeZ#ofD~hKkh>GZx^prwfgG~{pAc6d zouBIe@!`I=*H^aWSm>w-^YgIZ*&K6j_vB|MI?k;K+dn5@QHzV0jr_OQS0X%AtqmmQ zBzP;9itvJrOY(MiVd!9$^#F1>3p^r=85p>QL70(Y)*K0-AbW|YuPgf<77iA35s?!r zehduE(>+}rLn>~)y>XDY!GMS5pbe9Uir|I%&083s-xSJIvA@HYdfmq%qQw=0W^CZ- zh9P0GL_r8r(>bIBLok&QEu3(b-3Bm~K=la4K5%1^6(fulOGFr}giuV98)i4aoI7xi za7DP-AW@a;eAe8nEw8_>@w3=lEx?!mzU6W!`@=8Jz7~7^EcSF4R7gMk!m-?(Q&`Ps zhC$+?76jve$c}gK`%uL&RgH=uhuM$}jei;XrE8A=HJCB^05I1wc)I$ztaD0e0sv$o Bbm0I1 diff --git a/widgets/gogame.py b/widgets/gogame.py index 6fd6755..bb4af9c 100644 --- a/widgets/gogame.py +++ b/widgets/gogame.py @@ -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