Activities/Turtle Art: Difference between revisions
| Line 514: | Line 514: | ||
==Looking under the hood== | ==Looking under the hood== | ||
Turtle Art projects are stored as | Turtle Art projects are stored as a .ta file contains a [http://docs.python.org/library/json.html json-encoded] serialization of the project. | ||
The json encoding of a repeat 4 forward 100 right 90 project: | The json encoding of a repeat 4 forward 100 right 90 project: | ||
[[0,"repeat",331,158,[null,1,2,null]],[1,["number","4"],417,167,[0,null]],[2,"forward",426,207,[0,3,4]],[3,["number","100"],500,216,[2,null]],[4,"right",426,246,[2,5,null]],[5,["number","90"],500,255,[4,null]],[-1,"turtle",0,0,0,0,50,5]] | [[0,"repeat",331,158,[null,1,2,null]],[1,["number","4"],417,167,[0,null]],[2,"forward",426,207,[0,3,4]],[3,["number","100"],500,216,[2,null]],[4,"right",426,246,[2,5,null]],[5,["number","90"],500,255,[4,null]],[-1,"turtle",0,0,0,0,50,5]] | ||
The basic structure of the encoding is a list of lists, where each block has these elements: | |||
# block number | |||
# block name or [block name, block value] | |||
# x position (depreciated) | |||
# y position (depreciated) | |||
# list of connections to other blocks | |||
Turtles are encoded at the end of the list: | |||
# -1 | |||
# turtle or [turtle, turtle name] | |||
# x position | |||
# y position | |||
# heading | |||
# pen color | |||
# pen shade | |||
# pen width | |||
==Programmable Brick== | ==Programmable Brick== | ||