1 Star 0 Fork 1

freesand/pyVisual

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
cube.py 827 Bytes
Copy Edit Raw Blame History
freesand authored 8 years ago . Initial commit
''' sv01 cube.py 显示一个长方体
'''
from tvtk.api import tvtk
# 可视化管线
# 数据源:创建一个长方体数据源,并且同时设置其长宽高
s = tvtk.CubeSource(x_length=1.0, y_length=2.0, z_length=3.0)
# 数据映射:使用PolyDataMapper将数据转换为图形数据
m = tvtk.PolyDataMapper(input_connection=s.output_port)
# 图形管线
# 实体:创建一个Actor
a = tvtk.Actor(mapper=m)
# 渲染场景:创建一个Renderer,将Actor添加进去
r = tvtk.Renderer(background=(0, 0, 0))
r.add_actor(a)
# 渲染图形窗口:创建一个RenderWindow,将Renderer添加进去
w = tvtk.RenderWindow(size=(300,300))
w.add_renderer(r)
# 渲染图形窗口交互器:创建一个RenderWindowInteractor
i = tvtk.RenderWindowInteractor(render_window=w)
# 开启交互
i.initialize()
i.start()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/freesand/pyvisual.git
git@gitee.com:freesand/pyvisual.git
freesand
pyvisual
pyVisual
master

Search