def add_vertical_layer(diametro_tubo, altura_tubo, x_size,z_size): #scene = display(title='Graph of position', width=1800, height=900, center=(10,10,10), background=(1,1,1),forward=(-1,-1,-1)) scene = display(title='Graph of position', width=1800, height=900, center=(0,10,0), background=(1,1,1),forward=(0,-1,0)) scene.stereo = 'crosseyed' floor = box (pos=(0,0,0), length=x_size, height=0.1, width=z_size, color=color.black, opacity=0.1) arrow(pos=(0,0,0), axis=(10,0,0), shaftwidth=0.1, color = color.black) arrow(pos=(0,0,0), axis=(0,10,0), shaftwidth=0.1) arrow(pos=(0,0,0), axis=(0,0,10), shaftwidth=0.1) layout = "paralelo" altura_layer=0 vertical_layers = [] vertical_layers.append(get_vertical_positions(altura_layer, diametro_tubo, altura_tubo, x_size, z_size,"w")) vertical_layers.append(get_vertical_positions(altura_tubo, diametro_tubo, altura_tubo, x_size, z_size,"p")) raio = diametro_tubo/2 ind = 0. for vertical_layer in vertical_layers: n = str(len(vertical_layer)) text(pos=(0,vertical_layer[0][1],z_size/2), string=n, color=color.orange, depth=0.3, justify='center') for position in vertical_layer: ncolor = color.hsv_to_rgb((ind/len(vertical_layers),1,1)) x_pos,y_pos,z_pos = position cylinder(pos=(x_pos,y_pos,z_pos),axis=(0,altura_tubo,0), radius=raio, color = ncolor, opacity=0.8) ind += 1
def __init__ ( self, ini = None ) : x,y=wx.GetDisplaySize() wx.Frame.__init__ ( self, None,-1,'CrystoSim',size=(x,y) ) self.Splitter=wx.SplitterWindow( self) self.p1=wx.Panel( self.Splitter) str1=" " str2=" " self.p2=wx.Panel( self.Splitter) self.p2.SetBackgroundColour('') #making changes to the part where things will be asked self.p2.lblhear = wx.StaticText(self.p2, label="CRYSTOSIM", pos=(20, 90)) #the control button self.p2.button =wx.Button(self.p2, label="LATTICE ", pos=(30, 140)) self.p2.Bind(wx.EVT_BUTTON, self.OnClick,self.p2.button) self.p2.button1=wx.Button(self.p2,label="PLANE ",pos=(30,170)) self.p2.Bind(wx.EVT_BUTTON,self.OnClick1,self.p2.button1) self.p2.button2=wx.Button(self.p2,label="DIRECTION",pos=(30,200)) self.p2.Bind(wx.EVT_BUTTON,self.OnClick2,self.p2.button2) self.p2.button3=wx.Button(self.p2,label="CLEAR ",pos=(30,230)) self.p2.Bind(wx.EVT_BUTTON,self.OnClear,self.p2.button3) self.p2.button5=wx.Button(self.p2,label="STRUCTURES ",pos=(30,260)) self.p2.Bind(wx.EVT_BUTTON,self.OnClick3,self.p2.button5) self.p2.button4=wx.Button(self.p2,label="EXIT ",pos=(30,290)) self.p2.Bind(wx.EVT_BUTTON,self.OnClose,self.p2.button4) self.p2.button5=wx.Button(self.p2,label="ABOUT ",pos=(30,320)) self.p2.Bind(wx.EVT_BUTTON,self.OnAbout,self.p5.button4) self.Splitter.SplitVertically ( self.p1, self.p2,sashPosition = x-200 ) self.Splitter.SetMinimumPaneSize(50) Sizer = wx.BoxSizer ( ) Sizer.Add ( self.Splitter, 1, wx.EXPAND ) self.SetSizer ( Sizer ) # create a VPython application, just an copy of the Ball-demo visual.text(text='CrystoSim', align='center', depth=-0.3, color=visual.color.green) #self.ash() # initialize the State_Machine and start the timer self.VP_State = 0 self.Old_Size = ( 0, 0 ) self.Timer = wx.Timer ( self ) # the third parameter is essential to allow other timers self.Bind ( wx.EVT_TIMER, self._On_Timer, self.Timer) self.Timer.Start ( 100 )
def add_vertical_layer(diametro_tubo, altura_tubo, x_size, z_size): #scene = display(title='Graph of position', width=1800, height=900, center=(10,10,10), background=(1,1,1),forward=(-1,-1,-1)) scene = display(title='Graph of position', width=1800, height=900, center=(0, 10, 0), background=(1, 1, 1), forward=(0, -1, 0)) scene.stereo = 'crosseyed' floor = box(pos=(0, 0, 0), length=x_size, height=0.1, width=z_size, color=color.black, opacity=0.1) arrow(pos=(0, 0, 0), axis=(10, 0, 0), shaftwidth=0.1, color=color.black) arrow(pos=(0, 0, 0), axis=(0, 10, 0), shaftwidth=0.1) arrow(pos=(0, 0, 0), axis=(0, 0, 10), shaftwidth=0.1) layout = "paralelo" altura_layer = 0 vertical_layers = [] vertical_layers.append( get_vertical_positions(altura_layer, diametro_tubo, altura_tubo, x_size, z_size, "w")) vertical_layers.append( get_vertical_positions(altura_tubo, diametro_tubo, altura_tubo, x_size, z_size, "p")) raio = diametro_tubo / 2 ind = 0. for vertical_layer in vertical_layers: n = str(len(vertical_layer)) text(pos=(0, vertical_layer[0][1], z_size / 2), string=n, color=color.orange, depth=0.3, justify='center') for position in vertical_layer: ncolor = color.hsv_to_rgb((ind / len(vertical_layers), 1, 1)) x_pos, y_pos, z_pos = position cylinder(pos=(x_pos, y_pos, z_pos), axis=(0, altura_tubo, 0), radius=raio, color=ncolor, opacity=0.8) ind += 1
def setdecstring(val): global dec del dec dec=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')
def setrastring(val): global ra del ra ra=text(pos=(0.81,-1.7,0), axis=(0,0,-1), height=0.15, depth=0.02, color=color.black, string="RA "+sexstring(val), justify='center')
def intro(): Title = text(pos=(0, 3, 0), string='MCA PROUDLY PRESENTS', color=color.red, depth=0.3, justify='center') for i in range(20): rate(10) scene.range = i Title.makeinvisible() scene.range = 0 Header = text(pos=(0, 3, 0), string='RENAISSANCE 2005', color=color.yellow, depth=0.3, justify='center') for i in range(20): rate(10) scene.fov = 3 scene.range = i # Now play with colors Header.reshape(color=color.cyan) time.sleep(1) Header.reshape(color=color.blue) time.sleep(1) Header.reshape(color=color.green) time.sleep(1) Header.reshape(color=color.orange) time.sleep(1) Header.reshape(color=color.red) # Now let's delete the Header Header.makeinvisible() scene.range = 10 scene.fov = 0.2 Body = text(pos=(0, 3, 0), string='A CELEBRATION OF LINUX ', color=color.red, depth=0.3, justify='center') Body.reshape(color=color.orange)
from visual import * from visual.text import * print(""" Un aviso en 3D. 1) Modifica el archivo fuente para que el texto cambie de tamanio y de grosor (Hint: quita los comentarios) 2) Comprubebe que solamente funciona para mayusculas. """) scene.title = "3D Text" text(pos=(0, 3, 0), string='HOLA MUNDO', color=color.blue, depth=0.3, justify='center') message = text(pos=(0, 0, 0), string='PRESIONA AQUI', justify='center', color=color.orange, axis=(1, 0, 1)) #, # depth=0.3, up=(0,1,-0.3)) scene.mouse.getclick() message.reshape(color=color.red, height=2)
xc = R*c zc = R*s if i == 2: # Make a portal box(pos=(-3.*w/8.,0.75*h/2.,R), length=0.5*w/2,height=0.75*h,width=d, color=grey) box(pos=(3.*w/8.0,0.75*h/2.,R), length=-0.5*w/2,height=0.75*h,width=d, color=grey) box(pos=(0,0.85*h,R), length=w,height=0.3*h,width=d, color=grey) else: slab = box(pos=(R*c, h/2., R*s), axis=(c,0,s), length=d, height=h, width=w, color=grey) # Decorate the front entrance slab text(pos=(0, 0.77*h, R+d/2), string="NO EXIT", color=color.yellow, depth=0.2, height=0.7, justify="center") # Decorate back slab with a gold box and a clock box(pos=(0,h/2.,-R+d/2+0.1), length=w/2.,height=w/2.,width=0.2, color=(1,0.8,0)) clock = analog_clock(pos=(0,h/2.,-R+d/2+0.2+0.2*h/10.), radius=0.20*w, axis=(0,0,1)) # Draw guy wires from the top of the central post Nwires = 32 for i in range(Nwires): theta = i*2*pi/Nwires cylinder(pos=(0,h,0), axis=(R*cos(theta),-h-0.1,R*sin(theta)), radius=0.02, color=(1,0.7,0)) # Display extruded text text( pos=(1.0,-0.3*sin(pi/10),-2), string='A', height=2.0, depth=0.3,
Forward_Up(None, None, 15) #Forward_Up ( scene.center-camera, None, 15 ) # Bruce Sherwood, December 2007 print """ With left mouse button down, move left or right to look around. """ s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' c = len(s) R = 5 for n in range(c): theta = n * 2 * pi / c - pi / 2 text(pos=(R * cos(theta), 0, R * sin(theta)), axis=(-sin(theta), 0, cos(theta)), string=s[n], height=1, depth=0.5, color=color.yellow) camera = vector(0, 0, 0) # for generality; need not be at origin # Place center of scene at a distance R from the camera: scene.center = camera + vector(0, 0, -R) # Point the camera: #scene.userspin = False down = False lastpos = None #scene.forward = scene.center-camera # scene.fov is "field of view" in radians. R times the tangent # of half the field of view is half of the width of the scene: #scene.range = R*tan(scene.fov/2)
cable = gettreecable( tree.pos ) # And add a cable tail from the Christmas Tree, pointing towards the centre eaxis = visual.arrow(pos=V(0, 0, 0), axis=V(2, 0, 0), color=color.blue, shaftwidth=0.1, fixedwidth=True, opacity=0.2) naxis = visual.arrow(pos=V(0, 0, 0), axis=V(0, 2, 0), color=color.blue, shaftwidth=0.1, fixedwidth=True, opacity=0.2) eaxislabel = visual.text(text='E', pos=(2, 0, 0.2), height=0.5, depth=0.1, color=color.blue, opacity=0.2) naxislabel = visual.text(text='N', pos=(0, 2, 0.2), height=0.5, depth=0.1, color=color.blue, opacity=0.2) while True: visual.rate(10)
'''Rendering Graphics.''' from copypy import GUI import math from headers import * import numpy as np from math import pi,tan,atan,sin,cos import sys from visual import color import visual from cube import * from time import sleep _GRAPHICS=None; _PAUSED=visual.text(text='-',pos=(0,2,0),align="center", depth=-0.3, color=color.red) _PAUSED.visible=False; _FPS=70 class GUI(object): def stopAction(self,event): #if space pressed, #stop action in cube #wait for a keyup of space key #resume the action in cube #if reset pressed, #delay some time #reset the cube #empty actions to be performed #baam try: global _GRAPHICS;
scene.title = "VPython Demo" scene.background = color.gray(0.2) scene.width = 600 scene.height = 400 scene.range = 4 #scene.autocenter = True S = sphere(pos=(0,0,0), radius=1, material=materials.earth) rot=0.005 txPos=(0, 1.2, 0) from visual.text import * # Old 3D text machinery (pre-Visual 5.3): numbers and uppercase letters only: T1 = text(pos=txPos, string='HELLO', color=color.red, depth=0.3, justify='center') import vis # new text object, can render text from any font (default: "sans") : T2 = vis.text(pos=txPos, text="Goodbye", color=color.green, depth=-0.3, align='center') T2.visible=False Lbl_w = label(pos=(0,0,0), text='World', color=color.cyan, xoffset=80, yoffset=-40) # in screen-pixels L1 = label(pos=(0,-1.5,0), text='Drag with right mousebutton to rotate view', box=0) L2 = label(pos=(0,-1.9,0), text='Drag up+down with middle mousebutton to zoom', box=0) L3 = label(pos=(0,-2.3,0), text='Left-click to change', color=color.orange, box=0) print "Hello World" # Console
scene.width = 600 scene.height = 400 scene.range = 4 #scene.autocenter = True S = sphere(pos=(0, 0, 0), radius=1, material=materials.earth) rot = 0.005 txPos = (0, 1.2, 0) from visual.text import * # Old 3D text machinery (pre-Visual 5.3): numbers and uppercase letters only: T1 = text(pos=txPos, string='HELLO', color=color.red, depth=0.3, justify='center') import vis # new text object, can render text from any font (default: "sans") : T2 = vis.text(pos=txPos, text="Goodbye", color=color.green, depth=-0.3, align='center') T2.visible = False Lbl_w = label(pos=(0, 0, 0), text='World', color=color.cyan,
def Select( color0 = white, opacity0 = 1, x_window = 0, y_window = 0 ): L = 1. # box size = bar length R = L/8 # ball radius scene = visual.display( title = 'Select color', x = x_window, y = y_window, width = 600, height = 400, center = 2.5 * Geometry.xaxis + Geometry.yaxis, autoscale = True, autocenter = False, # userspin = False, userzoom = False, forward = -Geometry.zaxis) sample = visual.box( pos = 3 * L * Geometry.xaxis + L * Geometry.yaxis, length = L, height = L, width = L, color = color0, opacity = opacity0 ) hidden = visual.sphere( pos = sample.pos - (0,0,sample.width), radius = R, color = Colors.Complementary( color0 ), opacity = 1 ) red_bar = visual.cylinder( pos = (0,0,0), axis = Geometry.yaxis * L * 2, radius = R, color = Colors.red ) green_bar = visual.cylinder( pos = (L/2,0,0), axis = Geometry.yaxis * L * 2, radius = R, color = Colors.green ) blue_bar = visual.cylinder( pos = (L,0,0), axis = Geometry.yaxis * L * 2, radius = R, color = Colors.blue ) white_bar = visual.cylinder( pos = 2.5 * L * Geometry.xaxis , axis = Geometry.xaxis * L * 2, radius = R, color = Colors.white ) red_ball = visual.sphere( pos = visual.vector(red_bar.pos) + (0,2*color0[0],0), radius = L/4, color = Colors.red ) green_ball = visual.sphere( pos = visual.vector(green_bar.pos) + (0,2*color0[1],0), radius = L/4, color = Colors.green ) blue_ball = visual.sphere( pos = visual.vector(blue_bar.pos) + (0,2*color0[2],0), radius = L/4, color = Colors.blue ) white_ball = visual.sphere( pos = visual.vector(white_bar.pos) + (2*opacity0,0,0), radius = L/4, color = Colors.white ) ok_button = visual.cylinder( pos = 5 * L * Geometry.xaxis + Geometry.yaxis, axis = -Geometry.zaxis * 1e-2, radius = 3 * R, color = Colors.red ) ok_text = visual.text ( text = 'OK', pos = ok_button.pos + Geometry.zaxis * 1e-3, height = R, depth = 1e-3, align = 'center', font = 'Times', color = Colors.white ) def ChangeColor( click, ball ): if ball is white_ball: x0 = white_bar.pos[0] x1 = x0 + white_bar.axis[0] x = (click.pos[0] - x0)/2 ball.pos[0] = x0 if x < 0 else x0 + 2*x if 2*x < x1 - x0 else x1 sample.opacity = x return y = click.pos[1]/2 ball.pos[1] = 0 if y < 0 else 2*y if y < 1 else 2. sample.color = ( red_ball.y / 2, green_ball.y / 2, blue_ball.y / 2 ) hidden.color = Colors.Complementary( sample.color ) while True: ball = None click = scene.waitfor('mousedown') if (click.pos - red_ball.pos).mag < 2*R: ball = red_ball elif (click.pos - green_ball.pos).mag < 2*R: ball = green_ball elif (click.pos - blue_ball.pos).mag < 2*R: ball = blue_ball elif (click.pos - white_ball.pos).mag < 2*R: ball = white_ball elif ( click.pos - ok_button.pos).mag < ok_button.radius: break if ball: scene.bind( 'mousemove', ChangeColor, ball ) unclick = scene.waitfor( 'mouseup' ) scene.unbind( 'mousemove', ChangeColor ) return sample.color
def plot(tiles=None, pads=None): global simplist, complist, pdict visual.scene.autocenter = False # Disable autocentering and point the camera at the origin to start visual.scene.center = (0, 0, 0) visual.scene.show_rendertime = True # Draw a transparent grey ground plane, and transparent blue axis arrows and labels ground = visual.box(pos=(0, 0, 0), length=3000, height=3000, width=0.1, color=(0.8, 0, 0), opacity=0.2) eaxis = visual.arrow(pos=(0, 0, 0), axis=(1600, 0, 0), color=color.blue, shaftwidth=2, fixedwidth=True, opacity=0.2) eaxislabel = visual.text(text='East', pos=(1580, 20, 0), height=40, depth=10, color=color.blue) naxis = visual.arrow(pos=(0, 0, 0), axis=(0, 1600, 0), color=color.blue, shaftwidth=2, fixedwidth=True, opacity=0.2) naxislabel = visual.text(text='North', pos=(20, 1580, 0), height=40, depth=10, color=color.blue) # aaxis = visual.arrow(pos=(0,0,0), axis=(0,0,100), color=color.blue, shaftwidth=2, fixedwidth=True, opacity=0.2) # aaxislabel = visual.text(text='Up', pos=(0,20,80), height=40, depth=10, color=color.blue) for tile in tiles: complist += gettile(cpos=(tile.east, tile.north, 0.0)) tcolor = color.green if tile.color is not None: tcolor = tile.color simplist.append( visual.box(pos=(tile.east, tile.north, 0.0), axis=(0, 0, 1), height=5.0, width=5.0, length=0.2, color=tcolor)) simplist[-1].name = tile.name for pad in pads: pobj = visual.box(pos=(pad.east, pad.north, 0.0), length=1.0, height=2.0, width=1.0, color=color.white) if not pad.enabled: pobj.color = (0.5, 0.5, 0.5) num = int(''.join([c for c in pad.name if c.isdigit()])) if divmod(num, 2)[1] == 0: xoffset = 12 else: xoffset = -12 if pad.name.endswith('a'): yoffset = -8 else: yoffset = 8 # pobj.label = visual.label(pos=pobj.pos, text=pad.name, xoffset=xoffset, yoffset=yoffset, box=False, line=False, opacity=0.2) pobj.label = visual.label(pos=(pobj.pos.x + xoffset, pobj.pos.y + yoffset, pobj.pos.z + 10), text=pad.name, height=9) pobj.cables = {} for tname, tdata in pad.inputs.items(): tpos = visual.vector(tdata[0].east, tdata[0].north, 0.0) cobj = visual.arrow(pos=pobj.pos, axis=(tpos - pobj.pos), shaftwidth=ARROWWIDTH, fixedwidth=True) pobj.cables[tname] = cobj pdict[pad.name] = pobj # Bind mouse click events and key presses to the callback function visual.scene.bind('click keydown', processClick)
for y in range(9): p1=(x,coordenadas[x][y],y) p2=(x+1,coordenadas[x+1][y],y) p3=(x,coordenadas[x][y+1],y+1) p4=(x+1,coordenadas[x+1][y+1],y+1) faces(frame=plano,pos=[p1,p3,p2],color=(random.random(),random.random(),random.random())) faces(frame=plano,pos=[p4,p2,p3],color=(random.random(),random.random(),random.random())) #scene.fullscreen=1 plano=frame() scene.center = (7,-1,0) scene.background = (0.1,0.1,0.1) nome=text(pos =(0.5,0,0), string ="EDUARDO SARAIVA", height=1, depth=0.2, color = (1,0.5,0)) empresa=text(pos =(3,-1.5,0), string ="96 672 16 48", height=1, depth=0.2, color = (0.5,0.5,1)) # A volta do nome caixa = frame() box(frame=caixa,pos=(7,-2,0), height=0.1, length=14, width=1) box(frame=caixa,pos=(7,1.5,0), height=0.1, length=14, width=1) box(frame=caixa,pos=(0,0,0), height=4.1, length=0.1, width=1) box(frame=caixa,pos=(14,0,0), height=4.1, length=0.1, width=1) # relogio e ponteiros cylinder(pos=(7,-5,0), axis=(0,0,-0.2), radius=2.5, color=(0.9,0.9,0.9)) cylinder(pos=(7,-5,0.01), axis=(0,0,-0.2), radius=2.3, color=(0.7,0.7,0.7)) text(pos =(6.7,-3.2,.1), string ="12", height=0.4, depth=0.2, color =(0,0,0)) text(pos =(8.9,-5.2,.1), string ="3", height=0.4, depth=0.2, color =(0,0,0))
def game(): global player global target global missile global planets global barriers global scene global arrow global win global wintext ConfigureLevel() ### Player planet player = visual.sphere( pos = player_position, radius = player_radius, mass = player_mass, color = visual.color.green ) target = visual.sphere( pos = target_position, radius = target_radius, mass = target_mass, color = visual.color.red ) planets = [ visual.sphere(**planet ) for planet in planets_properties ] barriers = [ visual.curve (**barrier) for barrier in barriers_properties] scene.center = tuple(ComputeCenter( player, target, *(planets + barriers) ) ) scene.range = ComputeRange( player, target, *(planets + barriers) ) arrow = visual.arrow( pos = player_position, axis = (target.pos-player.pos).norm() * player_radius * 10, shaftwidth = player_radius * 0.5, headwidth = player_radius, headlength = player_radius, color = visual.color.cyan) scene.bind('mousemove',ChangeArrow) click = scene.waitfor('click') missile_direction = click.pos - player.pos missile = visual.cone( pos = missile_position(target), axis = missile_direction.norm() * missile_length, radius = missile_radius, mass = missile_mass, p = missile_direction * missile_momentum, color = visual.color.yellow, make_trail = True) scene.unbind('mousemove',ChangeArrow) arrow.visible = False del arrow while not Game_over(): visual.rate(100) missile.p += ComputeForce( player, target, *planets ) * time_step missile.pos += missile.p * time_step missile.axis = missile.p.norm() * missile_length if win: wintext = visual.text( text='You win', pos = scene.center + visual.vector(0,0,1e8), height = 1e7, align='center', font = 'Times', color=visual.color.green) # wintext.up = True break
# no, it's cool if quality > 10 : # X+1:6 not set : quality is OK if use_points : point.pos[ x_degree] = vector( dist_x,0, dist_y) if use_intensity : point2.pos[ x_degree] = vector( (quality + offset)*c,0, (quality + offset)*s) if use_lines : lines[ x_degree].color[1] = (1,0,0) if use_outer_line : outer_line.color[ x_degree] = (1,0,0) else: # Warning, the quality is not as good as expected if use_points : pointb.pos[ x_degree] = vector( dist_x,0, dist_y) if use_intensity : point2b.pos[ x_degree] = vector( (quality + offset)*c,0, (quality + offset)*s) if use_lines : lines[ x_degree].color[1] = (0.4,0,0) if use_outer_line : outer_line.color[ x_degree] = (0.4,0,0) if use_lines : lines[ x_degree].pos[1]=( dist_x, 0, dist_y) if use_outer_line : outer_line.pos[ x_degree]=( dist_x, 0, dist_y) ''' message = text(pos=(0,0,0), string='PROTOX1 DATA', justify='center', color=color.yellow, axis=(0,0,1), height=100, depth=0.3, up=(10,10,-0.3)) time.sleep(5) while True: print lidar.x_degree, lidar.y_degree, lidar.dist, lidar.quality update_view (lidar.x_degree, lidar.y_degree, lidar.dist, lidar.quality ) #rate(60) # synchonous repaint at 60fps if scene.kb.keys: # event waiting to be processed? s = scene.kb.getkey() # get keyboard info if s == "q": # stop motor print "hi" #sys.exit(-1)
from visual.text import * # At present VPython supports only numbers and uppercase characters.Other characters will be displayed as * # Specifying the Title of the window scene.title = "Hello World" # Here goes the hello world text text(pos=(0, 3, 0), string='HELLO WORLD', color=color.orange, depth=0.3, justify='center')
if zona == 'A': g = 9.80 elif zona == 'B': g = 1.67 elif zona == 'C': g = 5.88 elif zona == 'D': g = 19.6 else: print("Tem de ser uma das letras acima!") if queres == 'sim': txC3 = text(pos=(0, 7.6, 0.201), axis=(1, 0, 0), width=0.27, height=0.27, string='A ACELERACAO GRAVITICA E', color=color.black, justify='center') tableta = box(pos=(0, 7, 0), length=6, height=2.5, width=0.401, material=materials.wood) txC4 = text(pos=(0, 6.9, 0.201), axis=(1, 0, 0), width=0.45, height=0.45, string=str(g), color=color.red, justify='center')
from visual.text import * # Display extruded text (uppercase only at present) # By default, display text along x axis, with letters pointing up parallel to y axis # Bruce Sherwood, Carnegie Mellon University, begun March 2000 # Example with default values: # text(pos=(0,0,0), axis=(1,0,0), string='ABC', # height=1, depth=0, width=1, # color=currentdisplay.foreground, up=(0,1,0.3)) # axis is direction along which text advances # if width not specified, it is the same as height # depth is measured forward from pos # Only numbers and uppercase letters at present: others display as '*' scene.title = "3D Text" scene.fov = 0.001 scene.range = 7 text(pos=(0,3,0), string='ABC', color=color.red, depth=0.3, justify='center') text(pos=(0,-3,0), string='DEF', color=color.blue, depth=0.3, justify='center') message = text(pos=(0,0,0), string='CLICK TO CHANGE THIS', justify='center', color=color.yellow, axis=(1,0,1), depth=0.3, up=(0,1,-0.3)) scene.mouse.getclick() message.reshape(color=color.cyan, height=2)
height=0.3 * h, width=d, color=grey) else: slab = box(pos=(R * c, h / 2., R * s), axis=(c, 0, s), length=d, height=h, width=w, color=grey) # Decorate the front entrance slab text(pos=(0, 0.77 * h, R + d / 2), string="NO EXIT", color=color.yellow, depth=0.2, height=0.7, justify="center") # Decorate back slab with a gold box and a clock box(pos=(0, h / 2., -R + d / 2 + 0.1), length=w / 2., height=w / 2., width=0.2, color=(1, 0.8, 0)) clock = analog_clock(pos=(0, h / 2., -R + d / 2 + 0.2 + 0.2 * h / 10.), radius=0.20 * w, axis=(0, 0, 1)) # Draw guy wires from the top of the central post Nwires = 32
# By default, display text along x axis, with letters pointing up parallel to y axis # Bruce Sherwood, Carnegie Mellon University, begun March 2000 # Example with default values: # text(pos=(0,0,0), axis=(1,0,0), string='ABC', # height=1, depth=0, width=1, # color=currentdisplay.foreground, up=(0,1,0.3)) # axis is direction along which text advances # if width not specified, it is the same as height # depth is measured forward from pos # Only numbers and uppercase letters at present: others display as '*' scene.title = "3D Text" scene.fov = 0.001 scene.range = 7 text(pos=(0, 3, 0), string='ABC', color=color.red, depth=0.3, justify='center') text(pos=(0, -3, 0), string='DEF', color=color.blue, depth=0.3, justify='center') message = text(pos=(0, 0, 0), string='CLICK TO CHANGE THIS', justify='center', color=color.yellow, axis=(1, 0, 1), depth=0.3, up=(0, 1, -0.3)) scene.mouse.getclick() message.reshape(color=color.cyan, height=2)
'''Rendering Graphics.''' from copypy import GUI import math from headers import * import numpy as np from math import pi, tan, atan, sin, cos import sys from visual import color import visual from cube import * from time import sleep _GRAPHICS = None _PAUSED = visual.text(text='-', pos=(0, 2, 0), align="center", depth=-0.3, color=color.red) _PAUSED.visible = False _FPS = 70 class GUI(object): def stopAction(self, event): #if space pressed, #stop action in cube #wait for a keyup of space key #resume the action in cube #if reset pressed, #delay some time #reset the cube
from visual.text import * import time scene.title = "3D Clock" while 1: rate(100) cur_time = time.localtime() time_string = str(cur_time[3]) +": "+ str(cur_time[4]) + ": "+ str(cur_time[5]) timer = text(pos=(-3,0,-2), string=time_string, color= color.red, depth=0.5 ) time.sleep(1) timer.makeinvisible()
# Display extruded text (uppercase only at present) # By default, display text along x axis, with letters pointing up parallel to y axis # Bruce Sherwood, Carnegie Mellon University, begun March 2000 # Example with default values: # text(pos=(0,0,0), axis=(1,0,0), string='ABC', # height=1, depth=0, width=1, # color=currentdisplay.foreground, up=(0,1,0.3)) # axis is direction along which text advances # if width not specified, it is the same as height # depth is measured forward from pos # Only numbers and uppercase letters at present: others display as '*' scene.title = "3D Text" scene.fov = 0.001 scene.range = 7 text(pos=(0, 3, 0), string="ABC", color=color.red, depth=0.3, justify="center") text(pos=(0, -3, 0), string="DEF", color=color.blue, depth=0.3, justify="center") message = text( pos=(0, 0, 0), string="CLICK TO CHANGE THIS", justify="center", color=color.yellow, axis=(1, 0, 1), depth=0.3, up=(0, 1, -0.3), ) scene.mouse.getclick() message.reshape(color=color.cyan, height=2)
from __future__ import division from visual.text import * # Bruce Sherwood, December 2007 print """ With left mouse button down, move left or right to look around. """ s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' c = len(s) R = 5 for n in range(c): theta = n*2*pi/c-pi/2 text(pos=(R*cos(theta), 0, R*sin(theta)), axis=(-sin(theta), 0, cos(theta)), string=s[n], height = 1, depth=0.5, color=color.yellow) camera = vector(0,0,0) # for generality; need not be at origin # Place center of scene at a distance R from the camera: scene.center = camera+vector(0,0,-R) # Point the camera: scene.forward = scene.center-camera # scene.fov is "field of view" in radians. R times the tangent # of half the field of view is half of the width of the scene: scene.range = R*tan(scene.fov/2) scene.userspin = False down = False lastpos = None while 1: rate(100) if scene.mouse.events: m = scene.mouse.getevent()
pos=[rotor.pos-0.03*rotor.axis+vector(0,Rrotor,0), rotor.pos-0.03*rotor.axis-vector(0,Rrotor,0)]) gyro.rotate(axis=(0,1,0), angle=pi) cm = gyro.pos+0.5*Lshaft*gyro.axis # center of mass of shaft Lrot = I*omega*gyro.axis p = pprecess dt = 0.01 t = 0. Lrotarrow = arrow(length=0, shaftwidth=Rshaft, color=color.red, visible=arrowsvisible) Lrotscale = 0.2 rotimpulsearrow = arrow(length=0, shaftwidth=Lrotarrow.shaftwidth, color=color.cyan, visible=arrowsvisible) rotimpulsescale = 5. Lrotlabel = text(string='L', height=0.06, depth=0.25, visible=arrowsvisible, justify='center', color=Lrotarrow.color) Lrotimpulselabel = text(string='DL', justify='center', visible=arrowsvisible, height=0.06, depth=0.25, color=rotimpulsearrow.color) while 1: rate(50) if scene.mouse.clicked: # pause the animation with a mouse click m = scene.mouse.getclick() if m.pick is rotor: arrowsvisible = not arrowsvisible Lrotarrow.visible = arrowsvisible rotimpulsearrow.visible = arrowsvisible for obj in Lrotlabel.objects: obj.visible = arrowsvisible for obj in Lrotimpulselabel.objects: obj.visible = arrowsvisible