def disk(radius, **kwargs): ''' Draw a disk with given radius. ''' # Get any keyword arguments style = kwargs.get('style', 'wireframe') texture = kwargs.get('texture', None) quadric = _get_quadric() # Setup texture if specified if texture: style = 'solid' gluQuadricTexture(quadric, True) texture.bind() # Set the quadric draw style (line or fill) _set_draw_style(style) # Draw the disk gluDisk(quadric, 0, radius, DiskRes['slices'], DiskRes['loops']) # Clean up texture data if specified if texture: texture.unbind() gluQuadricTexture(quadric, False)
def draw_pin(self, x, y): glPushMatrix() glColor3f(1.0, 1.0, 0.0) glTranslatef(x, 0.0, -y) glRotatef(-90, 1.0, 0.0, 0.0) obj = gluNewQuadric() gluCylinder(obj, 0.05, 0.05, 0.5, 10, 10) glPushMatrix() gluDisk(obj, 0.0, 0.05, 10, 10) glTranslatef(0.0, 0.5, 0.0) glPopMatrix() glPopMatrix()
def drawCircle(pos=(0, 0), radius=1.0, linewidth=0): '''Draw a simple circle :Parameters: `pos`: tuple, default to (0, 0) Position of circle `radius`: float, default to 1.0 Radius of circle ''' x, y = pos[0], pos[1] with gx_matrix: glTranslatef(x, y, 0) glScalef(radius, radius, 1.0) if linewidth > 0: gluDisk(gluNewQuadric(), 1 - linewidth / float(radius), 1, 32, 1) else: gluDisk(gluNewQuadric(), 0, 1, 32, 1)
def drawCircle(pos=(0,0), radius=1.0, linewidth=0): '''Draw a simple circle :Parameters: `pos` : tuple, default to (0, 0) Position of circle `radius` : float, default to 1.0 Radius of circle ''' x, y = pos[0], pos[1] with gx_matrix: glTranslatef(x, y, 0) glScalef(radius, radius, 1.0) if linewidth > 0: gluDisk(gluNewQuadric(), 1-linewidth/float(radius), 1, 32,1) else: gluDisk(gluNewQuadric(), 0, 1, 32,1)
def OnDraw(self): if not self.drawing: return # clear color and depth buffers glClear(GL_COLOR_BUFFER_BIT) posx = 50.0 posy = 50.0 direction = 45 size = 10 #draw food glColor3f(0.0, 0.0, 1.0) for food in self.model.fooditems: # position viewer glMatrixMode(GL_MODELVIEW) glLoadIdentity() # position object glTranslatef(food.x, food.y, 0) #translation third glScalef(food.size, food.size, food.size) #scale second gluDisk(self.quadricObject, 0, 0.5, 16, 1) #draw animals glColor3f(1.0, 1.0, 1.0) for forager in self.model.foragers: # position viewer glMatrixMode(GL_MODELVIEW) glLoadIdentity() # position object glTranslatef(forager.x, forager.y, 0) #translation third glScalef(forager.size, forager.size, forager.size) #scale second #glRotatef(degrees(particle.rhoRad), 0, 0, 1) #rotation first gluDisk(self.quadricObject, 0, 0.5, 16, 1) self.SwapBuffers()
def cylinder(radius, height, **kwargs): """ Draw a cylinder with given radius and height.""" # Get any keyword arguments style = kwargs.get("style", "wireframe") texture = kwargs.get("texture", None) quadric = _get_quadric() # Setup texture if specified if texture: style = "solid" gluQuadricTexture(quadric, True) texture.bind() # Set the quadric draw style (line or fill) _set_draw_style(style) # Draw the bottom end of the cylinder glFrontFace(GL_CW) gluDisk(quadric, 0, radius, DiskRes["slices"], DiskRes["loops"]) glFrontFace(GL_CCW) # Draw the body of the cylinder gluCylinder(quadric, radius, radius, height, CylinderRes["slices"], CylinderRes["stacks"]) # Draw the top end of the cylinder glPushMatrix() translateZ(height) gluDisk(quadric, 0, radius, DiskRes["slices"], DiskRes["loops"]) glPopMatrix() # Clean up texture data if specified if texture: texture.unbind() gluQuadricTexture(quadric, False)
def draw_disk(self, radius, quality): gluDisk(self.quadric, 0, radius, quality, 1)
def _disk_(self, radius=1, inner_radius=0): ''' ''' gluDisk(gluNewQuadric(), inner_radius, radius, xseg, yseg)