diff options
Diffstat (limited to 'TurtleArt')
-rw-r--r-- | TurtleArt/tablock.py | 26 | ||||
-rwxr-xr-x | TurtleArt/tasprite_factory.py | 14 |
2 files changed, 39 insertions, 1 deletions
diff --git a/TurtleArt/tablock.py b/TurtleArt/tablock.py index 2658624..8d8ed4a 100644 --- a/TurtleArt/tablock.py +++ b/TurtleArt/tablock.py @@ -125,7 +125,31 @@ class Blocks: class Block: - """ A class for the individual blocks """ + """ A class for the individual blocks + + Attributes: + docks -- a list of docks, i.e. connection points where other blocks + could be attached. Each dock is a list of the form + [type_of_dock, flow_is_in, x, y, parenthesis] + with the last element being optional. + type_of_dock may be one of the following strings: + flow -- connect to the previous or next block ('slot' or 'tab') + bool, media, number, string -- argument slot ('innie') or + return value ('outie') of the given kind + unavailable -- nothing can be attached here ('cap' or 'tail') + flow_is_in is True if the flow is into the block, or False for out. + x and y are coodinates for positioning the block on the dock. + parenthesis is only used with arguments and ensures a known order + of arguments for arithmetic and logical operations. + connections -- a list of blocks that are attached to this one (or that + this one is attached to). This list corresponds to the docks list + as it uses the same indices. Slots where nothing is attached are + None on this list. + primitive -- a callable that is called when the block is executed + type -- type of the block: + block -- block that is part of the user's program + proto -- block on a palette, used to generate other blocks + trash -- block in the trash """ def __init__(self, block_list, sprite_list, name, x, y, type='block', values=[], scale=BLOCK_SCALE[0], diff --git a/TurtleArt/tasprite_factory.py b/TurtleArt/tasprite_factory.py index d44a9e2..2bd8993 100755 --- a/TurtleArt/tasprite_factory.py +++ b/TurtleArt/tasprite_factory.py @@ -30,6 +30,20 @@ from taconstants import HIT_RED, HIT_GREEN, HIDE_WHITE, SHOW_WHITE, \ class SVG: + """ Interface to the graphical representation of blocks, turtles, + palettes, etc. on screen + + terms used here: + docks -- list of connection points of a block to other blocks + innies -- right hand side docks of a block, argument slots + outie -- left hand side dock of a block + slot -- top dock of a block that can be attached to other blocks + cap -- top dock of a block that cannot be attached to other blocks + tab -- bottom dock of a block if other blocks can be attached + tail -- bottom dock of a block if no other blocks can be attached + arm -- connection point of a branching block (if-then, loops) where + inner blocks are attached + else -- optional second `arm' for if-then-else blocks """ def __init__(self): self._x = 0 |