You are on page 1of 7

Thực hành một số lệnh cơ vẽ cơ bản:

1.TH1: Vẽ với fd, bk, rt, lt


Fd 50 ; vẽ về phía trước 50
Fd 50 rt 90 ; vẽ về phía trước 50 và Rùa quay phải 90 độ
Fd 50 rt 90 fd 50 ; vẽ về phía trước 50, Rùa quay phải 90 độ và vẽ về phía trước 50
Fd 50 rt 90 fd 50 lt 90 ; kết quả như lệnh trên và Rùa tiếp tục quay trái 90
Fd 50 rt 90 fd 50 lt 90 fd 50; kết quả như lệnh trên và vẽ về phía trước 50
Fd 50 rt 90 fd 50 lt 90 fd 50 lt 90; kết quả như lệnh trên và Rùa tiếp tục quay trái 90
Fd 50 rt 90 fd 50 lt 90 fd 50 lt 90 bk 50; kết quả như lệnh trên và vẽ lùi về phía sau 50

2.TH2: Vẽ hình đa giác, nét vẽ và màu


setpensize [3 3]; Tạo nét vẽ 3
Fd 50 rt 120 fd 50 rt 120 fd 50 rt 120; Vẽ tam giác

setpensize [5 5] setpc 5; Tạo nét vẽ 5 và màu hồng 5


Fd 50 rt 90 fd 50 rt 90 fd 50 rt 90 fd 50; Vẽ hình vuông

setpensize [5 5] setpc 2; Tạo nét vẽ 5 và màu xanh


Fd 50 rt 90 fd 100 rt 90 fd 50 rt 90 fd 100; Vẽ hình chữ nhật

setpensize [5 5] setpc 0 setfc 5; Tạo nét vẽ 5 và màu đen 0, màu tô hồng 5


Fd 50 rt 72 fd 50 rt 72 fd 50 rt 72 fd 50 rt 72 fd 50; Vẽ hình ngũ giác
Pu rt 90 fd 10 fill ; đưa Rùa vào trong ngũ giác và tô màu hồng 5 được thiết lập ở trên

Fd 50 rt 72 fd 50 rt 72 fd 50 rt 72 fd 50 rt 72 fd 50 Lt 36 fd 50 rt 72 fd 50 rt 72 fd 50 rt 72 fd 50 ; Vẽ hình ngũ giác


đối xứng

Cs; Xóa sân chơi


Fd 50 rt 90 fd 50 lt 90 fd 50 rt 90 fd 50 lt 90 fd 50; Vẽ bậc thang lên
Rt 90 fd 50 rt 90 fd 50 lt 90 fd 50 rt 90 fd 50 lt 90 fd 50 rt 90 fd 50; Vẽ bậc thang xuống
rt 90 fd 250; Nối 2 bậc thang lại

Cs; Xóa sân chơi


Lt 90 fd 40 lt 90 fd 40 lt 90 fd 60 lt 90 fd 60 lt 90 fd 80 lt 90 fd 80 lt 90 fd 100 lt 90 fd 100 lt 90 fd 120; Tạo hình
vuông xoắn

Cs; Xóa sân chơi


Fd 50 rt 90 fd 50 rt 90 fd 50 rt 90 fd 50
Fd 50 rt 90 fd 50 rt 90 fd 50 rt 90 fd 50
Fd 50 rt 90 fd 50 rt 90 fd 50 rt 90 fd 50
Fd 50 rt 90 fd 50 rt 90 fd 50 rt 90 fd 50; Tạo 4 hình vuông liền kề

3.TH3: Thực hành với Rùa


Logo - Turtle World
Logo has a number of other additional drawing commands, some of these are given below.

 home

 cleartext or ct

 label

 setxy
The label command takes a single word as a quoted string (e.g. “a_string”) or a list of
words in [ ] brackets without quotation (e.g. [a string of letters]) and prints them on the
graphics window at the location of the turtle. Let us consider the following code.

The setxy command takes two arguments, treats the first as the value of the abscissa
(horizontal axis) and the second as a value of the ordinate (vertical axis). It places the
turtle at these coordinates, possibly leaving ink while reaching these coordinates. In the
following three figures, we have shown how the setxy command can be used.
The cleartext command, abbreviated ct, clears the text region of the command window.

Exercise
Following is an exercise to check your aptitude on what you have learned so far in this
chapter.

What kind of figure does the following command sequence produce?


cs pu setxy -60 60 pd home rt 45 fd 85 lt 135 fd 120

Interpret these commands as you read them from left to right. Try it to find out the result.

Following is a table of command summary.

Command Name Purpose


setx 100
Sets the turtle's x-coordinate to +100

Moves it 100 points to the right of center

No vertical change

setx -200 Moves the turtle 200 points to the left of center

No vertical change

sety 150
Sets the turtle's y-coordinate to 150

Moves it 150 points above center

No horizontal change

sety - 50 Moves the turtle 50 points below center

No horizontal change

setxy 100 100 Moves the turtle to xy coordinate 100 100

show xcor Reports the turtle’s x-coordinate

show ycor Reports the turtle’s y-coordinate

setheading 0
Points the turtle straight up, “high noon”
seth 0

seth 120 Moves the turtle 120 degree to point to the four o’clock
position

The following screenshot is a practical demonstration of some of the above commands.

You might also like