(see #draw)
 @note Used by Dare::ImageTile to draw a portion of an image to a canvas.
434286
def draw_tile(x = 0, y = 0, opts = {})

      opts[:canvas] ||= @canvas
      opts[:sx] ||= 0
      opts[:sy] ||= 0
      opts[:swidth] ||= width - opts[:sx]
      opts[:sheight] ||= height - opts[:sy]
      opts[:dwidth] ||= opts[:swidth]
      opts[:dheight] ||= opts[:sheight]

      %x{
        #{opts[:canvas].context}.drawImage(
          #{@img},
          #{opts[:sx]},
          #{opts[:sy]},
          #{opts[:swidth]},
          #{opts[:sheight]},
          #{x},
          #{y},
          #{opts[:dwidth]},
          #{opts[:dheight]}
        );
      }
    end
1098337
public Surface draw (Tile tile, float x, float y, float w, float h) {
    if (!checkIntersection || intersects(x, y, w, h)) {
      tile.addToBatch(batch, tint, tx(), x, y, w, h);
    }
    return this;
  }
196148
function draw_layer(layer, x, y) {

            // Draw layer
            if (layer.width > 0 && layer.height > 0) {

                // Save and update alpha
                var initial_alpha = context.globalAlpha;
                context.globalAlpha *= layer.alpha / 255.0;

                // Copy data
                context.drawImage(layer.getCanvas(), x, y);

                // Draw all children
                var children = get_children(layer);
                for (var i=0; i<children.length; i++) {
                    var child = children[i];
                    draw_layer(child, x + child.x, y + child.y);
                }

                // Restore alpha
                context.globalAlpha = initial_alpha;

            }

        }
648819
function(layer) {
        if (!this.img || !layer) return;

        if (layer.type === "Canvas") {
            this._pattern = this._drawContext.createPattern(
                this.img,
                this._repeat
            );
        } else if (layer.type === "WebGL") {
            this._establishShader(
                "image:" + this.__image,
                Crafty.defaultShader("Image")
            );
            this.program.setTexture(
                this._drawLayer.makeTexture(
                    this.__image,
                    this.img,
                    this._repeat !== "no-repeat"
                )
            );
        }

        if (this._repeat === "no-repeat") {
            this.w = this.w || this.img.width;
            this.h = this.h || this.img.height;
        }

        this.ready = true;
        this.trigger("Invalidate");
    }
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)
691836
def draw_rect(self, rect):
        
        check_int_err(lib.SDL_RenderDrawRect(self._ptr, rect._ptr))
673220
def draw(self, milliseconds, render_surface):
        """"""
        if self.is_visible:
            if not (self.__scale[0] == 0 or self.__scale[1] == 0):
                if self.image is not None:
                    # Create our rectangle to describe our sprite.
                    tmpRect = pygame.Rect(self.coords.X - self.__origin.X,
                                          self.coords.Y - self.__origin.Y,
                                          self.image.get_width(),
                                          self.image.get_height())
                    # Apply tinting to the sprite.
                    # tintedSurface = self.image.copy()
                    # self.image.fill(self.tint_color, special_flags = pygame.BLEND_RGB_MULT)
                    render_surface.blit(self.image, tmpRect, self.source, special_flags=0)
245550
def draw_tile_rot(x = 0, y = 0, angle = 90, opts = {})
      opts[:canvas] ||= @canvas
      opts[:sx] ||= 0
      opts[:sy] ||= 0
      opts[:swidth] ||= width - opts[:sx]
      opts[:sheight] ||= height - opts[:sy]
      opts[:dwidth] ||= opts[:swidth]
      opts[:dheight] ||= opts[:sheight]
      %x{
        var context = #{opts[:canvas].context};
        context.translate(#{x}, #{y});
        context.rotate(-#{angle-90}*Math.PI/180.0);
        context.drawImage(
          #{@img},
          #{opts[:sx]},
          #{opts[:sy]},
          #{opts[:swidth]},
          #{opts[:sheight]},
          -#{opts[:swidth]}/2,
          -#{opts[:sheight]}/2,
          #{opts[:swidth]},
          #{opts[:sheight]});
        context.rotate(#{angle-90}*Math.PI/180.0);
        context.translate(-#{x}, -#{y});
      }
    end
488094
private void drawPart(Canvas canvas, PagePart part) {
        // Can seem strange, but avoid lot of calls
        RectF pageRelativeBounds = part.getPageRelativeBounds();
        Bitmap renderedBitmap = part.getRenderedBitmap();

        // Move to the target page
        float localTranslationX = 0;
        float localTranslationY = 0;
        if (swipeVertical)
        	localTranslationY = toCurrentScale(part.getUserPage() * optimalPageHeight);
        else
        	localTranslationX = toCurrentScale(part.getUserPage() * optimalPageWidth);    	
        canvas.translate(localTranslationX, localTranslationY);
        
        Rect srcRect = new Rect(0, 0, renderedBitmap.getWidth(), //
                renderedBitmap.getHeight());

        float offsetX = toCurrentScale(pageRelativeBounds.left * optimalPageWidth);
        float offsetY = toCurrentScale(pageRelativeBounds.top * optimalPageHeight);
        float width = toCurrentScale(pageRelativeBounds.width() * optimalPageWidth);
        float height = toCurrentScale(pageRelativeBounds.height() * optimalPageHeight);

        // If we use float values for this rectangle, there will be
        // a possible gap between page parts, especially when
        // the zoom level is high.
        RectF dstRect = new RectF((int) offsetX, (int) offsetY, //
                (int) (offsetX + width), //
                (int) (offsetY + height));

        // Check if bitmap is in the screen
        float translationX = currentXOffset + localTranslationX;
        float translationY = currentYOffset + localTranslationY;
        if (translationX + dstRect.left >= getWidth() || translationX + dstRect.right <= 0 ||
                translationY + dstRect.top >= getHeight() || translationY + dstRect.bottom <= 0) {
            canvas.translate(-localTranslationX, -localTranslationY);
            return;
        }

        canvas.drawBitmap(renderedBitmap, srcRect, dstRect, paint);

        if (Constants.DEBUG_MODE) {
            debugPaint.setColor(part.getUserPage() % 2 == 0 ? Color.RED : Color.BLUE);
            canvas.drawRect(dstRect, debugPaint);
        }

        // Restore the canvas position
        canvas.translate(-localTranslationX, -localTranslationY);

    }
430168
private void drawPoint(BufferedImage image) {
        if (this.pointPower == -1) {
            return;
        }
        Random r = new Random();
        Graphics2D g2 = (Graphics2D) image.getGraphics();
        int max = this.w * this.h / this.pointPower;
        for (int i = 0; i < max; i++) {
            int x = r.nextInt(w);
            int y = r.nextInt(h);
            g2.setStroke(new BasicStroke(1.5F));
            g2.setColor(this.randomColor());
            g2.drawOval(x, y, 1, 1);
        }
        g2.dispose();
    }
450165
public function draw($hash)
    {
        $index = 0;
        $tiles = $this->tiles;
        $tileSize = $this->tileSize;
        $tile = $this->tile;
        $tile->allocate($tileSize);
        $br = $tileSize * ($tiles - 1);
        $offsets = array(
            // x, y, innerMoveX, innerMoveY, outerMoveX, outerMoveY
            // corners and sides
            array(0, 0, 0, 1, 1, 0),
            array($br, 0, -1, 0, 0, 1),
            array($br, $br, 0, -1, -1, 0),
            array(0, $br, 1, 0, 0, -1),
            // opposite sides
            array($br, 0, 0, 1, -1, 0),
            array($br, $br, -1, 0, 0, -1),
            array(0, $br, 0, -1, 1, 0),
            array(0, 0, 1, 0, 0, 1),
        );
        if (!$this->image) {
            $this->image = $image = imagecreatetruecolor($tileSize * $tiles, $tileSize * $tiles);
            $this->white = imagecolorallocate($image, 255, 255, 255);
        }
        $image = $this->image;
        $white = $this->white;
        $xEnd = ($tiles + 1) >> 1;
        $xMid = ($xEnd + 1) >> 1;
        $center = ($tiles & 1) ? ($tiles >> 1) : -1;
        $numColors = $this->colors;
        assert('$this->getMinimumHashLength() <= strlen($hash)');
        $colors = array();
        for ($i = 0; $i < $numColors; $i++) {
            $r = hexdec(substr($hash, $index, 2)); $index += 2;
            $g = hexdec(substr($hash, $index, 2)); $index += 2;
            $b = hexdec(substr($hash, $index, 2)); $index += 2;
            $colors[] = $tile->getColor($r, $g, $b);
        }
        $baseColor = hexdec($hash[$index++]);
        $colorPattern = hexdec($hash[$index++]);
        $type = hexdec($hash[$index++]);
        for ($x = 0; $x < $xEnd; $x++) {
            $xOffsets = $offsets;
            for ($y = 0; $y <= $x; $y++) {
                $color = $baseColor;
                if ($colorPattern & 1) {
                    $color++;
                }
                if ($colorPattern & 2) {
                    $color += $x;
                }
                if ($colorPattern & 4) {
                    $color += $y;
                }
                if ($colorPattern & 8) {
                    $color += $x <= $xMid;
                }
                $type += hexdec($hash[$index++]);
                $tileImage = $tile->draw($type, $colors[$color % $numColors]);
                for ($i = 0; $i < 8; $i++) {
                    if ($i == 4 && ($y == $x || $x == 0)) {
                        break;
                    }
                    $offset = $xOffsets[$i];
                    if ($i < 4 || $x != $center) {
                        if ($i == 4) {
                            imageflip($tileImage, IMG_FLIP_HORIZONTAL);
                        }
                        imagecopy($image, $tileImage, $offset[0], $offset[1], 0, 0, $tileSize, $tileSize);
                        if ($x == $center && $y == $center) {
                            break;
                        }
                        if ($i != 7) {
                            $tileImage = imagerotate($tileImage, 270, $white);
                        }
                    }
                    $xOffsets[$i][0] += $offset[2] * $tileSize;
                    $xOffsets[$i][1] += $offset[3] * $tileSize;
                }
            }
            for ($i = 0; $i < 8; $i++) {
                $offsets[$i][0] += $offsets[$i][4] * $tileSize;
                $offsets[$i][1] += $offsets[$i][5] * $tileSize;
            }
        }
        return $this;
    }
1169304
function draw(canvas, ctx, data, params, layer) {

		// If width and sWidth are not defined, use image width
		if (params.width === null && params.sWidth === null) {
			params.width = params.sWidth = img.width;
		}
		// If width and sHeight are not defined, use image height
		if (params.height === null && params.sHeight === null) {
			params.height = params.sHeight = img.height;
		}

		// Ensure image layer's width and height are accurate
		if (layer) {
			layer.width = params.width;
			layer.height = params.height;
		}

		// Only crop image if all cropping properties are given
		if (params.sWidth !== null && params.sHeight !== null && params.sx !== null && params.sy !== null) {

			// If width is not defined, use the given sWidth
			if (params.width === null) {
				params.width = params.sWidth;
			}
			// If height is not defined, use the given sHeight
			if (params.height === null) {
				params.height = params.sHeight;
			}

			// Optionally crop from top-left corner of region
			if (params.cropFromCenter) {
				params.sx += params.sWidth / 2;
				params.sy += params.sHeight / 2;
			}

			// Ensure cropped region does not escape image boundaries

			// Top
			if ((params.sy - (params.sHeight / 2)) < 0) {
				params.sy = (params.sHeight / 2);
			}
			// Bottom
			if ((params.sy + (params.sHeight / 2)) > img.height) {
				params.sy = img.height - (params.sHeight / 2);
			}
			// Left
			if ((params.sx - (params.sWidth / 2)) < 0) {
				params.sx = (params.sWidth / 2);
			}
			// Right
			if ((params.sx + (params.sWidth / 2)) > img.width) {
				params.sx = img.width - (params.sWidth / 2);
			}

			_transformShape(canvas, ctx, params, params.width, params.height);
			_setGlobalProps(canvas, ctx, params);

			// Draw image
			ctx.drawImage(
				img,
				params.sx - (params.sWidth / 2),
				params.sy - (params.sHeight / 2),
				params.sWidth,
				params.sHeight,
				params.x - (params.width / 2),
				params.y - (params.height / 2),
				params.width,
				params.height
			);

		} else {
			// Show entire image if no crop region is defined

			_transformShape(canvas, ctx, params, params.width, params.height);
			_setGlobalProps(canvas, ctx, params);

			// Draw image on canvas
			ctx.drawImage(
				img,
				params.x - (params.width / 2),
				params.y - (params.height / 2),
				params.width,
				params.height
			);

		}

		// Draw invisible rectangle to allow for events and masking
		ctx.beginPath();
		ctx.rect(
			params.x - (params.width / 2),
			params.y - (params.height / 2),
			params.width,
			params.height
		);
		// Check for jCanvas events
		_detectEvents(canvas, ctx, params);
		// Close path and configure masking
		ctx.closePath();
		_restoreTransform(ctx, params);
		_enableMasking(ctx, data, params);
	}
341552
private void draw() throws IOException { // NOPMD
		assert x == 0;
		final double myPercent = Math.max(Math.min(percentValue, 100d), 0d);
		final int fullBlockCount = (int) Math.floor(myPercent / (UNIT_SIZE * PARTIAL_BLOCKS));
		final int partialBlockIndex = (int) Math
				.floor((myPercent - fullBlockCount * UNIT_SIZE * PARTIAL_BLOCKS) / UNIT_SIZE);

		addImage(getBarImage(fullBlockCount > 0 || partialBlockIndex > 0 ? "a" : "a0"));

		final BufferedImage fullBody = getBarImage(String.valueOf(PARTIAL_BLOCKS));
		for (int i = 0; i < fullBlockCount; i++) {
			addImage(fullBody);
		}

		if (partialBlockIndex > 0) {
			final BufferedImage partialBody = getBarImage(String.valueOf(partialBlockIndex));
			addImage(partialBody);
		}

		final int emptyBlocks = FULL_BLOCKS - fullBlockCount - (partialBlockIndex > 0 ? 1 : 0);
		final BufferedImage emptyBody = getBarImage(String.valueOf(0));
		for (int i = 0; i < emptyBlocks; i++) {
			addImage(emptyBody);
		}

		addImage(getBarImage(fullBlockCount == FULL_BLOCKS ? "b" : "b0"));

		if (alertOnHighUsage) {
			x += 8;
			graphics.drawImage(getImage("alert.png"), x, 0, null);
		}
	}
976351
function drawDonutHole(layer) {
			if (options.series.pie.innerRadius > 0) {

				// subtract the center

				layer.save();
				var innerRadius = options.series.pie.innerRadius > 1 ? options.series.pie.innerRadius : maxRadius * options.series.pie.innerRadius;
				layer.globalCompositeOperation = "destination-out"; // this does not work with excanvas, but it will fall back to using the stroke color
				layer.beginPath();
				layer.fillStyle = options.series.pie.stroke.color;
				layer.arc(0, 0, innerRadius, 0, Math.PI * 2, false);
				layer.fill();
				layer.closePath();
				layer.restore();

				// add inner stroke

				layer.save();
				layer.beginPath();
				layer.strokeStyle = options.series.pie.stroke.color;
				layer.arc(0, 0, innerRadius, 0, Math.PI * 2, false);
				layer.stroke();
				layer.closePath();
				layer.restore();

				// TODO: add extra shadow inside hole (with a mask) if the pie is tilted.
			}
		}
523989
def draw_icon(point, icon)
      x, y = point.pixel(@bounding_box)
      icon.draw(@canvas, x, y)
    end
498389
function (renderer, x, y, tmxTile) {
            var tileset = tmxTile.tileset;
            // draw the tile
            tileset.drawTile(
                renderer,
                ((this.cols - 1) * tileset.tilewidth + (x - y) * tileset.tilewidth >> 1),
                (-tileset.tilewidth + (x + y) * tileset.tileheight >> 2),
                tmxTile
            );
        }
847511
def drawForeground(self, painter, rect):
        
        gantt  = self.ganttWidget()
        header = gantt.treeWidget().header()
        width  = self.sceneRect().width()
        height = header.height()
        
        for tile_rect, tile in self._tiles:
            painter.drawPixmap(tile_rect.x(), rect.top(), tile)
        
        palette = self.palette()
        textColor = palette.color(palette.Button).darker(125)
        painter.setPen(textColor)
        painter.drawLine(0, rect.top() + height, width, rect.top() + height)