本文整理匯總了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()