|
From: Poul R. <Pou...@sk...> - 2008-10-28 14:54:12
|
In the example below I expect the slider button to start in the middle of
the horizontal rod (value 0). However, it starts at the very left and can
only be moved to the middle of the rod. Am I doing something wrong? (I use
the beta version of VPython)
Poul Riis
from visual import *
from visual.controls import *
scene=display(title="Sliding
box",width=860,height=860,forward=(-2,-1,-0.5),up=(0,0,1),background=(1,1,1))
boxcontrol =controls(title='x-position', x=0, y=700, width=800,
height=150, range=100)
boxslider = slider(pos=(-100,0), width=2, length=200, min=-2, max=2,
color=(0,1,0))
boxslider.value=0
xaxis=arrow(pos=(-3,0,0),axis=(6,0,0),color=(1,0,1),shaftwidth=0.05,fixedwidth
= 1)
yaxis=arrow(pos=(0,-3,0),axis=(0,6,0),color=(1,1,0),shaftwidth=0.05,fixedwidth
= 1)
zaxis=arrow(pos=(0,0,-3),axis=(0,0,6),color=(0,0,1),shaftwidth=0.05,fixedwidth
= 1)
for i in range(-5,6):
for j in range(-5,6):
box(pos=(i*0.5,j*0.5,-0.025),axis=(0,0,-0.05),width=0.45,height=0.45,color=(0.8,0.2,0.1))
slidingbox=box(axis=(0,0,0.4),width=0.6,height=0.4,color=(0,1,0))
rate(100)
while 1:
boxcontrol.interact()
slidingbox.pos=(boxslider.value-2,1.5,0.2)
|