Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
 summaryrefslogtreecommitdiffstats log msg author committer range
path: root/TurtleArt/tacanvas.py
diff options
 context: 12345678910152025303540 space: includeignore mode: unifiedssdiff
author committer Walter Bender 2013-01-23 18:51:12 (GMT) Walter Bender 2013-01-23 18:51:12 (GMT) cd76414ef0f9e3903296b373889e864475cc19aa (patch) 56abcbc1e5494beaafe1783e0d480d7ae467bc7a /TurtleArt/tacanvas.py 8aaec7024ac8d0e5a25fac174b32a6d851f19a5c (diff)
catch some potential zero divide situations
Diffstat (limited to 'TurtleArt/tacanvas.py')
-rw-r--r--TurtleArt/tacanvas.py18
1 files changed, 5 insertions, 13 deletions
 diff --git a/TurtleArt/tacanvas.py b/TurtleArt/tacanvas.pyindex 1272b6b..1aac790 100644--- a/TurtleArt/tacanvas.py+++ b/TurtleArt/tacanvas.py@@ -49,18 +49,10 @@ def wrap100(n): def calc_shade(c, s, invert=False): ''' Convert a color to the current shade (lightness/darkness). ''' # Assumes 16 bit input values- ''' if invert:- if s < 0:- return int(c / (1 + s * 0.8))- return int((c - 65536 * s * 0.9) / (1 - (s * 0.9)))- else:- if s < 0:- return int(c * (1 + s * 0.8))- return int(c + (65536 - c) * s * 0.9)- '''- if invert:- if s < 0:+ if s == -1:+ return int(c)+ elif s < 0: return int(c / (1 + s)) return int((c - 65536 * s) / (1 - s)) else:@@ -73,10 +65,10 @@ def calc_gray(c, g, invert=False): ''' Gray is a psuedo saturation calculation. ''' # Assumes 16 bit input values if g == 100:- return c+ return int(c) if invert: if g == 0:- return c+ return int(c) else: return int(((c * 100) - (32768 * (100 - g))) / g) else: