""" vpython测试程序,vpython是用Python进行3D建模的模块。 以下程序会生成3D球,3D立方体盒子, 程序显示的结果是在浏览器当中,按鼠标右键可调摄像头,滚动可调远近视距。 用命令pip install vpython即可安装vpython, """ from vpython import * b = box(pos=vec(-4,2,0), color=color.red) # 新建3D立方体 c1 = cylinder(pos=b.pos, radius=0.1, axis=vec(0,1.5,0), color=color.yellow) s = sphere(pos=vec(4,-4,0), radius=0.5, color=color.green) # 新建球体 c2 = cylinder(pos=s.pos, radius=0.1, axis=vec(0,1.5,0), color=color.yellow) t1 = text(text='www.scratch8.net', pos=c1.pos+c1.axis, align='center', height=0.5, color=color.yellow, billboard=True, emissive=True) t2 = text(text='sphere', pos=c2.pos+c2.axis, align='center', height=0.5, color=color.yellow, billboard=True, emissive=True) t3 = text(text='Faces forward', pos=vec(-4,0,0), color=color.cyan, billboard=True, emissive=True) box(pos=t3.start, size=0.1*vec(1,1,1), color=color.red) t4 = text(text='Regular text', pos=vec(-4,-1,0), depth=0.5, color=color.yellow, start_face_color=color.red, end_face_color=color.green) box(pos=t4.start, size=0.1*vec(1,1,1), color=color.red)
李兴球
李兴球的博客是Python创意编程原创博客