mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-06 03:50:06 +01:00
Trim Whitespace lib directory
This commit is contained in:
@@ -43,7 +43,7 @@ Sample usage::
|
||||
|
||||
# Lighter
|
||||
light_colour = stepColour(colour, 120)
|
||||
|
||||
|
||||
app.MainLoop()
|
||||
|
||||
"""
|
||||
@@ -60,10 +60,10 @@ def grayOut(anImage):
|
||||
|
||||
:rtype: :class:`wx.Image`
|
||||
:returns: The modified (greyed out) image.
|
||||
|
||||
|
||||
.. note:: the image is converted in place, i.e. the input image will
|
||||
be modified to a greyed out version.
|
||||
|
||||
|
||||
"""
|
||||
|
||||
factor = 0.7 # 0 < f < 1. Higher is grayer.
|
||||
@@ -75,7 +75,7 @@ def grayOut(anImage):
|
||||
alpha = anImage.GetAlpha()
|
||||
else:
|
||||
alpha = None
|
||||
|
||||
|
||||
data = anImage.GetData()
|
||||
|
||||
for i in range(0, len(data), 3):
|
||||
@@ -86,7 +86,7 @@ def grayOut(anImage):
|
||||
anImage.SetData(data) # ''.join(map(chr, data)))
|
||||
if alpha:
|
||||
anImage.SetAlpha(alpha)
|
||||
|
||||
|
||||
|
||||
def makeGray(rgb, factor, maskColor):
|
||||
"""
|
||||
@@ -98,11 +98,11 @@ def makeGray(rgb, factor, maskColor):
|
||||
:param `maskColor`: the mask colour.
|
||||
|
||||
:type `maskColor`: tuple or :class:`wx.Colour`.
|
||||
|
||||
|
||||
:rtype: tuple
|
||||
:returns: An RGB tuple with the greyed out pixel colour.
|
||||
"""
|
||||
|
||||
|
||||
if rgb != maskColor:
|
||||
return tuple([int((230 - x)*factor) + x for x in rgb])
|
||||
else:
|
||||
@@ -123,7 +123,7 @@ def stepColour(c, step):
|
||||
:rtype: :class:`wx.Colour`
|
||||
:returns: A new colour, darkened or lightened depending on the input `step` value.
|
||||
"""
|
||||
|
||||
|
||||
def _blendColour(fg, bg, dstep):
|
||||
result = bg + (dstep * (fg - bg))
|
||||
if result < 0:
|
||||
@@ -134,18 +134,18 @@ def stepColour(c, step):
|
||||
|
||||
if step == 100:
|
||||
return c
|
||||
|
||||
|
||||
r = c.Red()
|
||||
g = c.Green()
|
||||
b = c.Blue()
|
||||
|
||||
|
||||
# step is 0..200 where 0 is completely black
|
||||
# and 200 is completely white and 100 is the same
|
||||
# convert that to a range of -1.0 .. 1.0
|
||||
step = min(step, 200)
|
||||
step = max(step, 0)
|
||||
dstep = (step - 100.0)/100.0
|
||||
|
||||
|
||||
if step > 100:
|
||||
# blend with white
|
||||
bg = 255.0
|
||||
@@ -154,10 +154,10 @@ def stepColour(c, step):
|
||||
# blend with black
|
||||
bg = 0.0
|
||||
dstep = 1.0 + dstep; # 0 = transparent fg; 1 = opaque fg
|
||||
|
||||
|
||||
r = _blendColour(r, bg, dstep)
|
||||
g = _blendColour(g, bg, dstep)
|
||||
b = _blendColour(b, bg, dstep)
|
||||
|
||||
|
||||
return wx.Colour(int(r), int(g), int(b))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user