Activities/Turtle Art/Patching: Difference between revisions

Line 14: Line 14:


==The steps==
==The steps==
* I looked at the Turtle Art program installed in Activity/TurtleArt.activity and determined where I needed to make changes. I had to add a new primitive for square root to the talogo.py file (and also include the sqrt function from the Python math module. And I had to define a new brick for square root in tasetup.py and describe the bricks attributes: its size; how it connects to other bricks; and default values. Finally, I had to create a graphic for the brick (images/en/numbers/sqrt.gif) and modify the panel for numbers (images/en/numbers/numbersgroup,gif and numbersmask.gif). I made similar changes to the Spanish version (images/es).
* I looked at the Turtle Art program installed in Activity/TurtleArt.activity and determined where I needed to make changes. I had to add a new primitive for square root to the talogo.py file (and also include the sqrt function from the Python math module.  
from math import sqrt
    defprim(lc,'sqrt', 1, lambda lc,x: int(sqrt(x)))
* And I had to define a new brick for square root in tasetup.py and describe the bricks attributes: its size; how it connects to other bricks; and default values.  
    ('sqrt','sqrt','sqrt',100),
and
  'sqrt':    (('num',True,0,20),('num',False,42,20)),
* Finally, I had to create a graphic for the brick (images/en/numbers/sqrt.gif) and modify the panel for numbers (images/en/numbers/numbersgroup,gif and numbersmask.gif). I made similar changes to the Spanish version (images/es).
* I ran the modified Turtle Art program and made changes until I managed to get it working properly--i.e., I debugged my code. At one point, I sent email to the maintainer with a question, which he promptly answered.
* I ran the modified Turtle Art program and made changes until I managed to get it working properly--i.e., I debugged my code. At one point, I sent email to the maintainer with a question, which he promptly answered.
* In order to push my changes upstream so that others can use them, first I needed to get a local copy of the source code
* In order to push my changes upstream so that others can use them, first I needed to get a local copy of the source code