@@ -174,7 +174,7 @@ def __init__(self, display=None, scale=1):
174
174
i += 1
175
175
else :
176
176
self ._bgscale = self ._GCD (self ._w , self ._h )
177
- self ._bg_bitmap = displayio .Bitmap (self ._w // self ._bgscale , self ._h // self ._bgscale , 1 )
177
+ self ._bg_bitmap = displayio .Bitmap (self ._w // self ._bgscale , self ._h // self ._bgscale , 1 )
178
178
self ._bg_palette = displayio .Palette (1 )
179
179
self ._bg_palette [0 ] = Color .colors [self ._bg_color ]
180
180
self ._bg_sprite = displayio .TileGrid (self ._bg_bitmap ,
@@ -260,8 +260,9 @@ def forward(self, distance):
260
260
:param distance: how far to move (integer or float)
261
261
"""
262
262
p = self .pos ()
263
- x1 = p [0 ] + math .sin (math .radians ((self ._angleOffset + self ._angleOrient * self ._heading ) % self ._fullcircle )) * distance
264
- y1 = p [1 ] + math .cos (math .radians ((self ._angleOffset + self ._angleOrient * self ._heading ) % self ._fullcircle )) * distance
263
+ angle = (self ._angleOffset + self ._angleOrient * self ._heading ) % self ._fullcircle
264
+ x1 = p [0 ] + math .sin (math .radians (angle )) * distance
265
+ y1 = p [1 ] + math .cos (math .radians (angle )) * distance
265
266
self .goto (x1 , y1 )
266
267
fd = forward
267
268
@@ -426,7 +427,7 @@ def home(self):
426
427
self .setheading (90 )
427
428
self .goto (0 , 0 )
428
429
429
- # pylint:disable=too-many-locals
430
+ # pylint:disable=too-many-locals, too-many-statements, too-many-branches
430
431
def _plot (self , x , y , c ):
431
432
if self ._pensize == 1 :
432
433
try :
@@ -435,8 +436,9 @@ def _plot(self, x, y, c):
435
436
except IndexError :
436
437
pass
437
438
r = self ._pensize // 2 + 1
438
- sin = math .sin (math .radians ((self ._angleOffset + self ._angleOrient * self ._heading - 90 ) % self ._fullcircle ))
439
- cos = math .cos (math .radians ((self ._angleOffset + self ._angleOrient * self ._heading - 90 ) % self ._fullcircle ))
439
+ angle = (self ._angleOffset + self ._angleOrient * self ._heading - 90 ) % self ._fullcircle
440
+ sin = math .sin (math .radians (angle ))
441
+ cos = math .cos (math .radians (angle ))
440
442
x0 = x + sin * r
441
443
x1 = x - sin * (self ._pensize - r )
442
444
y0 = y - cos * r
@@ -501,7 +503,7 @@ def _plot(self, x, y, c):
501
503
x0 -= 1
502
504
else :
503
505
x0 += 1
504
- # pylint:enable=too-many-locals
506
+ # pylint:enable=too-many-locals, too-many-statements, too-many-branches
505
507
506
508
def circle (self , radius , extent = None , steps = None ):
507
509
"""Draw a circle with given radius. The center is radius units left of
@@ -718,9 +720,6 @@ def towards(self, x1, y1=None):
718
720
result = math .degrees (math .atan2 (x1 - x0 , y1 - y0 ))
719
721
result /= self ._degreesPerAU
720
722
return (self ._angleOffset + self ._angleOrient * result ) % self ._fullcircle
721
- if self ._logomode :
722
- return (math .degrees (math .atan2 (x0 - x1 , y0 - y1 )))
723
- return (math .degrees (math .atan2 (y0 - y1 , x0 - x1 )))
724
723
725
724
def xcor (self ):
726
725
"""Return the turtle's x coordinate."""
@@ -749,7 +748,7 @@ def distance(self, x1, y1=None):
749
748
y1 = x1 [1 ]
750
749
x1 = x1 [0 ]
751
750
x0 , y0 = self .pos ()
752
- return ( math .sqrt ((x0 - x1 )** 2 + (y0 - y1 )** 2 ) )
751
+ return math .sqrt ((x0 - x1 ) ** 2 + (y0 - y1 ) ** 2 )
753
752
754
753
###########################################################################
755
754
# Setting and measurement
@@ -1004,6 +1003,7 @@ def isvisible(self):
1004
1003
return True
1005
1004
return False
1006
1005
1006
+ # pylint:disable=too-many-statements, too-many-branches
1007
1007
def changeturtle (self , source = None , dimensions = (12 , 12 )):
1008
1008
"""
1009
1009
Change the turtle.
@@ -1053,7 +1053,8 @@ def changeturtle(self, source=None, dimensions=(12, 12)):
1053
1053
raise
1054
1054
self ._turtle_odb_use += 1
1055
1055
self ._turtle_pic = True
1056
- self ._turtle_alt_sprite = displayio .TileGrid (self ._turtle_odb , pixel_shader = displayio .ColorConverter ())
1056
+ self ._turtle_alt_sprite = displayio .TileGrid (self ._turtle_odb ,
1057
+ pixel_shader = displayio .ColorConverter ())
1057
1058
1058
1059
if self ._turtle_group :
1059
1060
self ._turtle_group .pop ()
@@ -1074,6 +1075,7 @@ def changeturtle(self, source=None, dimensions=(12, 12)):
1074
1075
self ._drawturtle ()
1075
1076
else :
1076
1077
raise TypeError ('Argument must be "str", a "displayio.TileGrid" or nothing.' )
1078
+ # pylint:enable=too-many-statements, too-many-branches
1077
1079
1078
1080
###########################################################################
1079
1081
# Other
@@ -1126,6 +1128,5 @@ def _GCD(self, a, b):
1126
1128
recursive 'Greatest common divisor' calculus for int numbers a and b"""
1127
1129
if b == 0 :
1128
1130
return a
1129
- else :
1130
- r = a % b
1131
- return self ._GCD (b , r )
1131
+ r = a % b
1132
+ return self ._GCD (b , r )
0 commit comments