Difference between revisions of "KTurtle/C3/Grammar-of-TurtleScript-Part-II/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
Line 18: Line 18:
 
  || Welcome to the tutorial on Grammar of Turtle Script-Part II.
 
  || Welcome to the tutorial on Grammar of Turtle Script-Part II.
  
|-
+
|-
  
 
|00.06
 
|00.06
  
| |If this is the first time you are using KTurtle, please view the
+
| |If this is the first time you are using KTurtle, please view the
 
  tutorial introduction to KTurtle
 
  tutorial introduction to KTurtle
  
Line 58: Line 58:
 
  | 00.31
 
  | 00.31
  
||This tutorial will introduce some more commands to be used in the KTurtle
+
||This tutorial will introduce some more commands to be used in the KTurtle environment.
environment.
+
  
  
Line 87: Line 86:
 
  | 00.40
 
  | 00.40
  
|For this demonstration, I am using the Linux Operating System Ubuntu
+
||For this demonstration, I am using the Linux Operating System Ubuntu
  v11.04, and Kturtle v0.8.1 beta.
+
  v11.04,and Kturtle v0.8.1 beta.
  
  
Line 95: Line 94:
 
| 00.51
 
| 00.51
  
|| Let us first look at the '''learn '''command.
+
|| Let us first look at the '''learn '''command.
  
  

Latest revision as of 12:22, 10 January 2013

Visual Cue Narration


00.01 Hi everyone,


00.02 Welcome to the tutorial on Grammar of Turtle Script-Part II.
00.06 If this is the first time you are using KTurtle, please view the
tutorial introduction to KTurtle


00.11 which will help you understand the installation and interface of the

application and some of the basic commands to move the turtle.


00.18 Also view the tutorial Grammar of Turtle Script-Part I,


00.22 to understand few more commands that are used in the Kturtle environment.

>

00.26 These tutorials can be viewed on the spoken tutorial website

(www.spoken-tutorials.org).

00.31 This tutorial will introduce some more commands to be used in the KTurtle environment.


00.36 We will learn the


00.37 learn command


00.39 And the random command


00.40 For this demonstration, I am using the Linux Operating System Ubuntu
v11.04,and Kturtle v0.8.1 beta.


00.51 Let us first look at the learn command.


00.54 learn is special as it is used to create your own commands.
00.58 The commands you create can take input and return output.


01.02 Let us take a look at how a new command is created.
01.06 I will launch the Kturtle application


01.11 And Let us enter the following lines of code in the editor to draw a
square:


01.33 here the number 10 specfies the length of the side of the square.


01.40 Now let us learn the commands involved to draw a square using the 'command 'learn .


01.46 We will name this set of commands to draw a square as square.


01.53 The command learn is followed by the name of the command to be learnt,


01.58 in this case it is square.


02.01 So i will enter the command learn before square


02.24 so here the new command that we have defined is called square.
02.30 square takes one input argument, i.e $x to set the size of the square.


02.36 One important point to be noted here is,
02.39 when you run this piece of code, It does not return no output.


02.45 The command learn is just 'learning' the other command
square to be used later.


02.51 The square command can now be used like a normal command in the rest of the code.


02.57 Let me add few more lines of code here.


Type the following code in your editor:


03.09 Let me select Run from the toolbar to run this piece of code from the editor.


03.15 The turtle now draws the square on the canvas.


03.18 The command square can now be used anywhere and any number of times in the program .


03.27 Also Note that this command can be used only within the scope of this program.


03.30 Let us next look at the 'random' Command.'


03.34 random is a command that takes input and gives output.


03.38 The syntax for this command is random X,Y


03.42 where X and Y are two inputs.
03.44 X sets the minimum output and Y sets the maximum.


03.49 The output is a randomly chosen number between X and Y.


03.54 Let us put the random command to use in the application.


03.59 In my editor, I will enter a few lines of code to draw a circle.


04.29 Here, the command random 1,20 selects a random number which is equal or greater than 1 and equal or lesser than 20,


04.41 and assigns it to the variable x.


04.44 When you run this piece of code, a circle with a radius of size, which is in between 1 and 20 is drawn on the canvas.


04.53 Let us execute this code a few times, and you can see that a circle with a different size is generated each time.


05.06 Every time you execute this code, a circle with a different radius is drawn.


05.13 Let us now use both the learn and random commands in an

example.


05.24 Here, i have with me few line of code that demonstrates the use of both the learn and the random command.


05.31 i am going to copy the entire code on to my clipboard and paste it in my editor in the Kturtle application.


05.46 Let us see what each line means here.


05.50 canvassize 300,300' sets the width and height of the canvas to 300
pixels each.


05.58 $R, $G, and $B are three variables to which I am
assigning random values between 0 and 255.


06.07 In the command 'canvascolor $R,$G,$B' ,


06.11 the Red-Green-Blue combination is replaced by the values assigned to the variables R, G, and B in the previous step.


06.20 The canvas color is now set randomly when this command is executed.


06.27 $red, $blue, $green are another set of variables


06.33 to which values between 0 and 255 are assigned randomly.


06.38 Again in the command 'pencolor $red,$blue,$green' the
Red-Green-Blue combination values are replaced by the variables


06.48 $red, $green and $blue to which random values are assigned in the previous step.


06.53 The color of the pen is also set randomly when the command is executed.


06.57 'penwidth 2' sets the width of the pen to 2 pixels.


07.02 I have next entered the code to learn to draw a circle.


07.08 Here $x represents the size of the circle.


07.12 The next set of commands i.e the go commands
07.16 followed by the circle commands draws circles with the specified sizes.


07.23 For example the command circle 5 draws a circle of size 5


07.28 If the co-ordinates X and Y specified in the go commands.


07.33 For each circle, I have specified different positions on the canvas.


07.39 Let us execute this code now.


07.42 I am going to run this execution at full speed.


07.46 But you can select any of the speeds mentioned in the Run option.


07.52 I will run this code few more times, so that you can see the difference in the randomly set values of pen color and canvas color.


08.06 When I execute the code one more time, note the change in the color in the pen and the canvas.


08.19 You can exceute this code how many ever times you want and you can note the change in the randomly set values.


08.31 As an assignment for you to solve,


08.33 using the learn command,


08.35 draw a pentagon, a square, a rectangle, a hexagon on the four corners of your canvas


08.43 and a circle at the centre of the canvas.


08.47 Using the random command create various colors and customize the shapes and also the canvas.


08.55 I have created my own customized canvas for the geometric shapes,


09.00 and your assignment should look some thinglike this.


09.03 Let me run the piece of code in the application.


09.09 You can see the geometric shapes and the color of the canvas changing each time.


09.17 I would like to acknowledge the spoken tutorial project
09.20 which is part of the talk to a teacher project.


09.23 Supported by the National Mission on Education through ICT, MHRD

Government of India.


09.28 For more information please visit the link shown on the screen.


09.33 The video on the link shown summaries the spoken tutorial project.


09.37 If you do not have good bandwidth, you can download and watch it.
09.41 We also give certificate for those who pass an online test. please

contact us contact@spoken-tutorial.org for more details .

09.48 Thank You.This is Sindhu signing off. Enjoy playing with KTurtle!


Contributors and Content Editors

Sneha