def setdecstring(self, val): if self.decstring: self.decstring.visible = False del self.decstring self.decstring = text(pos=(0.81, -1.9, 0), axis=(0, 0, -1), height=0.15, depth=0.02, color=color.black, string="DEC " + sexstring(val), justify='center', twosided=False)
def __init__(self,*args,**kw): """Create primitives of clock""" Base.__init__(self,{ 'frame':None, 'pointers':'hms', 'ring_color':color.yellow, 'back_color':color.white, 'big_tick_color':color.red, 'small_tick_color':color.blue, 'minute_dot_color':(0.4,0.4,0.4), 'number_color':color.black, 'hour_pointer_color':color.red, 'minute_pointer_color':color.blue, 'second_pointer_color':(0.4,0.4,0.4)},*args,**kw) if not self.frame: self.frame=frame(*self.args,**self.kw) pl=list(self.pointers) hp,mp,sp='h' in pl,'m' in pl,'s' in pl ring(frame=self.frame, axis=(0,0,1), radius=1, thickness=0.05, color=self.ring_color) cylinder(frame=self.frame, pos=(0,0,-0.03), axis=(0,0,0.02), radius=1, color=self.back_color) for i in range(60): a=pi*i/30.0 if i%5==0: j=i/5 if j%3: c,h=self.small_tick_color,0.06 else: c,h=self.big_tick_color,0.12 box(frame=self.frame, pos=(0.99,0,0), length=0.14, height=h, width=0.12, color=c).rotate(angle=a, axis=(0,0,1), origin=(0,0,0)) t=text(pos=(0.8*sin(a),0.8*cos(a)-0.06,0), axis=(1,0,0), height=0.12, string=str(j+12*(not j)), color=self.number_color, depth=0.02, justify='center') for o in t.objects: o.frame.frame=self.frame else: sphere(frame=self.frame, pos=(1,0,0.05), radius=0.01, color=self.minute_dot_color).rotate(angle=a, axis=(0,0,1), origin=(0,0,0)) if hp: self.hf=hf=frame(frame=self.frame) cylinder(frame=hf, pos=(0,0,-0.01), axis=(0,0,0.02), radius=0.08, color=self.hour_pointer_color) box(frame=hf, pos=(0.25,0,0.005), axis=(0.5,0,0), height=0.04, width=0.01, color=self.hour_pointer_color) else: self.hf=None if mp: self.mf=mf=frame(frame=self.frame) cylinder(frame=mf, pos=(0,0,0.01), axis=(0,0,0.02), radius=0.06, color=self.minute_pointer_color) box(frame=mf, pos=(0.35,0,0.025), axis=(0.7,0,0), height=0.03, width=0.01, color=self.minute_pointer_color) else: self.mf=None if sp: self.sf=sf=frame(frame=self.frame) cylinder(frame=sf, pos=(0,0,0.03), axis=(0,0,0.02), radius=0.04, color=self.second_pointer_color) box(frame=sf, pos=(0.4,0,0.045), axis=(0.8,0,0), height=0.02, width=0.01, color=self.second_pointer_color) else: self.sf=None self.update()
def build_keyboard(self): print 'Building Keyboard..' nts = ("C", "D", "E", "F", "G", "A", "B") tol = 0.12 keybsize = 16.5 #cm, span of one octave wb = keybsize / 7. nr_octaves = 7 span = nr_octaves * wb * 7. self.scene = vp.display(title='Piano Keyboard', x=0, y=0, width=1400. / 1., height=600. / 1., center=(75, 0, 0), forward=(0., -2, -1.), background=(0., 0.25, 0.0)) #wooden top and base vp.box(pos=(span / 2 + keybsize, -1., -3), length=span + 1, height=1, width=17, material=vp.materials.wood) vp.box(pos=(span / 2 + keybsize, 1, -8), length=span + 1, height=3, width=7, material=vp.materials.wood) text(pos=(28, 2.2, -8), string=version, width=2, height=2, up=(0, 0, -1), color=vp.color.orange, depth=0.3, justify='center') #leggio leggio = vp.box(pos=(75, 8., -12.), length=span / 2, height=span / 8, width=0.08, color=(1, 1, 0.9)) leggio.rotate(angle=-0.4) for ioct in range(nr_octaves): for ik in range(7): #white keys x = ik * wb + (ioct + 1.) * keybsize + wb / 2. tb = vp.box(pos=(x, 0., 0), length=wb - tol, height=1, width=10, up=(0, 1, 0), color=(1, 1, 1)) self.KB.update({nts[ik] + str(ioct + 1): tb}) if not nts[ik] in ("E", "B"): #black keys tn = vp.box(pos=(x + wb / 2, wb / 2, -2), length=wb * .6, height=1, width=6, up=(0, 1, 0), color=(0, 0, 0)) self.KB.update({nts[ik] + "#" + str(ioct + 1): tn}) self.scene.lights = [] vp.local_light(pos=(0, 100, 0), color=vp.color.white) #source1 vp.local_light(pos=(-10, -40, 20), color=vp.color.white) #source2
def __init__(self, *args, **kw): """Create primitives of clock""" Base.__init__( self, { 'frame': None, 'pointers': 'hms', 'ring_color': color.yellow, 'back_color': color.white, 'big_tick_color': color.red, 'small_tick_color': color.blue, 'minute_dot_color': (0.4, 0.4, 0.4), 'number_color': color.black, 'hour_pointer_color': color.red, 'minute_pointer_color': color.blue, 'second_pointer_color': (0.4, 0.4, 0.4) }, *args, **kw) if not self.frame: self.frame = frame(*self.args, **self.kw) pl = list(self.pointers) hp, mp, sp = 'h' in pl, 'm' in pl, 's' in pl ring(frame=self.frame, axis=(0, 0, 1), radius=1, thickness=0.05, color=self.ring_color) cylinder(frame=self.frame, pos=(0, 0, -0.03), axis=(0, 0, 0.02), radius=1, color=self.back_color) for i in range(60): a = pi * i / 30.0 if i % 5 == 0: j = i / 5 if j % 3: c, h = self.small_tick_color, 0.06 else: c, h = self.big_tick_color, 0.12 box(frame=self.frame, pos=(0.99, 0, 0), length=0.14, height=h, width=0.12, color=c).rotate(angle=a, axis=(0, 0, 1), origin=(0, 0, 0)) t = text(pos=(0.8 * sin(a), 0.8 * cos(a) - 0.06, 0), axis=(1, 0, 0), height=0.12, string=str(j + 12 * (not j)), color=self.number_color, depth=0.02, justify='center') for o in t.objects: o.frame.frame = self.frame else: sphere(frame=self.frame, pos=(1, 0, 0.05), radius=0.01, color=self.minute_dot_color).rotate(angle=a, axis=(0, 0, 1), origin=(0, 0, 0)) if hp: self.hf = hf = frame(frame=self.frame) cylinder(frame=hf, pos=(0, 0, -0.01), axis=(0, 0, 0.02), radius=0.08, color=self.hour_pointer_color) box(frame=hf, pos=(0.25, 0, 0.005), axis=(0.5, 0, 0), height=0.04, width=0.01, color=self.hour_pointer_color) else: self.hf = None if mp: self.mf = mf = frame(frame=self.frame) cylinder(frame=mf, pos=(0, 0, 0.01), axis=(0, 0, 0.02), radius=0.06, color=self.minute_pointer_color) box(frame=mf, pos=(0.35, 0, 0.025), axis=(0.7, 0, 0), height=0.03, width=0.01, color=self.minute_pointer_color) else: self.mf = None if sp: self.sf = sf = frame(frame=self.frame) cylinder(frame=sf, pos=(0, 0, 0.03), axis=(0, 0, 0.02), radius=0.04, color=self.second_pointer_color) box(frame=sf, pos=(0.4, 0, 0.045), axis=(0.8, 0, 0), height=0.02, width=0.01, color=self.second_pointer_color) else: self.sf = None self.update()
def add_label(self, num, label): self.text[num] = vt.text(pos=(num * 5, 3.5, 0), string=label.upper(), justify='center', depth=-0.3, color=vt.color.green)