Draws a viewport-filling rect, texturing it with the specified texture object.
502383
public void drawFrame(int textureId, float[] texMatrix) {
        // Use the identity matrix for MVP so our 2x2 FULL_RECTANGLE covers the viewport.
        synchronized (mDrawLock) {
            if (mCorrectVerticalVideo && !mScaleToFit && (requestedOrientation == SCREEN_ROTATION.VERTICAL || requestedOrientation == SCREEN_ROTATION.UPSIDEDOWN_VERTICAL)) {
                Matrix.scaleM(texMatrix, 0, 0.316f, 1.0f, 1f);
            }
            mProgram.draw(IDENTITY_MATRIX, mRectDrawable.getVertexArray(), 0,
                    mRectDrawable.getVertexCount(), mRectDrawable.getCoordsPerVertex(),
                    mRectDrawable.getVertexStride(),
                    texMatrix, TEX_COORDS_BUF, textureId, TEX_COORDS_STRIDE);
        }
    }
836562
def draw_rect(
            self, x:float, y:float, w:float, h:float, *,
            stroke:Color=None,
            stroke_width:float=1,
            stroke_dash:typing.Sequence=None,
            fill:Color=None
            ) -> None:
        """"""
        pass
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
256549
function fillRect(x, y, width, height) {
         if (this.backBufferContext2D.globalAlpha < 1 / 255) {
           // Fast path: don't draw fully transparent
           return;
         }

         this.backBufferContext2D.fillRect(x, y, width, height);
       }
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)
886811
def _draw_as_bitmap(self, context, opacity):
        
        matrix = context.get_matrix()
        matrix_changed = matrix != self._last_matrix
        new_instructions = self.__new_instructions is not None and len(self.__new_instructions) > 0

        if not new_instructions and not matrix_changed:
            context.save()
            context.identity_matrix()
            context.translate(self.extents.x, self.extents.y)
            context.set_source_surface(self.cache_surface)
            if opacity < 1:
                context.paint_with_alpha(opacity)
            else:
                context.paint()
            context.restore()
            return


        if new_instructions:
            self.__instruction_cache = list(self.__new_instructions)
            self.__new_instructions = deque()

        self.paths = []
        self.extents = None

        if not self.__instruction_cache:
            # no instructions - nothing to do
            return

        # instructions that end path
        path_end_instructions = ("new_path", "clip", "stroke", "fill", "stroke_preserve", "fill_preserve")

        # measure the path extents so we know the size of cache surface
        # also to save some time use the context to paint for the first time
        extents = gdk.Rectangle()
        for instruction, args in self.__instruction_cache:
            if instruction in path_end_instructions:
                self.paths.append((instruction, "path", context.copy_path()))
                exts = context.path_extents()
                exts = get_gdk_rectangle(int(exts[0]), int(exts[1]),
                                         int(exts[2]-exts[0]), int(exts[3]-exts[1]))
                if extents.width and extents.height:
                    extents = gdk.rectangle_union(extents, exts)
                else:
                    extents = exts
            elif instruction in ("save", "restore", "translate", "scale", "rotate"):
                self.paths.append((instruction, "transform", args))


            if instruction in ("set_source_pixbuf", "set_source_surface"):
                # draw a rectangle around the pathless instructions so that the extents are correct
                pixbuf = args[0]
                x = args[1] if len(args) > 1 else 0
                y = args[2] if len(args) > 2 else 0
                context.rectangle(x, y, pixbuf.get_width(), pixbuf.get_height())
                context.clip()

            if instruction == "paint" and opacity < 1:
                context.paint_with_alpha(opacity)
            elif instruction == "set_color":
                self._set_color(context, args[0], args[1], args[2], args[3] * opacity)
            elif instruction == "show_layout":
                self._show_layout(context, *args)
            else:
                getattr(context, instruction)(*args)


        # avoid re-caching if we have just moved
        just_transforms = new_instructions == False and \
                          matrix and self._last_matrix \
                          and all([matrix[i] == self._last_matrix[i] for i in range(4)])

        # TODO - this does not look awfully safe
        extents.x += matrix[4] - 5
        extents.y += matrix[5] - 5
        self.extents = extents

        if not just_transforms:
            # now draw the instructions on the caching surface
            w = int(extents.width) + 10
            h = int(extents.height) + 10
            self.cache_surface = context.get_target().create_similar(cairo.CONTENT_COLOR_ALPHA, w, h)
            ctx = cairo.Context(self.cache_surface)
            ctx.translate(-extents.x, -extents.y)

            ctx.transform(matrix)
            for instruction, args in self.__instruction_cache:
                if instruction == "set_color":
                    self._set_color(ctx, args[0], args[1], args[2], args[3])
                elif instruction == "show_layout":
                    self._show_layout(ctx, *args)
                else:
                    getattr(ctx, instruction)(*args)

        self._last_matrix = matrix
969304
def blend_rect(self, x0, y0, x1, y1, dx, dy, destination, alpha=0xff):
        """"""
        x0, y0, x1, y1 = self.rect_helper(x0, y0, x1, y1)
        for x in range(x0, x1 + 1):
            for y in range(y0, y1 + 1):
                o = self._offset(x, y)
                rgba = self.canvas[o:o + 4]
                rgba[3] = alpha
                destination.point(dx + x - x0, dy + y - y0, rgba)
245430
def draw(self, surface):
        """"""
        offset = 0
        i = 0
        ol, ot = self.screen_topleft_offset
        first = self.options and self.options[0]
        last = self.options and self.options[-1]
        for o in self.options:
            indent = o.get('padding_col', 0)

            # padding above the line
            if o != first and o.get('padding_line', 0):
                offset += o['padding_line']

            font = o.get('font', self._font)
            if i == self.option and self.focus_color:
                clr = self.focus_color
            else:
                clr = self.color
            text = o['label']
            ren = font.render(text, 1, clr)
            if ren.get_width() > self.width:
                self.width = ren.get_width()
            o['label_rect'] = pygame.Rect(
                (ol + self.x + indent, ot + self.y + offset),
                (ren.get_width(), ren.get_height()),
            )
            surface.blit(ren, (self.x + indent, self.y + offset))
            offset += font.get_height()

            # padding below the line
            if o != last and o.get('padding_line', 0):
                offset += o['padding_line']

            i += 1
671785
function (renderer, rect) {
            // use the offscreen canvas
            if (this.preRender) {
                var width = Math.min(rect.width, this.width);
                var height = Math.min(rect.height, this.height);

                // draw using the cached canvas
                renderer.drawImage(
                    this.canvasRenderer.getCanvas(),
                    rect.pos.x, rect.pos.y, // sx,sy
                    width, height,          // sw,sh
                    rect.pos.x, rect.pos.y, // dx,dy
                    width, height           // dw,dh
                );
            }
            // dynamically render the layer
            else {
                // draw the layer
                this.renderer.drawTileLayer(renderer, this, rect);
            }
        }
758085
public void repaintRect (int x, int y, int width, int height)
    {
        // translate back into view coordinates
        x -= _vbounds.x;
        y -= _vbounds.y;
        repaint(x, y, width, height);
    }
865518
function(rect) {
        rect = rect || this._viewportRect();
        var gl = this.context;

        // Set viewport and clear it
        gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
        gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);

        //Set the viewport uniform variables used by each registered program
        var programs = this.programs;
        if (this._dirtyViewport) {
            var view = this._viewportRect();
            for (var comp in programs) {
                programs[comp].setViewportUniforms(view, this.options);
            }
            this._dirtyViewport = false;
        }

        // Search for any entities in the given area (viewport unless otherwise specified)
        var q = Crafty.map.search(rect),
            i = 0,
            l = q.length,
            current;
        //From all potential candidates, build a list of visible entities, then sort by zorder
        var visible_gl = this.visible_gl;
        visible_gl.length = 0;
        for (i = 0; i < l; i++) {
            current = q[i];
            if (
                current._visible &&
                current.program &&
                current._drawLayer === this
            ) {
                visible_gl.push(current);
            }
        }
        visible_gl.sort(this._sort);
        l = visible_gl.length;

        // Now iterate through the z-sorted entities to be rendered
        // Each entity writes it's data into a typed array
        // The entities are rendered in batches, where the entire array is copied to a buffer in one operation
        // A batch is rendered whenever the next element needs to use a different type of program
        // Therefore, you get better performance by grouping programs by z-order if possible.
        // (Each sprite sheet will use a different program, but multiple sprites on the same sheet can be rendered in one batch)
        var shaderProgram = null;
        for (i = 0; i < l; i++) {
            current = visible_gl[i];
            if (shaderProgram !== current.program) {
                if (shaderProgram !== null) {
                    shaderProgram.renderBatch();
                }

                shaderProgram = current.program;
                shaderProgram.index_pointer = 0;
                shaderProgram.switchTo();
            }
            current.draw();
            current._changed = false;
        }

        if (shaderProgram !== null) {
            shaderProgram.renderBatch();
        }
    }
200726
function (src, data, cb) {
    var texture;
    texture = new THREE.CanvasTexture(src);
    setTextureProperties(texture, data);
    cb(texture);
  }
386527
def texture_floodfill(x, y, texture)
      target = pixel_color(x, y)
      texture_flood_fill(target, texture, x, y, FloodfillMethod)
    end
406738
def draw_rect(self, color, world_rect, thickness=0):
    """"""
    tl = self.world_to_surf.fwd_pt(world_rect.tl).round()
    br = self.world_to_surf.fwd_pt(world_rect.br).round()
    rect = pygame.Rect(tl, br - tl)
    pygame.draw.rect(self.surf, color, rect, thickness)
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;
       }
626275
def roundrect(surface, rect, color, rounding=5, unit=PIXEL):
    

    if unit == PERCENT:
        rounding = int(min(rect.size) / 2 * rounding / 100)

    rect = pygame.Rect(rect)
    color = pygame.Color(*color)
    alpha = color.a
    color.a = 0
    pos = rect.topleft
    rect.topleft = 0, 0
    rectangle = pygame.Surface(rect.size, SRCALPHA)

    circle = pygame.Surface([min(rect.size) * 3] * 2, SRCALPHA)
    pygame.draw.ellipse(circle, (0, 0, 0), circle.get_rect(), 0)
    circle = pygame.transform.smoothscale(circle, (rounding, rounding))

    rounding = rectangle.blit(circle, (0, 0))
    rounding.bottomright = rect.bottomright
    rectangle.blit(circle, rounding)
    rounding.topright = rect.topright
    rectangle.blit(circle, rounding)
    rounding.bottomleft = rect.bottomleft
    rectangle.blit(circle, rounding)

    rectangle.fill((0, 0, 0), rect.inflate(-rounding.w, 0))
    rectangle.fill((0, 0, 0), rect.inflate(0, -rounding.h))

    rectangle.fill(color, special_flags=BLEND_RGBA_MAX)
    rectangle.fill((255, 255, 255, alpha), special_flags=BLEND_RGBA_MIN)

    return surface.blit(rectangle, pos)
1223270
def drawRect(page, rect, color=None, fill=None, dashes=None,
             width=1, roundCap=False, morph=None, overlay=True):
    
    img = page.newShape()
    Q = img.drawRect(Rect(rect))
    img.finish(color=color, fill=fill, dashes=dashes, width=width,
                   roundCap=roundCap, morph=morph)
    img.commit(overlay)

    return Q