File: sin.py

package info (click to toggle)
glitch 0.6-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 488 kB
  • ctags: 649
  • sloc: python: 3,432; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 957 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

from math import sin

import gobject

import glitch, glitch.gtk
from glitch.limbo.lights import LightSwitch, AmbientLight, DiffuseLight
from glitch.limbo.material import Material
from glitch.limbo.objects import Cube
from glitch.limbo.spread import Spread

def tick():
    global t

    for i, cube in enumerate(cubes):
        cube.y = 0.1 + 3 * sin((-t + (i * 5.0)) / 15.0)

    t += 1
    camera.refresh()
    return True

if __name__ == '__main__':
    cubes = [glitch.Scale(children=[
        Material(r=1, children=[
            Cube()])]) for x in xrange(10)]
    camera = glitch.gtk.GtkCamera(eye=[0, 2, 6], ref=[0, 0, -1], children=[
        LightSwitch(children=[
            AmbientLight(intensity=0.4, children=[
                DiffuseLight(y=5, children=[
                    glitch.Translate(x=-5, children=[
                        Spread(x=1.1, children=cubes)])])])])])

    t = 0
    gobject.timeout_add(1000/30, tick)

    camera.run()