當前位置: 首頁>>代碼示例>>Python>>正文


Python Window.add_actor_to_world方法代碼示例

本文整理匯總了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()
開發者ID:arokem,項目名稱:Fos,代碼行數:32,代碼來源:treedemo.py

示例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()
開發者ID:arokem,項目名稱:Fos,代碼行數:31,代碼來源:treedemo2.py


注:本文中的fos.Window.add_actor_to_world方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。