draw the tile map
@ignore
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
            );
        }
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;

            }

        }
653388
function() {
        var buffer = this.buffer + 1;
        while(true) {
            var tlTile = this.grid[0][0];
            var tlViewPort = {
                x: tlTile.position.x +
                    this.map.layerContainerOriginPx.x,
                y: tlTile.position.y +
                    this.map.layerContainerOriginPx.y
            };
            var ratio = this.getServerResolution() / this.map.getResolution();
            var tileSize = {
                w: Math.round(this.tileSize.w * ratio),
                h: Math.round(this.tileSize.h * ratio)
            };
            if (tlViewPort.x > -tileSize.w * (buffer - 1)) {
                this.shiftColumn(true, tileSize);
            } else if (tlViewPort.x < -tileSize.w * buffer) {
                this.shiftColumn(false, tileSize);
            } else if (tlViewPort.y > -tileSize.h * (buffer - 1)) {
                this.shiftRow(true, tileSize);
            } else if (tlViewPort.y < -tileSize.h * buffer) {
                this.shiftRow(false, tileSize);
            } else {
                break;
            }
        }
    }
156127
function (renderer, layer, rect) {
            // cache a couple of useful references
            var tileset = layer.tileset;

            // get top-left and bottom-right tile position
            var rowItr = this.pixelToTileCoords(
                rect.pos.x - tileset.tilewidth,
                rect.pos.y - tileset.tileheight,
                me.pool.pull("me.Vector2d")
            ).floorSelf();
            var tileEnd = this.pixelToTileCoords(
                rect.pos.x + rect.width + tileset.tilewidth,
                rect.pos.y + rect.height + tileset.tileheight,
                me.pool.pull("me.Vector2d")
            ).ceilSelf();

            var rectEnd = this.tileToPixelCoords(tileEnd.x, tileEnd.y, me.pool.pull("me.Vector2d"));

            // Determine the tile and pixel coordinates to start at
            var startPos = this.tileToPixelCoords(rowItr.x, rowItr.y, me.pool.pull("me.Vector2d"));
            startPos.x -= this.hTilewidth;
            startPos.y += this.tileheight;

            /* Determine in which half of the tile the top-left corner of the area we
             * need to draw is. If we're in the upper half, we need to start one row
             * up due to those tiles being visible as well. How we go up one row
             * depends on whether we're in the left or right half of the tile.
             */
            var inUpperHalf = startPos.y - rect.pos.y > this.hTileheight;
            var inLeftHalf  = rect.pos.x - startPos.x < this.hTilewidth;

            if (inUpperHalf) {
                if (inLeftHalf) {
                    rowItr.x--;
                    startPos.x -= this.hTilewidth;
                }
                else {
                    rowItr.y--;
                    startPos.x += this.hTilewidth;
                }
                startPos.y -= this.hTileheight;
            }

            // Determine whether the current row is shifted half a tile to the right
            var shifted = inUpperHalf ^ inLeftHalf;

            // initialize the columItr vector
            var columnItr = rowItr.clone();

            // main drawing loop
            for (var y = startPos.y * 2; y - this.tileheight * 2 < rectEnd.y * 2; y += this.tileheight) {
                columnItr.setV(rowItr);
                for (var x = startPos.x; x < rectEnd.x; x += this.tilewidth) {
                    //check if it's valid tile, if so render
                    if (
                        (columnItr.x >= 0) &&
                        (columnItr.y >= 0) &&
                        (columnItr.x < this.cols) &&
                        (columnItr.y < this.rows)
                    ) {
                        var tmxTile = layer.layerData[columnItr.x][columnItr.y];
                        if (tmxTile) {
                            tileset = tmxTile.tileset;
                            // offset could be different per tileset
                            var offset  = tileset.tileoffset;
                            // draw our tile
                            tileset.drawTile(
                                renderer,
                                offset.x + x,
                                offset.y + y / 2 - tileset.tileheight,
                                tmxTile
                            );
                        }
                    }
                    // Advance to the next column
                    columnItr.x++;
                    columnItr.y--;
                }

                // Advance to the next row
                if (!shifted) {
                    rowItr.x++;
                    startPos.x += this.hTilewidth;
                    shifted = true;
                }
                else {
                    rowItr.y++;
                    startPos.x -= this.hTilewidth;
                    shifted = false;
                }
            }

            me.pool.push(columnItr);
            me.pool.push(rowItr);
            me.pool.push(tileEnd);
            me.pool.push(rectEnd);
            me.pool.push(startPos);
        }
503102
public void draw(GraphicContext graphicContext) {
        if (!this.visible) {
            return;
        }

        if (this.mapViewDimension.getDimension() == null) {
            return;
        }

        if (this.isRedrawNecessary()) {
            redraw(this.mapScaleCanvas);
            this.redrawNeeded = false;
        }

        int positionLeft = calculatePositionLeft(0, this.mapViewDimension.getDimension().width, this.mapScaleBitmap.getWidth());
        int positionTop = calculatePositionTop(0, this.mapViewDimension.getDimension().height, this.mapScaleBitmap.getHeight());

        graphicContext.drawBitmap(this.mapScaleBitmap, positionLeft, positionTop);
    }
1213531
function() {
        var drawn = OpenLayers.Tile.prototype.draw.apply(this, arguments);
        if (drawn) {
            if (this.isLoading) {
                this.abortLoading();
                //if we're already loading, send 'reload' instead of 'loadstart'.
                this.events.triggerEvent("reload"); 
            } else {
                this.isLoading = true;
                this.events.triggerEvent("loadstart");
            }
            this.url = this.layer.getURL(this.bounds);

            if (this.layer.useJSONP) {
                // Use JSONP method to avoid xbrowser policy
                var ols = new OpenLayers.Protocol.Script({
                    url: this.url,
                    callback: function(response) {
                        this.isLoading = false;
                        this.events.triggerEvent("loadend");
                        this.json = response.data;
                    },
                    scope: this
                });
                ols.read();
                this.request = ols;
            } else {
                // Use standard XHR
                this.request = OpenLayers.Request.GET({
                    url: this.url,
                    callback: function(response) {
                        this.isLoading = false;
                        this.events.triggerEvent("loadend");
                        if (response.status === 200) {
                            this.parseData(response.responseText);
                        }
                    },
                    scope: this
                });
            }
        } else {
            this.unload();
        }
        return drawn;
    }
1238018
function(x, y){
            var coords = this.renderer.mouseToTileCoords(x, y),
                tile = this.map.get(coords.x, coords.y);
            if(tile){
                this.renderer.hoveredTileX = tile.x;
                this.renderer.hoveredTileY = tile.y;
            } else {
                this.renderer.hoveredTileX = null;
                this.renderer.hoveredTileY = null;
            }
            this.renderer.draw();
        }
1123602
private boolean drawLine(FeatureTileGraphics graphics, Path2D line,
			FeatureStyle featureStyle) {

		Graphics2D lineGraphics = graphics.getLineGraphics();

		Paint paint = getLinePaint(featureStyle);
		lineGraphics.setColor(paint.getColor());
		lineGraphics.setStroke(paint.getStroke());

		boolean drawn = lineGraphics.hit(new java.awt.Rectangle(tileWidth,
				tileHeight), line, true);
		if (drawn) {
			lineGraphics.draw(line);
		}

		return drawn;
	}
319693
public void paint (Graphics g, int x, int y, int width, int height)
    {
        // bail out now if we were passed a bogus source image at construct time
        if (_tiles == null) {
            return;
        }

        int rwid = width-2*_w3, rhei = height-2*_h3;

        g.drawImage(_tiles[0], x, y, _w3, _h3, null);
        g.drawImage(_tiles[1], x + _w3, y, rwid, _h3, null);
        g.drawImage(_tiles[2], x + _w3 + rwid, y, _w3, _h3, null);

        y += _h3;
        g.drawImage(_tiles[3], x, y, _w3, rhei, null);
        g.drawImage(_tiles[4], x + _w3, y, rwid, rhei, null);
        g.drawImage(_tiles[5], x + _w3 + rwid, y, _w3, rhei, null);

        y += rhei;
        g.drawImage(_tiles[6], x, y, _w3, _h3, null);
        g.drawImage(_tiles[7], x + _w3, y, rwid, _h3, null);
        g.drawImage(_tiles[8], x + _w3 + rwid, y, _w3, _h3, null);
    }
155471
def draw_grid(self):
        """"""
        self.screen.fill((0xbb, 0xad, 0xa0), self.origin + (self.game_width, self.game_height))
        for y, row in enumerate(self.grid):
            for x, cell in enumerate(row):
                self.screen.blit(self.tiles[cell], self.get_tile_location(x, y))
45106
function (renderer, dx, dy, tmxTile) {

            // check if any transformation is required
            if (tmxTile.flipped) {
                renderer.save();
                // apply the tile current transform
                renderer.translate(dx, dy);
                renderer.transform(tmxTile.currentTransform);
                // reset both values as managed through transform();
                dx = dy = 0;
            }

            // check if the tile has an associated image
            if (this.isCollection === true) {
                // draw the tile
                renderer.drawImage(
                    this.imageCollection[tmxTile.tileId],
                    0, 0,
                    tmxTile.width, tmxTile.height,
                    dx, dy,
                    tmxTile.width, tmxTile.height
                );
            } else {
                // use the tileset texture
                var offset = this.atlas[this.getViewTileId(tmxTile.tileId)].offset;
                // draw the tile
                renderer.drawImage(
                    this.image,
                    offset.x, offset.y,
                    this.tilewidth, this.tileheight,
                    dx, dy,
                    this.tilewidth + renderer.uvOffset, this.tileheight + renderer.uvOffset
                );
            }

            if (tmxTile.flipped)  {
                // restore the context to the previous state
                renderer.restore();
            }
        }
1248547
def draw_oval(x, y, width, height)
      @context.drawOval(x, y, width, height)
    end
321410
function _drawLayer($canvas, ctx, layer, nextLayerIndex) {
	if (layer && layer.visible && layer._method) {
		if (nextLayerIndex) {
			layer._next = nextLayerIndex;
		} else {
			layer._next = null;
		}
		// If layer is an object, call its respective method
		if (layer._method) {
			layer._method.call($canvas, layer);
		}
	}
}
308725
function (renderer, layer, rect) {
            var incX = 1, incY = 1;

            // get top-left and bottom-right tile position
            var start = this.pixelToTileCoords(
                Math.max(rect.pos.x - (layer.maxTileSize.width - layer.tilewidth), 0),
                Math.max(rect.pos.y - (layer.maxTileSize.height - layer.tileheight), 0),
                me.pool.pull("me.Vector2d")
            ).floorSelf();

            var end = this.pixelToTileCoords(
                rect.pos.x + rect.width + this.tilewidth,
                rect.pos.y + rect.height + this.tileheight,
                me.pool.pull("me.Vector2d")
            ).ceilSelf();

            //ensure we are in the valid tile range
            end.x = end.x > this.cols ? this.cols : end.x;
            end.y = end.y > this.rows ? this.rows : end.y;

            switch (layer.renderorder) {
                case "right-up" :
                    // swapping start.y and end.y
                    end.y = start.y + (start.y = end.y) - end.y;
                    incY = -1;
                    break;
                case "left-down" :
                    // swapping start.x and end.x
                    end.x = start.x + (start.x = end.x) - end.x;
                    incX = -1;
                    break;
                case "left-up" :
                    // swapping start.x and end.x
                    end.x = start.x + (start.x = end.x) - end.x;
                    // swapping start.y and end.y
                    end.y = start.y + (start.y = end.y) - end.y;
                    incX = -1;
                    incY = -1;
                    break;
                default: // right-down
                    break;
            }

            // main drawing loop
            for (var y = start.y; y !== end.y; y+= incY) {
                for (var x = start.x; x !== end.x; x+= incX) {
                    var tmxTile = layer.layerData[x][y];
                    if (tmxTile) {
                        this.drawTile(renderer, x, y, tmxTile);
                    }
                }
            }

            me.pool.push(start);
            me.pool.push(end);
        }
1001495
public BufferedImage drawTile(int x, int y, int zoom) {
		BufferedImage image;
		if (isIndexQuery()) {
			image = drawTileQueryIndex(x, y, zoom);
		} else {
			image = drawTileQueryAll(x, y, zoom);
		}
		return image;
	}
675793
def _render_map(self, surface, rect, surfaces):
        
        self._tile_queue = self.data.process_animation_queue(self._tile_view)
        self._tile_queue and self._flush_tile_queue(self._buffer)

        # TODO: could maybe optimize to remove just the edges, ideally by drawing lines
        # if not self.anchored_view:
        #     surface.fill(self._clear_color, self._previous_blit)
        if not self._anchored_view:
            self._clear_surface(surface, self._previous_blit)

        offset = -self._x_offset + rect.left, -self._y_offset + rect.top

        with surface_clipping_context(surface, rect):
            self._previous_blit = surface.blit(self._buffer, offset)
            if surfaces:
                surfaces_offset = -offset[0], -offset[1]
                self._draw_surfaces(surface, surfaces_offset, surfaces)
953668
def draw(surface, z_order, colour)
      surface.draw_rectangle(position, size, z_order, colour)
    end