本文整理汇总了Python中fos.Window.add_actor_to_world方法的典型用法代码示例。如果您正苦于以下问题:Python Window.add_actor_to_world方法的具体用法?Python Window.add_actor_to_world怎么用?Python Window.add_actor_to_world使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fos.Window
的用法示例。
在下文中一共展示了Window.add_actor_to_world方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DefaultCamera
# 需要导入模块: from fos import Window [as 别名]
# 或者: from fos.Window import add_actor_to_world [as 别名]
conn = np.array( [ 0, 1, 1, 2, 1, 3 ], dtype = np.uint32 )
cols = np.array( [ [0, 0, 1, 1],
[1, 0, 1, 1],
[0, 0, 1, 0.5] ] , dtype = np.float32 )
vert_width = np.array( [1, 20, 15, 1, 5, 1], dtype = np.float32 )
from fos.core.camera2 import DefaultCamera
cam = DefaultCamera()
from fos.actor.axes import Axes
ax = Axes()
window.add_actor_to_world(ax)
act = Tree(vertices = vert, connectivity = conn, colors = cols, vertices_width = vert_width)
window.add_actor_to_world(act)
class MyEventLoop(pyglet.app.base.EventLoop):
# only overwrite idle
def idle(self):
dt = self.clock.update_time()
redraw_all = self.clock.call_scheduled_functions(dt)
# Redraw all windows
for window in pyglet.app.windows:
if redraw_all or (window._legacy_invalid and window.invalid):
window.switch_to()
示例2: multisampling
# 需要导入模块: from fos import Window [as 别名]
# 或者: from fos.Window import add_actor_to_world [as 别名]
mycpt = "Treedemo - Fos.me"
try:
# Try and create a window with multisampling (antialiasing)
config = Config(sample_buffers=1, samples=4, depth_size=16, double_buffer=True)
window = Window(
resizable=True, config=config, vsync=False, width=1000, height=800, caption=mycpt
) # "vsync=False" to check the framerate
except fos.lib.pyglet.window.NoSuchConfigException:
# Fall back to no multisampling for old hardware
print "fallback"
window = Window(resizable=True, caption=mycpt)
ac = []
s = 500
# tune it up
# this is very inefficient, because it copies the position arrays
for i in range(1000):
pos2 = pos.copy()
pos2[:, 0] = pos2[:, 0] + (randn() - 0.5) * s
pos2[:, 1] = pos2[:, 1] + (randn() - 0.5) * s
# random width array
# wid = np.random.randn(1, 5, (len(pos2),) )
wid = np.random.rand(len(pos2)) * 2
ac.append(Tree(vertices=pos2, connectivity=parents, colors=colors, vertices_width=wid))
for e in ac:
window.add_actor_to_world(e)
fos.run()