MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / mode

Method mode

Python/Turtle.py:933–965  ·  view source on GitHub ↗

Set turtle-mode ('standard', 'logo' or 'world') and perform reset. Optional argument: mode -- one of the strings 'standard', 'logo' or 'world' Mode 'standard' is compatible with turtle.py. Mode 'logo' is compatible with most Logo-Turtle-Graphics. Mode 'world

(self, mode=None)

Source from the content-addressed store, hash-verified

931 Turtle._pen = None
932
933 def mode(self, mode=None):
934 """Set turtle-mode ('standard', 'logo' or 'world') and perform reset.
935
936 Optional argument:
937 mode -- one of the strings 'standard', 'logo' or 'world'
938
939 Mode 'standard' is compatible with turtle.py.
940 Mode 'logo' is compatible with most Logo-Turtle-Graphics.
941 Mode 'world' uses userdefined 'worldcoordinates'. *Attention*: in
942 this mode angles appear distorted if x/y unit-ratio doesn't equal 1.
943 If mode is not given, return the current mode.
944
945 Mode Initial turtle heading positive angles
946 ------------|-------------------------|-------------------
947 'standard' to the right (east) counterclockwise
948 'logo' upward (north) clockwise
949
950 Examples:
951 >>> mode('logo') # resets turtle heading to north
952 >>> mode()
953 'logo'
954 """
955 if mode is None:
956 return self._mode
957 mode = mode.lower()
958 if mode not in ["standard", "logo", "world"]:
959 raise TurtleGraphicsError("No turtle-graphics-mode %s" % mode)
960 self._mode = mode
961 if mode in ["standard", "logo"]:
962 self._setscrollregion(-self.canvwidth//2, -self.canvheight//2,
963 self.canvwidth//2, self.canvheight//2)
964 self.xscale = self.yscale = 1.0
965 self.reset()
966
967 def setworldcoordinates(self, llx, lly, urx, ury):
968 """Set up a user defined coordinate-system.

Callers 2

setworldcoordinatesMethod · 0.95
__init__Method · 0.80

Calls 3

resetMethod · 0.95
TurtleGraphicsErrorClass · 0.85
_setscrollregionMethod · 0.80

Tested by

no test coverage detected