python(使用海龟)有没有办法画一个圆柱体?(从数组中读取高度、半径和体积)
Is there a way in python (using turtle) to draw an cylinder?(Reading height, radius and volume from array)
我想知道是否有任何方法可以用 python turtle(使用数据(半径、体积和高度)从数组)?
允许我使用的模块列表如下:
-astropy v1.3.2
-美汤v4.6.0
-密码学 v1.8.1
-烧瓶 v1.1.1
-lxml v4.1.1
-numpy v1.12.1
-matplotlib v3.0.3
-pandas v0.19.1
-PeakUtils v1.1.0
-pillow: Python 图像库 (PIL) v4.1.0
-psycopg2 v2.7.1
-PySAL v1.13.0
-请求 v2.18.4
-RunStats v1.6.3
-scikit-learn v0.18.1
-scipy v0.19.0
-SortedContainers v1.5.7
-Statsmodels v0.8.0
有人可以告诉我怎么做吗? (带代码)
提前致谢。
试试这个作为起点:
from turtle import *
height = 100
radius = 20
color(0.2, 0.5, 0.8)
forward(height)
circle(radius)
setheading(90)
penup()
forward(2*radius)
pendown()
setheading(180)
forward(height)
circle(radius, extent=180) # Draw 1/2 of the bottom/circle
done()
使用 stamping 的 turtle 的一种可能方式:
from turtle import *
CURSOR_SIZE = 20
radius, height = [50, 200] # in pixels
shape('square')
shapesize(radius*2 / CURSOR_SIZE, height / CURSOR_SIZE)
fillcolor('white')
stamp()
shape('circle')
shapesize(stretch_len=radius / CURSOR_SIZE)
backward(height/2)
stamp()
forward(5)
pencolor('white')
stamp()
forward(height - 5)
color('black')
stamp()
done()
虽然缺乏真实的视角:
那就是我要画一个圆柱体。
pendown()
#starts to draw
turtle.reset()
#clears the drawing space
circle(radius*10)
forward(length*10)
circle(radius*10, 180)
forward(length*10)
penup()
right(90)
forward(100*10)
#gets the turtle out of the way
#draws a cylinder
我想知道是否有任何方法可以用 python turtle(使用数据(半径、体积和高度)从数组)?
允许我使用的模块列表如下:
-astropy v1.3.2
-美汤v4.6.0
-密码学 v1.8.1
-烧瓶 v1.1.1
-lxml v4.1.1
-numpy v1.12.1
-matplotlib v3.0.3
-pandas v0.19.1
-PeakUtils v1.1.0
-pillow: Python 图像库 (PIL) v4.1.0
-psycopg2 v2.7.1
-PySAL v1.13.0
-请求 v2.18.4
-RunStats v1.6.3
-scikit-learn v0.18.1
-scipy v0.19.0
-SortedContainers v1.5.7
-Statsmodels v0.8.0
有人可以告诉我怎么做吗? (带代码)
提前致谢。
试试这个作为起点:
from turtle import *
height = 100
radius = 20
color(0.2, 0.5, 0.8)
forward(height)
circle(radius)
setheading(90)
penup()
forward(2*radius)
pendown()
setheading(180)
forward(height)
circle(radius, extent=180) # Draw 1/2 of the bottom/circle
done()
使用 stamping 的 turtle 的一种可能方式:
from turtle import *
CURSOR_SIZE = 20
radius, height = [50, 200] # in pixels
shape('square')
shapesize(radius*2 / CURSOR_SIZE, height / CURSOR_SIZE)
fillcolor('white')
stamp()
shape('circle')
shapesize(stretch_len=radius / CURSOR_SIZE)
backward(height/2)
stamp()
forward(5)
pencolor('white')
stamp()
forward(height - 5)
color('black')
stamp()
done()
虽然缺乏真实的视角:
那就是我要画一个圆柱体。
pendown()
#starts to draw
turtle.reset()
#clears the drawing space
circle(radius*10)
forward(length*10)
circle(radius*10, 180)
forward(length*10)
penup()
right(90)
forward(100*10)
#gets the turtle out of the way
#draws a cylinder