大家好,今天给大家一个二维的笛卡尔坐标系
好,那我们废话不多说,直接上程序
import turtle as t
t.screensize(800,600,"black")
t.pensize(1)
t.pencolor("white")
t.speed(1000)
#移动
def yidong(x,y):
t.penup()
t.goto( x,y )
t.pendown()
#箭头
def jiantou(l):
t.color("white","white")
t.begin_fill()
t.lt(150)
for i in range(3):
t.fd(l)
t.lt(120)
t.end_fill()
#标识
def biaoshi():
for i in range(-400,401,100):
yidong(i,10)
t.goto(i,0)
yidong(i,-20)
t.write(i)
for ii in range(-400,400,10):
yidong(ii,5)
t.goto(ii,0)
for a in range(-300,301,100):
yidong(10,a)
t.goto(0,a)
yidong(-20,a-10)
t.write(a)
if a==0:
continue
t.write(a)
for aa in range(-300,301,10):
yidong(5,aa)
t.goto(0,aa)
#画
def h(l):
t.fd(l)
def dk():
yidong(-400,0)
h(800)
jiantou(10)
yidong(0,-300)
t.setheading(90)#设置画笔角度,逆时针为正,顺时针为负
h(600)
jiantou(10)
biaoshi()
dk()
t.done()
接下来是运行结果
?
|