<s> from visual import * <EOL> print ( """<STR_LIT>""" ) <EOL> scene . userspin = <NUM_LIT:0> <EOL> grey = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> class slider : <EOL> def __init__ ( self , pos = vector ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) , axis = vector ( <NUM_LIT:0> , <NUM_LIT:1.> , <NUM_LIT:0> ) , value = None , <EOL> width = <NUM_LIT> , min = <NUM_LIT:0> , max = <NUM_LIT> , color = ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) ) : <EOL> pos = vector ( pos ) <EOL> if value == None : <EOL> value = min <EOL> self . min = min <EOL> self . max = max <EOL> self . value = value <EOL> self . shaft = cylinder ( pos = pos , axis = axis , radius = width / <NUM_LIT> , color = grey ) <EOL> self . start = pos <EOL> self . axis = axis <EOL> self . control = sphere ( pos = self . start + ( self . min + value ) / ( self . max - self . min ) * self . axis , <EOL> radius = width / <NUM_LIT> , color = color ) <EOL> self . label = label ( pos = self . control . pos , text = "<STR_LIT>" % value , <EOL> opacity = <NUM_LIT:0> , box = <NUM_LIT:0> , line = <NUM_LIT:0> ) <EOL> def getslider ( self , pos = None ) : <EOL> pos = vector ( pos ) <EOL> value = self . min + ( self . max - self . min ) * ( pos . y - self . start . y ) / mag ( self . axis ) <EOL> self . setslider ( value ) <EOL> return value <EOL> def setslider ( self , value = None ) : <EOL> if value > self . max : <EOL> value = self . max <EOL> if value < self . min : <EOL> value = self . min <EOL> self . value = value <EOL> self . control . pos = self . start + ( self . min + value ) / ( self . max - self . min ) * self . axis <EOL> self . label . pos = self . control . pos <EOL> self . label . text = "<STR_LIT>" % value <EOL> scene . width = <NUM_LIT> <EOL> scene . height = <NUM_LIT> <EOL> scene . center = ( <NUM_LIT:0> , <NUM_LIT:0.5> , <NUM_LIT:0> ) <EOL> scene . title = "<STR_LIT>" <EOL> wcube = <NUM_LIT> <EOL> rgb = ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> opacity = <NUM_LIT:1> <EOL> hsv = color . rgb_to_hsv ( ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> ctrl = [ slider ( pos = ( - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ) , color = ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) , max = <NUM_LIT:1.> , value = rgb [ <NUM_LIT:0> ] ) , <EOL> slider ( pos = ( - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ) , color = ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> ) , max = <NUM_LIT:1.> , value = rgb [ <NUM_LIT:1> ] ) , <EOL> slider ( pos = ( - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ) , color = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ) , max = <NUM_LIT:1.> , value = rgb [ <NUM_LIT:2> ] ) , <EOL> slider ( pos = ( - <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) , color = ( <NUM_LIT:0.5> , <NUM_LIT:0.5> , <NUM_LIT:0.5> ) , max = <NUM_LIT:1.> , value = opacity ) , <EOL> slider ( pos = ( + <NUM_LIT:1.0> , <NUM_LIT:0> , <NUM_LIT:0> ) , color = ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) , max = <NUM_LIT:1.> , value = hsv [ <NUM_LIT:0> ] ) , <EOL> slider ( pos = ( + <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ) , color = ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) , max = <NUM_LIT:1.> , value = hsv [ <NUM_LIT:1> ] ) , <EOL> slider ( pos = ( + <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ) , color = ( <NUM_LIT:0.5> , <NUM_LIT:0.5> , <NUM_LIT:0.5> ) , max = <NUM_LIT:1.> , value = hsv [ <NUM_LIT:2> ] ) ] <EOL> panel = box ( pos = ( <NUM_LIT:0> , <NUM_LIT:0.5> , <NUM_LIT:0> ) , length = <NUM_LIT> , height = <NUM_LIT:1> , width = <NUM_LIT:0.1> , color = rgb , opacity = opacity ) <EOL> ball = sphere ( pos = ( <NUM_LIT:0> , <NUM_LIT:0.5> , <NUM_LIT:0> ) , radius = <NUM_LIT:0.5> , color = rgb , opacity = opacity ) <EOL> cube = box ( pos = ( <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> ) , axis = ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> length = wcube , width = wcube , height = wcube , color = rgb , opacity = opacity ) <EOL> behind = arrow ( pos = ( - <NUM_LIT> , <NUM_LIT:0> , - <NUM_LIT> ) , axis = ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> ) , color = color . white ) <EOL> dragobj = None <EOL> while True : <EOL> rate ( <NUM_LIT:50> ) <EOL> cube . rotate ( angle = <NUM_LIT:0.1> , axis = scene . up ) <EOL> if scene . mouse . events : <EOL> m = scene . mouse . getevent ( ) <EOL> if m . click == "<STR_LIT:left>" and m . pick in [ panel , ball , cube ] : <EOL> print ( "<STR_LIT>" % ( ctrl [ <NUM_LIT:0> ] . value , ctrl [ <NUM_LIT:1> ] . value , ctrl [ <NUM_LIT:2> ] . value , ctrl [ <NUM_LIT:3> ] . value ) ) <EOL> print ( "<STR_LIT>" % ( ctrl [ <NUM_LIT:4> ] . value , ctrl [ <NUM_LIT:5> ] . value , ctrl [ <NUM_LIT:6> ] . value ) ) <EOL> continue <EOL> elif m . drop == "<STR_LIT:left>" : <EOL> dragobj = None <EOL> elif m . drag == "<STR_LIT:left>" : <EOL> for index in range ( <NUM_LIT:7> ) : <EOL> s = ctrl [ index ] <EOL> if m . pick is s . control : <EOL> pos = m . project ( normal = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ) ) <EOL> dragobj = s <EOL> break <EOL> newpos = scene . mouse . project ( normal = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ) ) <EOL> if dragobj and ( newpos != pos ) : <EOL> pos = newpos <EOL> dragobj . getslider ( pos ) <EOL> if index <= <NUM_LIT:3> : <EOL> cube . color = ball . color = panel . color = ( ctrl [ <NUM_LIT:0> ] . value , ctrl [ <NUM_LIT:1> ] . value , ctrl [ <NUM_LIT:2> ] . value ) <EOL> cube . opacity = ball . opacity = panel . opacity = ctrl [ <NUM_LIT:3> ] . value <EOL> hsv = color . rgb_to_hsv ( ball . color ) <EOL> for nn in range ( <NUM_LIT:3> ) : <EOL> ctrl [ nn + <NUM_LIT:4> ] . setslider ( hsv [ nn ] ) <EOL> else : <EOL> rgb = color . hsv_to_rgb ( ( ctrl [ <NUM_LIT:4> ] . value , ctrl [ <NUM_LIT:5> ] . value , ctrl [ <NUM_LIT:6> ] . value ) ) <EOL> cube . color = ball . color = panel . color = rgb <EOL> cube . opacity = ball . opacity = panel . opacity = ctrl [ <NUM_LIT:3> ] . value <EOL> for nn in range ( <NUM_LIT:3> ) : <EOL> ctrl [ nn ] . setslider ( rgb [ nn ] ) </s>
