mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
* improved mahjongg tile highlighting
git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@202 39dd0a4e-7c14-0410-91b3-c4f2d318f732
This commit is contained in:
parent
1464034191
commit
95655910b2
4 changed files with 20 additions and 9 deletions
|
@ -83,7 +83,7 @@ class Mahjongg_Hint(AbstractHint):
|
|||
len(rb.all_left) + len(rb.all_right) + \
|
||||
len(tb.all_left) + len(tb.all_right)
|
||||
self.addHint(score, 1, r, t)
|
||||
i = i + 1
|
||||
i += 1
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
|
@ -899,12 +899,15 @@ a solvable configuration.'''),
|
|||
assert c1 in s.cards
|
||||
tkraise = False
|
||||
x, y = s.x, s.y
|
||||
img = self.app.images.getShadowCard(c1.deck, c1.suit, c1.rank)
|
||||
img = self.app.images.getHighlightCard(c1.deck, c1.suit, c1.rank)
|
||||
if img is None:
|
||||
continue
|
||||
img = MfxCanvasImage(self.canvas, x, y, image=img,
|
||||
anchor=ANCHOR_NW, group=s.group)
|
||||
img.tkraise(c1.item)
|
||||
if self.drag.stack and s is self.drag.stack:
|
||||
img.tkraise(self.drag.shade_img)
|
||||
else:
|
||||
img.tkraise(c1.item)
|
||||
items.append(img)
|
||||
if not items:
|
||||
return 0
|
||||
|
|
|
@ -90,6 +90,7 @@ class Images:
|
|||
self._xshadow = []
|
||||
self._shade = []
|
||||
self._shadow_cards = {} # key: (suit, rank)
|
||||
self._highlight_cards = {} # for mahjongg
|
||||
self._shadow_back = None
|
||||
self._pil_shadow = {} # key: (width, height)
|
||||
self._pil_shadow_image = None
|
||||
|
@ -375,6 +376,17 @@ class Images:
|
|||
return self.getShade()
|
||||
return shade
|
||||
|
||||
def getHighlightCard(self, deck, suit, rank):
|
||||
if (suit, rank) in self._highlight_cards:
|
||||
shade = self._highlight_cards[(suit, rank)]
|
||||
else:
|
||||
image = self.getFace(deck, suit, rank)
|
||||
shade = shadowImage(image, color='black', factor=0.3)
|
||||
self._highlight_cards[(suit, rank)] = shade
|
||||
if not shade:
|
||||
return self.getShade()
|
||||
return shade
|
||||
|
||||
def getShadowBack(self):
|
||||
if self._shadow_back:
|
||||
return self._shadow_back
|
||||
|
|
|
@ -345,12 +345,10 @@ def createImage(width, height, fill, outline=None):
|
|||
fillImage(image, fill, outline)
|
||||
return image
|
||||
|
||||
def shadowImage(image):
|
||||
def shadowImage(image, color='#3896f8', factor=0.3):
|
||||
if not hasattr(image, '_pil_image'):
|
||||
return None
|
||||
im = image._pil_image
|
||||
#color, factor = 'black', 0.2
|
||||
color, factor = '#3896f8', 0.3
|
||||
sh = Image.new('RGBA', im.size, color)
|
||||
tmp = Image.blend(im, sh, factor)
|
||||
out = Image.composite(tmp, im, im)
|
||||
|
|
|
@ -345,12 +345,10 @@ def createImage(width, height, fill, outline=None):
|
|||
fillImage(image, fill, outline)
|
||||
return image
|
||||
|
||||
def shadowImage(image):
|
||||
def shadowImage(image, color='#3896f8', factor=0.3):
|
||||
if not hasattr(image, '_pil_image'):
|
||||
return None
|
||||
im = image._pil_image
|
||||
#color, factor = 'black', 0.2
|
||||
color, factor = '#3896f8', 0.3
|
||||
sh = Image.new('RGBA', im.size, color)
|
||||
tmp = Image.blend(im, sh, factor)
|
||||
out = Image.composite(tmp, im, im)
|
||||
|
|
Loading…
Add table
Reference in a new issue