Ejemplo n.º 1
0
#
@fig.connect
def on_mouse_move(event):
    cam0.on_mouse_move(event)

# Create two viewboxes
vp1 = entities.ViewBox(fig.viewbox)
vp2 = entities.ViewBox(fig.viewbox)
vp1.bgcolor = (0,0,0.2)
vp2.bgcolor = (0,0.2,0)

# Put them next to each-other
transforms.scale(vp1.transform, 400, 400)
transforms.scale(vp2.transform, 400, 400)
transforms.translate(vp1.transform, 0)
transforms.translate(vp2.transform, 400, 0, 0)

# Create one object in each scene
points1 = entities.PointsEntity(vp1, 100)
points2 = entities.PointsEntity(vp2, 1000)

# Create a camera
cam0 = entities.TwoDCamera()
cam0.parents = vp1, vp2

# Set limits of cam0, this is only to set position right, its fov is not used
cam0.xlim = -100, 500
cam0.ylim = -100, 500

app.run()
Ejemplo n.º 2
0
entities.PixelCamera(fig.viewbox)

for col in range(NCOLS):
    for row in range(NROWS):
        # Create viewbox
        viewbox = entities.ViewBox(fig.viewbox)
        viewbox.transform[-1, 0] = col * RES / NCOLS
        viewbox.transform[-1, 1] = row * RES / NROWS
        viewbox.transform[0, 0] = RES / NCOLS
        viewbox.transform[1, 1] = RES / NROWS
        # Create a camera in the viewbox
        camera = entities.TwoDCamera(viewbox)
        camera.xlim = -100, 500
        camera.ylim = -100, 500
        # Create a points visual in the viewbox
        points = entities.PointsEntity(viewbox, 100)

# Count FPS
t0, frames, t = time.time(), 0, 0


@fig.connect
def on_paint(event):
    global t, t0, frames
    t = time.time()
    frames = frames + 1
    elapsed = (t - t0)  # seconds
    if elapsed > 2.5:
        print("FPS : %.2f (%d frames in %.2f second)" %
              (frames / elapsed, frames, elapsed))
        t0, frames = t, 0
Ejemplo n.º 3
0
# Create a figure
fig = entities.CanvasWithScene()
fig.size = 600, 600
fig.show()

# Create a camera inside a container
camcontainer = entities.PixelCamera(fig.viewbox)
camera = entities.ThreeDCamera(camcontainer)
camera._fov = 90  # or other between 0 and 179

# Explicitly set the second camera, or the ViewBox will pick the second
fig.viewbox.camera = camera

# Create a points entity inside a container
pointscontainer = entities.Entity(fig.viewbox)
points = entities.PointsEntity(pointscontainer, 1000)

# Count FPS
t0, frames, t = time.time(), 0, 0


@fig.connect
def on_paint(event):
    global t, t0, frames
    t = time.time()
    frames = frames + 1
    elapsed = (t - t0)  # seconds
    if elapsed > 2.5:
        print("FPS : %.2f (%d frames in %.2f second)" %
              (frames / elapsed, frames, elapsed))
        t0, frames = t, 0
Ejemplo n.º 4
0
fig.show()

# Add a simple normal pixelcamera. This camera looks at the many
# subplots. Each subplot has its own world with a visual and a camera.
entities.PixelCamera(fig.viewbox)

for col in range(NCOLS):
    for row in range(NROWS):
        # Create "viewbox"
        box = entities.Entity(fig.viewbox)
        box.transform[-1, 0] = col * RES / NCOLS + 100 / NCOLS
        box.transform[-1, 1] = row * RES / NROWS + 100 / NROWS
        box.transform[0, 0] = 1 / NCOLS
        box.transform[1, 1] = 1 / NROWS
        # Create a points visual in the "viewbox"
        points = entities.PointsEntity(box, 100)

# Count FPS
t0, frames, t = time.time(), 0, 0


@fig.connect
def on_paint(event):
    global t, t0, frames
    t = time.time()
    frames = frames + 1
    elapsed = (t - t0)  # seconds
    if elapsed > 2.5:
        print("FPS : %.2f (%d frames in %.2f second)" %
              (frames / elapsed, frames, elapsed))
        t0, frames = t, 0
Ejemplo n.º 5
0
# Create a world object to act as a container
# It is a child of both viewports
world = entities.Entity()
world.parents = vp1, vp2

# Create two cameras
cam0 = entities.TwoDCamera(world)  # Placeholder camera
cam1 = entities.TwoDCamera(cam0)
cam2 = entities.TwoDCamera(cam0)

# Set limits of cam0, this is only to set position right, its fov is not used
cam0.xlim = -100, 500
cam0.ylim = -100, 500

# Set fov of cam1 and cam2, and translate both cameras a bit
cam1.fov = cam2.fov = 600, 600
transforms.translate(cam1.transform, -50, 0)
transforms.translate(cam2.transform, +50, 0)

# Apply cameras
vp1.camera = cam1
vp2.camera = cam2
vp1.bgcolor = (0, 0, 0.2)
vp2.bgcolor = (0, 0.2, 0)

# Create a entity
points = entities.PointsEntity(world)

app.run()