Draw a single material
437250
def draw_material(material, face=GL_FRONT_AND_BACK):
    """"""
    if material.gl_floats is None:
        material.gl_floats = (GLfloat * len(material.vertices))(*material.vertices)
        material.triangle_count = len(material.vertices) / material.vertex_size

    vertex_format = VERTEX_FORMATS.get(material.vertex_format)
    if not vertex_format:
        raise ValueError("Vertex format {} not supported by pyglet".format(material.vertex_format))

    glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT)
    glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT)
    glEnable(GL_CULL_FACE)
    glCullFace(GL_BACK)

    # Fall back to ambient texture if no diffuse
    texture = material.texture or material.texture_ambient
    if texture and material.has_uvs:
        bind_texture(texture)
    else:
        glDisable(GL_TEXTURE_2D)

    glMaterialfv(face, GL_DIFFUSE, gl_light(material.diffuse))
    glMaterialfv(face, GL_AMBIENT, gl_light(material.ambient))
    glMaterialfv(face, GL_SPECULAR, gl_light(material.specular))
    glMaterialfv(face, GL_EMISSION, gl_light(material.emissive))
    glMaterialf(face, GL_SHININESS, min(128.0, material.shininess))
    glEnable(GL_LIGHT0)

    if material.has_normals:
        glEnable(GL_LIGHTING)
    else:
        glDisable(GL_LIGHTING)

    glInterleavedArrays(vertex_format, 0, material.gl_floats)
    glDrawArrays(GL_TRIANGLES, 0, int(material.triangle_count))

    glPopAttrib()
    glPopClientAttrib()
236769
def drawrectangle(self, xa, xb, ya, yb, colour=None, label = None):
        
    
        self.checkforpilimage()
        colour = self.defaultcolour(colour)
        self.changecolourmode(colour)
        self.makedraw()
        
        (pilxa, pilya) = self.pilcoords((xa,ya))
        (pilxb, pilyb) = self.pilcoords((xb,yb))
        
        self.draw.rectangle([(pilxa, pilyb-1), (pilxb+1, pilya)], outline = colour)
        
        if label != None:
            # The we write it :
            self.loadlabelfont()
            textwidth = self.draw.textsize(label, font = self.labelfont)[0]
            self.draw.text(((pilxa + pilxb)/2.0 - float(textwidth)/2.0 + 1, pilya + 2), label, fill = colour, font = self.labelfont)
130568
def draw(self, surfaceObj):
        """"""
        if self._visible:
            if self.buttonDown:
                surfaceObj.blit(self.surfaceDown, self._rect)
            elif self.mouseOverButton:
                surfaceObj.blit(self.surfaceHighlight, self._rect)
            else:
                surfaceObj.blit(self.surfaceNormal, self._rect)
708416
def draw_image(pixelmap, img):
    ''''''
    for item in pixelmap:
        color = item[2]

        # Access the rectangle edges.
        pixelbox = (item[0][0], item[0][1], item[1][0], item[1][1])
        draw = ImageDraw.Draw(img)
        draw.rectangle(pixelbox, fill=color)
830795
def drawItem(self, item, painter, option):
        
        dataset = item.dataset()
        
        painter.save()
        painter.setRenderHint(painter.Antialiasing)
        
        pen = QPen(dataset.color())
        pen.setWidth(0.75)
        painter.setPen(pen)
        
        for path in item.buildData('subpaths', []):
            gradient = QLinearGradient()
            
            clr = QColor(dataset.color())
            clr.setAlpha(220)
            
            gradient.setColorAt(0.0,  clr.lighter(180))
            gradient.setColorAt(0.1,  clr.lighter(160))
            gradient.setColorAt(0.25, clr.lighter(140))
            gradient.setColorAt(1.0,  clr.lighter(125))
            
            if self.orientation() == Qt.Vertical:
                gradient.setStart(0, path.boundingRect().bottom())
                gradient.setFinalStop(0, path.boundingRect().top())
            else:
                gradient.setStart(path.boundingRect().left(), 0)
                gradient.setFinalStop(path.boundingRect().right(), 0)
            
            painter.setBrush(gradient)
            painter.drawPath(path)
        
        painter.restore()
314909
function drawNonMono(
    ctx, points, start, segLen, allLen,
    dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls
) {
    var prevIdx = 0;
    var idx = start;
    for (var k = 0; k < segLen; k++) {
        var p = points[idx];
        if (idx >= allLen || idx < 0) {
            break;
        }
        if (isPointNull(p)) {
            if (connectNulls) {
                idx += dir;
                continue;
            }
            break;
        }

        if (idx === start) {
            ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]);
            v2Copy(cp0, p);
        }
        else {
            if (smooth > 0) {
                var nextIdx = idx + dir;
                var nextP = points[nextIdx];
                if (connectNulls) {
                    // Find next point not null
                    while (nextP && isPointNull(points[nextIdx])) {
                        nextIdx += dir;
                        nextP = points[nextIdx];
                    }
                }

                var ratioNextSeg = 0.5;
                var prevP = points[prevIdx];
                var nextP = points[nextIdx];
                // Last point
                if (!nextP || isPointNull(nextP)) {
                    v2Copy(cp1, p);
                }
                else {
                    // If next data is null in not connect case
                    if (isPointNull(nextP) && !connectNulls) {
                        nextP = p;
                    }

                    vec2.sub(v, nextP, prevP);

                    var lenPrevSeg;
                    var lenNextSeg;
                    if (smoothMonotone === 'x' || smoothMonotone === 'y') {
                        var dim = smoothMonotone === 'x' ? 0 : 1;
                        lenPrevSeg = Math.abs(p[dim] - prevP[dim]);
                        lenNextSeg = Math.abs(p[dim] - nextP[dim]);
                    }
                    else {
                        lenPrevSeg = vec2.dist(p, prevP);
                        lenNextSeg = vec2.dist(p, nextP);
                    }

                    // Use ratio of seg length
                    ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg);

                    scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg));
                }
                // Smooth constraint
                vec2Min(cp0, cp0, smoothMax);
                vec2Max(cp0, cp0, smoothMin);
                vec2Min(cp1, cp1, smoothMax);
                vec2Max(cp1, cp1, smoothMin);

                ctx.bezierCurveTo(
                    cp0[0], cp0[1],
                    cp1[0], cp1[1],
                    p[0], p[1]
                );
                // cp0 of next segment
                scaleAndAdd(cp0, p, v, smooth * ratioNextSeg);
            }
            else {
                ctx.lineTo(p[0], p[1]);
            }
        }

        prevIdx = idx;
        idx += dir;
    }

    return k;
}
774602
def draw(self):
        """"""

        if self.hidden:
            return False

        if self.background_color is not None:
            render.fillrect(self.surface, self.background_color,
                            rect=pygame.Rect((0, 0), self.frame.size))

        for child in self.children:
            if not child.hidden:
                child.draw()

                topleft = child.frame.topleft

                if child.shadowed:
                    shadow_size = theme.current.shadow_size
                    shadow_topleft = (topleft[0] - shadow_size // 2,
                                      topleft[1] - shadow_size // 2)
                    self.surface.blit(child.shadow_image, shadow_topleft)

                self.surface.blit(child.surface, topleft)

                if child.border_color and child.border_widths is not None:
                    if (type(child.border_widths) is int and
                        child.border_widths > 0):
                        pygame.draw.rect(self.surface, child.border_color,
                                         child.frame, child.border_widths)
                    else:
                        tw, lw, bw, rw = child.get_border_widths()

                        tl = (child.frame.left, child.frame.top)
                        tr = (child.frame.right - 1, child.frame.top)
                        bl = (child.frame.left, child.frame.bottom - 1)
                        br = (child.frame.right - 1, child.frame.bottom - 1)

                        if tw > 0:
                            pygame.draw.line(self.surface, child.border_color,
                                             tl, tr, tw)
                        if lw > 0:
                            pygame.draw.line(self.surface, child.border_color,
                                             tl, bl, lw)
                        if bw > 0:
                            pygame.draw.line(self.surface, child.border_color,
                                             bl, br, bw)
                        if rw > 0:
                            pygame.draw.line(self.surface, child.border_color,
                                             tr, br, rw)
        return True
1055247
def draw(self, painter, options, widget):
        
        self.declaration.draw(painter, options, widget)
845080
def draw_image(self, ax, image):
        """"""
        self.renderer.draw_image(imdata=utils.image_to_base64(image),
                                 extent=image.get_extent(),
                                 coordinates="data",
                                 style={"alpha": image.get_alpha(),
                                        "zorder": image.get_zorder()},
                                 mplobj=image)
32805
def draw(self, milliseconds, surface):
        """"""
        self.drawn_rects = []
        cam = Ragnarok.get_world().Camera
        cX, cY, cXMax, cYMax = cam.get_cam_bounds()

        #Draw out only the tiles visible to the camera.
        start_pos = self.pixels_to_tiles( (cX, cY) )
        start_pos -= Vector2(1, 1)
        end_pos = self.pixels_to_tiles( (cXMax, cYMax) )
        end_pos += Vector2(1, 1)

        start_pos.X, start_pos.Y = self.clamp_within_range(start_pos.X, start_pos.Y)
        end_pos.X, end_pos.Y = self.clamp_within_range(end_pos.X, end_pos.Y)

        cam_pos = cam.get_world_pos()
        for x in range(start_pos.X, end_pos.X + 1):
            for y in range(start_pos.Y, end_pos.Y + 1):
                tile = self.tiles[y][x]
                translate_posX = tile.coords.X - cam_pos.X
                translate_posY = tile.coords.Y - cam_pos.Y
                surface.blit(self.spritesheet.image, (translate_posX, translate_posY), tile.source, special_flags = 0)
1059222
def draw(self, milliseconds, surface):
        """"""
        surface.blit(self.image, self.coords, self.source, special_flags=0)
807041
def __draw_cmp(self, obj1, obj2):
        """"""
        if obj1.draw_order > obj2.draw_order:
            return 1
        elif obj1.draw_order < obj2.draw_order:
            return -1
        else:
            return 0
1138172
def _draw(self, color):
        """"""
        width = self.winfo_width()
        height = self.winfo_height()
        self.delete("bg")
        self.delete("cross_h")
        self.delete("cross_v")
        del self.bg
        self.bg = tk.PhotoImage(width=width, height=height, master=self)
        self._fill()
        self.create_image(0, 0, image=self.bg, anchor="nw", tags="bg")
        self.tag_lower("bg")
        h, s, v = color
        x = v / 100.
        y = (1 - s / 100.)
        self.create_line(0, y * height, width, y * height, tags="cross_h",
                         fill="#C2C2C2")
        self.create_line(x * width, 0, x * width, height, tags="cross_v",
                         fill="#C2C2C2")
1258293
def draw_frame(x, y, width, height, thickness, z, color, mode = :default)
      draw_rect(x - thickness, y, thickness, height, z, color, mode) # left
      draw_rect(x - thickness, y - thickness, width + thickness * 2, thickness, z, color, mode) # top (full)
      draw_rect(x + width, y, thickness, height, z, color, mode) # right
      draw_rect(x - thickness, y + height, width + thickness * 2, thickness, z, color, mode) # bottom (full)

      nil
    end
240645
def draw(self):
        '''
        
        '''
        return np.random.uniform(loc=self.__low, scale=self.__high, size=self.__output_shape)
726952
function _drawLine(v0, v1, color) {
        var p = new Primitive();

        p.vertices = [v0, v1];
        p.color = toColor(color);

        renderer.addPrimitive(p);
    }
76518
function draw(renderer, text, x, y) {
         // allows to provide backward compatibility when
         // adding Bitmap Font to an object container
         if (typeof this.ancestor === "undefined") {
           // update cache
           this.setText(text); // force update bounds

           this.update(0); // save the previous global alpha value

           var _alpha = renderer.globalAlpha();

           renderer.setGlobalAlpha(_alpha * this.getOpacity());
         } else {
           // added directly to an object container
           x = this.pos.x;
           y = this.pos.y;
         }

         var strings = ("" + this._text).split("\n");

         var lX = x;
         var stringHeight = measureTextHeight(this);
         var maxWidth = 0;

         for (var i = 0; i < strings.length; i++) {
           x = lX;
           var string = me.utils.string.trimRight(strings[i]); // adjust x pos based on alignment value

           var stringWidth = measureTextWidth(this, string);

           switch (this.textAlign) {
             case "right":
               x -= stringWidth;
               break;

             case "center":
               x -= stringWidth * 0.5;
               break;

             default:
               break;
           } // adjust y pos based on alignment value


           switch (this.textBaseline) {
             case "middle":
               y -= stringHeight * 0.5;
               break;

             case "ideographic":
             case "alphabetic":
             case "bottom":
               y -= stringHeight;
               break;

             default:
               break;
           } // update initial position if required


           if (this.isDirty === true && typeof this.ancestor === "undefined") {
             if (i === 0) {
               this.pos.y = y;
             }

             if (maxWidth < stringWidth) {
               maxWidth = stringWidth;
               this.pos.x = x;
             }
           } // draw the string


           var lastGlyph = null;

           for (var c = 0, len = string.length; c < len; c++) {
             // calculate the char index
             var ch = string.charCodeAt(c);
             var glyph = this.fontData.glyphs[ch];
             var glyphWidth = glyph.width;
             var glyphHeight = glyph.height;
             var kerning = lastGlyph && lastGlyph.kerning ? lastGlyph.getKerning(ch) : 0; // draw it

             if (glyphWidth !== 0 && glyphHeight !== 0) {
               // some browser throw an exception when drawing a 0 width or height image
               renderer.drawImage(this.fontImage, glyph.x, glyph.y, glyphWidth, glyphHeight, x + glyph.xoffset, y + glyph.yoffset * this.fontScale.y, glyphWidth * this.fontScale.x, glyphHeight * this.fontScale.y);
             } // increment position


             x += (glyph.xadvance + kerning) * this.fontScale.x;
             lastGlyph = glyph;
           } // increment line


           y += stringHeight;
         }

         if (typeof this.ancestor === "undefined") {
           // restore the previous global alpha value
           renderer.setGlobalAlpha(_alpha);
         } // clear the dirty flag


         this.isDirty = false;
       }