@@ -174,7 +174,7 @@ def __init__(self, display=None, scale=1):
174174 i += 1
175175 else :
176176 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 )
178178 self ._bg_palette = displayio .Palette (1 )
179179 self ._bg_palette [0 ] = Color .colors [self ._bg_color ]
180180 self ._bg_sprite = displayio .TileGrid (self ._bg_bitmap ,
@@ -260,8 +260,9 @@ def forward(self, distance):
260260 :param distance: how far to move (integer or float)
261261 """
262262 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
265266 self .goto (x1 , y1 )
266267 fd = forward
267268
@@ -426,7 +427,7 @@ def home(self):
426427 self .setheading (90 )
427428 self .goto (0 , 0 )
428429
429- # pylint:disable=too-many-locals
430+ # pylint:disable=too-many-locals, too-many-statements, too-many-branches
430431 def _plot (self , x , y , c ):
431432 if self ._pensize == 1 :
432433 try :
@@ -435,8 +436,9 @@ def _plot(self, x, y, c):
435436 except IndexError :
436437 pass
437438 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 ))
440442 x0 = x + sin * r
441443 x1 = x - sin * (self ._pensize - r )
442444 y0 = y - cos * r
@@ -501,7 +503,7 @@ def _plot(self, x, y, c):
501503 x0 -= 1
502504 else :
503505 x0 += 1
504- # pylint:enable=too-many-locals
506+ # pylint:enable=too-many-locals, too-many-statements, too-many-branches
505507
506508 def circle (self , radius , extent = None , steps = None ):
507509 """Draw a circle with given radius. The center is radius units left of
@@ -718,9 +720,6 @@ def towards(self, x1, y1=None):
718720 result = math .degrees (math .atan2 (x1 - x0 , y1 - y0 ))
719721 result /= self ._degreesPerAU
720722 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 )))
724723
725724 def xcor (self ):
726725 """Return the turtle's x coordinate."""
@@ -749,7 +748,7 @@ def distance(self, x1, y1=None):
749748 y1 = x1 [1 ]
750749 x1 = x1 [0 ]
751750 x0 , y0 = self .pos ()
752- return ( math .sqrt ((x0 - x1 )** 2 + (y0 - y1 )** 2 ) )
751+ return math .sqrt ((x0 - x1 ) ** 2 + (y0 - y1 ) ** 2 )
753752
754753 ###########################################################################
755754 # Setting and measurement
@@ -1004,6 +1003,7 @@ def isvisible(self):
10041003 return True
10051004 return False
10061005
1006+ # pylint:disable=too-many-statements, too-many-branches
10071007 def changeturtle (self , source = None , dimensions = (12 , 12 )):
10081008 """
10091009 Change the turtle.
@@ -1053,7 +1053,8 @@ def changeturtle(self, source=None, dimensions=(12, 12)):
10531053 raise
10541054 self ._turtle_odb_use += 1
10551055 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 ())
10571058
10581059 if self ._turtle_group :
10591060 self ._turtle_group .pop ()
@@ -1074,6 +1075,7 @@ def changeturtle(self, source=None, dimensions=(12, 12)):
10741075 self ._drawturtle ()
10751076 else :
10761077 raise TypeError ('Argument must be "str", a "displayio.TileGrid" or nothing.' )
1078+ # pylint:enable=too-many-statements, too-many-branches
10771079
10781080 ###########################################################################
10791081 # Other
@@ -1126,6 +1128,5 @@ def _GCD(self, a, b):
11261128 recursive 'Greatest common divisor' calculus for int numbers a and b"""
11271129 if b == 0 :
11281130 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