draw and fill rectangle
@param {number} x1 - x
@param {number} y2 - y
@param {number} radius - radius
@param {string} color
@param {CanvasRenderingContext2D} [c]
970867
function (x1, y1, w, h, color, c)
    {
        _c = c || _c
        if (color)
        {
            _c.fillStyle = color
        }
        box(x1 * _scale, y1 * _scale, w * _scale, h * _scale)
    }
71152
function(color, ctx){
            ctx = ctx || this.bufferCtx;
            ctx.fillStyle = color || this.bgColor;
            ctx.fillRect(
                0,
                0,
                this.canvas.width,
                this.canvas.height
            );
        }
203168
def paint_cube(self, x, y):
        
        # get the color
        color = self.next_color()
        # calculate the position
        cube_pos = [x, y, x + self.cube_size, y + self.cube_size]
        # draw the cube
        draw = ImageDraw.Draw(im=self.image)
        draw.rectangle(xy=cube_pos, fill=color)
1278671
public function drawRoundedRectangle($X1, $Y1, $X2, $Y2, $Radius, array $Format = [])
    {
        $R = isset($Format["R"]) ? $Format["R"] : 0;
        $G = isset($Format["G"]) ? $Format["G"] : 0;
        $B = isset($Format["B"]) ? $Format["B"] : 0;
        $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;

        list($X1, $Y1, $X2, $Y2) = $this->fixBoxCoordinates($X1, $Y1, $X2, $Y2);

        if ($X2 - $X1 < $Radius) {
            $Radius = floor((($X2 - $X1)) / 2);
        }
        if ($Y2 - $Y1 < $Radius) {
            $Radius = floor((($Y2 - $Y1)) / 2);
        }

        $Color = ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "NoBorder" => true];

        if ($Radius <= 0) {
            $this->drawRectangle($X1, $Y1, $X2, $Y2, $Color);
            return 0;
        }

        if ($this->Antialias) {
            $this->drawLine($X1 + $Radius, $Y1, $X2 - $Radius, $Y1, $Color);
            $this->drawLine($X2, $Y1 + $Radius, $X2, $Y2 - $Radius, $Color);
            $this->drawLine($X2 - $Radius, $Y2, $X1 + $Radius, $Y2, $Color);
            $this->drawLine($X1, $Y1 + $Radius, $X1, $Y2 - $Radius, $Color);
        } else {
            $Color = $this->allocateColor($this->Picture, $R, $G, $B, $Alpha);
            imageline($this->Picture, $X1 + $Radius, $Y1, $X2 - $Radius, $Y1, $Color);
            imageline($this->Picture, $X2, $Y1 + $Radius, $X2, $Y2 - $Radius, $Color);
            imageline($this->Picture, $X2 - $Radius, $Y2, $X1 + $Radius, $Y2, $Color);
            imageline($this->Picture, $X1, $Y1 + $Radius, $X1, $Y2 - $Radius, $Color);
        }

        $Step = 360 / (2 * PI * $Radius);
        for ($i = 0; $i <= 90; $i = $i + $Step) {
            $X = cos(($i + 180) * PI / 180) * $Radius + $X1 + $Radius;
            $Y = sin(($i + 180) * PI / 180) * $Radius + $Y1 + $Radius;
            $this->drawAntialiasPixel($X, $Y, ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha]);

            $X = cos(($i + 90) * PI / 180) * $Radius + $X1 + $Radius;
            $Y = sin(($i + 90) * PI / 180) * $Radius + $Y2 - $Radius;
            $this->drawAntialiasPixel($X, $Y, ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha]);

            $X = cos($i * PI / 180) * $Radius + $X2 - $Radius;
            $Y = sin($i * PI / 180) * $Radius + $Y2 - $Radius;
            $this->drawAntialiasPixel($X, $Y, ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha]);

            $X = cos(($i + 270) * PI / 180) * $Radius + $X2 - $Radius;
            $Y = sin(($i + 270) * PI / 180) * $Radius + $Y1 + $Radius;
            $this->drawAntialiasPixel($X, $Y, ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha]);
        }
    }
751638
def fill_rectangle(x, y, width, height)
      @context.fillRect(x, y, width, height)
    end
410814
public static void drawRectangle( Rectangle2D_I32 rect , Graphics2D g2 ) {
		g2.drawLine(rect.x0, rect.y0, rect.x1, rect.y0);
		g2.drawLine(rect.x1, rect.y0, rect.x1, rect.y1);
		g2.drawLine(rect.x0, rect.y1, rect.x1, rect.y1);
		g2.drawLine(rect.x0, rect.y1, rect.x0, rect.y0);
	}
903864
private void drawInterfere(Graphics g, int x1, int y1, int x2, int y2, int thickness, Color c) {

		// The thick line is in fact a filled polygon
		g.setColor(c);
		int dX = x2 - x1;
		int dY = y2 - y1;
		// line length
		double lineLength = Math.sqrt(dX * dX + dY * dY);

		double scale = (double) (thickness) / (2 * lineLength);

		// The x and y increments from an endpoint needed to create a
		// rectangle...
		double ddx = -scale * (double) dY;
		double ddy = scale * (double) dX;
		ddx += (ddx > 0) ? 0.5 : -0.5;
		ddy += (ddy > 0) ? 0.5 : -0.5;
		int dx = (int) ddx;
		int dy = (int) ddy;

		// Now we can compute the corner points...
		int xPoints[] = new int[4];
		int yPoints[] = new int[4];

		xPoints[0] = x1 + dx;
		yPoints[0] = y1 + dy;
		xPoints[1] = x1 - dx;
		yPoints[1] = y1 - dy;
		xPoints[2] = x2 - dx;
		yPoints[2] = y2 - dy;
		xPoints[3] = x2 + dx;
		yPoints[3] = y2 + dy;

		g.fillPolygon(xPoints, yPoints, 4);
	}
432224
function drawCell(cell, canvas, loc, fill) {
  // Also takes in a number and outputs a cell.
  if (typeof loc == 'undefined') loc = {x: 0, y: 0};
  if (typeof fill == 'undefined') fill = '#8ED6FF';

  var quadrant_width = 50;
  // Given a number in a quadrant and a location specifying the top left corner of
  // the quadrant, draw the relevant shape.
  function drawQuadrant(n, q, loc) {
    // draw upper triangle going certain direction at location
    function drawUpperTriangle(d, loc) {
      if (d == "r") {
        var first = {x: 50, y: 0};
        var second = {x: 50, y: 50};
      } else {
        var first = {x: 50, y: 0};
        var second = {x: 0, y: 50};
      }
      context.beginPath();
      context.moveTo(loc.x, loc.y);
      context.lineTo(loc.x + first.x, loc.y + first.y);
      context.lineTo(loc.x + second.x, loc.y + second.y);
      context.lineTo(loc.x, loc.y);
      context.lineWidth = 1;
      context.strokeStyle = 'black';
      context.stroke();
      context.fillStyle = fill;
      context.fill();
      context.closePath();
    }
    function drawLowerTriangle(d, loc) {
      if (d == "r") {
        loc = {x: loc.x + 50, y: loc.y};
        var first = {x: 0, y: 50};
        var second = {x: -50, y: 50};
      } else {
        var first = {x: 50, y: 50};
        var second = {x: 0, y: 50};
      }
      context.beginPath();
      context.moveTo(loc.x, loc.y);
      context.lineTo(loc.x + first.x, loc.y + first.y);
      context.lineTo(loc.x + second.x, loc.y + second.y);
      context.lineTo(loc.x, loc.y);
      context.lineWidth = 1;
      context.strokeStyle = 'black';
      context.stroke();
      context.fillStyle = fill;
      context.fill();
      context.closePath();
    }
    function drawTileOutline(loc) {
      context.beginPath();
      context.moveTo(loc.x, loc.y);
      context.lineTo(loc.x + 50, loc.y);
      context.lineTo(loc.x + 50, loc.y + 50);
      context.lineTo(loc.x, loc.y + 50);
      context.lineTo(loc.x, loc.y);
      context.lineWidth = 1;
      context.strokeStyle = 'black';
      context.stroke();
      context.closePath();
    }
    // blank space, just draw outline without filling.
    if (n == 0) {
      drawTileOutline(loc);
    } else if (n == 1) { // tile.
      context.beginPath();
      context.moveTo(loc.x, loc.y);
      context.lineTo(loc.x + 50, loc.y);
      context.lineTo(loc.x + 50, loc.y + 50);
      context.lineTo(loc.x, loc.y + 50);
      context.lineTo(loc.x, loc.y);
      context.lineWidth = 1;
      context.strokeStyle = 'black';
      context.stroke();
      context.fillStyle = fill;
      context.fill();
      context.closePath();
    } else if (n == 2) {
      drawTileOutline(loc);
      if (q == 0 || q == 2) {
        drawLowerTriangle("l", loc);
      } else {
        drawLowerTriangle("r", loc);
      }
    } else if (n == 3) {
      drawTileOutline(loc);
      if (q == 0 || q == 2) {
        drawUpperTriangle("r", loc);
      } else {
        drawUpperTriangle("l", loc);
      }
    }
  }
  var context = canvas.getContext('2d');
  var offsets = [
    {x: 0, y: 0},
    {x: 50, y: 0},
    {x: 50, y: 50},
    {x: 0, y: 50}
  ];

  // number at element, quadrant
  cell.array.forEach(function(n, q) {
    var offset = offsets[q];
    var new_loc = {x: loc.x + offset.x, y: loc.y + offset.y};
    drawQuadrant(n, q, new_loc);
  });
}
630765
void draw(Canvas canvas) {
        mCanvasRect.set(0.0f, 0.0f, canvas.getWidth(), canvas.getHeight());
        switch (mShape) {
            case SHAPE_RECTANGLE:
                canvas.drawRect(mCanvasRect, mCanvasPaint);
                break;
            case SHAPE_OVAL:
                canvas.drawOval(mCanvasRect, mCanvasPaint);
                break;
            case SHAPE_STAR_3_VERTICES:
            case SHAPE_STAR_4_VERTICES:
            case SHAPE_STAR_5_VERTICES:
            case SHAPE_STAR_6_VERTICES:
                drawStar(canvas, mShape);
                break;
            case SHAPE_HEART:
                drawHeart(canvas);
                break;
        }
    }
506978
function (size, unitSize, color1, color2) {
        size = size || 512;
        unitSize = unitSize || 64;
        color1 = color1 || 'black';
        color2 = color2 || 'white';

        var repeat = Math.ceil(size / unitSize);

        var canvas = document.createElement('canvas');
        canvas.width = size;
        canvas.height = size;
        var ctx = canvas.getContext('2d');
        ctx.fillStyle = color2;
        ctx.fillRect(0, 0, size, size);

        ctx.fillStyle = color1;
        for (var i = 0; i < repeat; i++) {
            for (var j = 0; j < repeat; j++) {
                var isFill = j % 2 ? (i % 2) : (i % 2 - 1);
                if (isFill) {
                    ctx.fillRect(i * unitSize, j * unitSize, unitSize, unitSize);
                }
            }
        }

        var texture = new Texture2D({
            image: canvas,
            anisotropic: 8
        });

        return texture;
    }
602230
public void drawLine(float x1, float y1, float x2, float y2) {
		float lineWidth = this.lineWidth - 1;
		
		if (LSR.applyGLLineFixes()) {
			if (x1 == x2) {
				if (y1 > y2) {
					float temp = y2;
					y2 = y1;
					y1 = temp;
				}
				float step = 1 / sy;
				lineWidth = lineWidth / sy;
				fillRect(x1-(lineWidth/2.0f),y1-(lineWidth/2.0f),lineWidth+step,(y2-y1)+lineWidth+step);
				return;
			} else if (y1 == y2) {
				if (x1 > x2) {
					float temp = x2;
					x2 = x1;
					x1 = temp;
				}
				float step = 1 / sx;
				lineWidth = lineWidth / sx;
				fillRect(x1-(lineWidth/2.0f),y1-(lineWidth/2.0f),(x2-x1)+lineWidth+step,lineWidth+step);
				return;
			}
		}
		
		predraw();
		currentColor.bind();
		TextureImpl.bindNone();

		LSR.start();
		LSR.vertex(x1,y1);
		LSR.vertex(x2,y2);
		LSR.end();
		
		postdraw();
	}
597303
public void drawLine(int x0, int y0, int x1, int y1, Color c) {
        int colorRGB = c.getRGB();
        int dy = y1 - y0;
        int dx = x1 - x0;
        int stepx, stepy;
        int fraction;


        if (dy < 0) {
            dy = -dy;
            stepy = -1;
        } else {
            stepy = 1;
        }
        if (dx < 0) {
            dx = -dx;
            stepx = -1;
        } else {
            stepx = 1;
        }
        dy <<= 1;                            // dy is now 2*dy
        dx <<= 1;                            // dx is now 2*dx

        setIntColor(x0, y0, colorRGB);

        if (dx > dy) {
            fraction = dy - (dx >> 1);    // same as 2*dy - dx
            while (x0 != x1) {
                if (fraction >= 0) {
                    y0 += stepy;
                    fraction -= dx;        // same as fraction -= 2*dx
                }
                x0 += stepx;
                fraction += dy;                // same as fraction -= 2*dy
                setIntColor(x0, y0, colorRGB);
            }
        } else {
            fraction = dx - (dy >> 1);
            while (y0 != y1) {
                if (fraction >= 0) {
                    x0 += stepx;
                    fraction -= dy;
                }
                y0 += stepy;
                fraction += dx;
                setIntColor(x0, y0, colorRGB);
            }
        }
    }
635737
function drawRadialHighlights(context, options) {
    let hlWidth = context.max *
        (parseFloat(options.highlightsWidth) || 0) / 100;

    if (!hlWidth) return;

    //noinspection JSUnresolvedFunction
    let r = abs(radialTicksRadius(context, options) - hlWidth / 2);
    let i = 0, s = options.highlights.length;
    let vd = (options.maxValue - options.minValue) / options.ticksAngle;

    context.save();

    for (; i < s; i++) {
        let hlt = options.highlights[i];

        context.beginPath();

        context.rotate(HPI);
        context.arc(0, 0, r,
            drawings.radians(options.startAngle +
                (hlt.from - options.minValue) / vd),
            drawings.radians(options.startAngle +
                (hlt.to - options.minValue) / vd),
            false
        );
        context.strokeStyle = hlt.color;
        context.lineWidth = hlWidth;
        context.stroke();
        context.closePath();

        context.restore();
        context.save();
    }
}
744387
function (renderer, x, y, tmxTile) {
            var tileset = tmxTile.tileset;
            var point = this.tileToPixelCoords(x, y, me.pool.pull("me.Vector2d"));

            // draw the tile
            tileset.drawTile(
                renderer,
                tileset.tileoffset.x + point.x,
                tileset.tileoffset.y + point.y + (this.tileheight - tileset.tileheight),
                tmxTile
            );

            me.pool.push(point);
        }
835448
function drawRadialNeedle(context, options) {
    if (!options.needle) return;

    let value = options.ticksAngle < 360 ?
        drawings.normalizedValue(options).indented : options.value;
    let max = maxRadialRadius(context, options);
    //noinspection JSUnresolvedFunction
    let r1 = abs(max / 100 * options.needleCircleSize);
    //noinspection JSUnresolvedFunction
    let r2 = abs(max / 100 * options.needleCircleSize * 0.75);
    //noinspection JSUnresolvedFunction
    let rIn = abs(max / 100 * options.needleEnd);
    //noinspection JSUnresolvedFunction
    let rStart = abs(options.needleStart ?
            max / 100 * options.needleStart : 0);
    //noinspection JSUnresolvedFunction
    let pad1 = max / 100 * options.needleWidth;
    let pad2 = max / 100 * options.needleWidth / 2;
    let pixelRatio = SmartCanvas.pixelRatio;
    let isFixed = options.animationTarget !== 'needle';

    context.save();

    drawings.drawNeedleShadow(context, options);

    context.rotate(drawings.radians(isFixed ? options.startAngle :
        (options.startAngle + (value -
            options.minValue) / (options.maxValue - options.minValue) *
            options.ticksAngle)));

    context.fillStyle = drawings.linearGradient(
        context,
        options.colorNeedle,
        options.colorNeedleEnd,
        rIn - rStart);

    if (options.needleType === 'arrow') {
        context.beginPath();
        context.moveTo(-pad2, -rStart);
        context.lineTo(-pad1, 0);
        context.lineTo(-1 * pixelRatio, rIn);
        context.lineTo(pixelRatio, rIn);
        context.lineTo(pad1, 0);
        context.lineTo(pad2, -rStart);
        context.closePath();
        context.fill();

        context.beginPath();
        context.lineTo(-0.5 * pixelRatio, rIn);
        context.lineTo(-1 * pixelRatio, rIn);
        context.lineTo(-pad1, 0);
        context.lineTo(-pad2, -rStart);
        context.lineTo(pad2 / 2 * pixelRatio - 2 * pixelRatio, -rStart);
        context.closePath();
        context.fillStyle = options.colorNeedleShadowUp;
        context.fill();
    }

    else { // simple line needle
        context.beginPath();
        context.moveTo(-pad2, rIn);
        context.lineTo(-pad2, rStart);
        context.lineTo(pad2, rStart);
        context.lineTo(pad2, rIn);
        context.closePath();
        context.fill();
    }

    if (options.needleCircleSize) {
        context.restore();

        drawings.drawNeedleShadow(context, options);

        if (options.needleCircleOuter) {
            context.beginPath();
            context.arc(0, 0, r1, 0, PI * 2, true);
            context.fillStyle = drawings.linearGradient(
                context,
                options.colorNeedleCircleOuter,
                options.colorNeedleCircleOuterEnd,
                r1
            );
            context.fill();
            context.closePath();
        }

        if (options.needleCircleInner) {
            context.beginPath();
            context.arc(0, 0, r2, 0, PI * 2, true);
            context.fillStyle = drawings.linearGradient(
                context,
                options.colorNeedleCircleInner,
                options.colorNeedleCircleInnerEnd,
                r2
            );
            context.fill();
            context.closePath();
        }

        context.restore();
    }
}
480190
function (x0, y0, radius, color, c)
    {
        _c = c || _c
        if (color)
        {
            _c.fillStyle = color
        }
        x0 *= _scale
        y0 *= _scale
        radius *= _scale
        let x = radius
        let y = 0
        let decisionOver2 = 1 - x   // Decision criterion divided by 2 evaluated at x=r, y=0

        while (x >= y)
        {
            box(-x + x0, y + y0, x * 2, 1)
            box(-y + x0, x + y0, y * 2, 1)
            box(-x + x0, -y + y0, x * 2, 1)
            box(-y + x0, -x + y0, y * 2, 1)
            y++
            if (decisionOver2 <= 0)
            {
                decisionOver2 += 2 * y + 1 // Change in decision criterion for y -> y+1
            } else
            {
                x--
                decisionOver2 += 2 * (y - x) + 1 // Change for y -> y+1, x -> x-1
            }
        }
    }
637565
function (ctx, x, y, radius, shadow) {
            // pi * r^2 = (2s)^2  =>  s = r * sqrt(pi)/2
            var size = radius * Math.sqrt(Math.PI) / 2;
            ctx.rect(x - size, y - size, size + size, size + size);
        }