Draws an empty rectangle on the resource at a specific position with a determined color.

@param resource $im
@param int $x1
@param int $y1
@param int $x2
@param int $y2
@param int $color
501430
protected function drawRectangle($im, $x1, $y1, $x2, $y2, $color = self::COLOR_FG) {
        if ($this->scale === 1) {
            imagefilledrectangle($im,
                ($x1 + $this->offsetX) + $this->pushLabel[0],
                ($y1 + $this->offsetY) + $this->pushLabel[1],
                ($x2 + $this->offsetX) + $this->pushLabel[0],
                ($y2 + $this->offsetY) + $this->pushLabel[1],
                $this->getColor($im, $color));
        } else {
            imagefilledrectangle($im, ($x1 + $this->offsetX) * $this->scale + $this->pushLabel[0], ($y1 + $this->offsetY) * $this->scale + $this->pushLabel[1], ($x2 + $this->offsetX) * $this->scale + $this->pushLabel[0] + $this->scale - 1, ($y1 + $this->offsetY) * $this->scale + $this->pushLabel[1] + $this->scale - 1, $this->getColor($im, $color));
            imagefilledrectangle($im, ($x1 + $this->offsetX) * $this->scale + $this->pushLabel[0], ($y1 + $this->offsetY) * $this->scale + $this->pushLabel[1], ($x1 + $this->offsetX) * $this->scale + $this->pushLabel[0] + $this->scale - 1, ($y2 + $this->offsetY) * $this->scale + $this->pushLabel[1] + $this->scale - 1, $this->getColor($im, $color));
            imagefilledrectangle($im, ($x2 + $this->offsetX) * $this->scale + $this->pushLabel[0], ($y1 + $this->offsetY) * $this->scale + $this->pushLabel[1], ($x2 + $this->offsetX) * $this->scale + $this->pushLabel[0] + $this->scale - 1, ($y2 + $this->offsetY) * $this->scale + $this->pushLabel[1] + $this->scale - 1, $this->getColor($im, $color));
            imagefilledrectangle($im, ($x1 + $this->offsetX) * $this->scale + $this->pushLabel[0], ($y2 + $this->offsetY) * $this->scale + $this->pushLabel[1], ($x2 + $this->offsetX) * $this->scale + $this->pushLabel[0] + $this->scale - 1, ($y2 + $this->offsetY) * $this->scale + $this->pushLabel[1] + $this->scale - 1, $this->getColor($im, $color));
        }
    }
79878
private function createImage($x, $y, $width, $height, $new_width, $new_height, $interlace = false) {

		$resource = imagecreatetruecolor($new_width, $new_height);

		if(false === imagesavealpha($resource, true)) {
			trigger_error('Could not set the flag to save full alpha channel', E_USER_ERROR);
		}

		if(false === imagealphablending($resource, false)) {
			trigger_error('Could not set the blending mode', E_USER_ERROR);
		}

		if(false === imagefill($resource, 0, 0, imagecolorallocate($resource, 255, 255, 255))) {
			trigger_error('Could not flood fill the image', E_USER_ERROR);
		}

		if(false === imagecopyresampled($resource, $this -> image, 0, 0, $x, $y, $new_width, $new_height, $width, $height)) {
			trigger_error('Could not copy and resize part of an image with resampling', E_USER_ERROR);
		}

		if((true === $interlace && imageinterlace($this -> image, true)) || false === $interlace) {
				
			$this -> image = $resource;
			return $this -> image;
		}

		return false;
	}
317207
@Override
	public void draw(float x, float y) {
		init();
		draw(x,y,width,height);
	}
892580
function line($x1, $y1, $x2, $y2, $color, $width, $style = null) {
    $this->_set_line_style($width, "butt", "", $style);
    $this->_set_stroke_color($color);

    $y1 = $this->y($y1);
    $y2 = $this->y($y2);

    $this->_pdf->moveto($x1,$y1);
    $this->_pdf->lineto($x2, $y2);
    $this->_pdf->stroke();
  }
1306376
public function drawRectangle($X1, $Y1, $X2, $Y2, 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;
        $Ticks = isset($Format["Ticks"]) ? $Format["Ticks"] : null;
        $NoAngle = isset($Format["NoAngle"]) ? $Format["NoAngle"] : false;

        if ($X1 > $X2) {
            list($X1, $X2) = [$X2, $X1];
        }
        if ($Y1 > $Y2) {
            list($Y1, $Y2) = [$Y2, $Y1];
        }

        if ($this->Antialias) {
            if ($NoAngle) {
                $this->drawLine(
                    $X1 + 1,
                    $Y1,
                    $X2 - 1,
                    $Y1,
                    ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Ticks" => $Ticks]
                );
                $this->drawLine(
                    $X2,
                    $Y1 + 1,
                    $X2,
                    $Y2 - 1,
                    ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Ticks" => $Ticks]
                );
                $this->drawLine(
                    $X2 - 1,
                    $Y2,
                    $X1 + 1,
                    $Y2,
                    ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Ticks" => $Ticks]
                );
                $this->drawLine(
                    $X1,
                    $Y1 + 1,
                    $X1,
                    $Y2 - 1,
                    ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Ticks" => $Ticks]
                );
            } else {
                $this->drawLine(
                    $X1 + 1,
                    $Y1,
                    $X2 - 1,
                    $Y1,
                    ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Ticks" => $Ticks]
                );
                $this->drawLine(
                    $X2,
                    $Y1,
                    $X2,
                    $Y2,
                    ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Ticks" => $Ticks]
                );
                $this->drawLine(
                    $X2 - 1,
                    $Y2,
                    $X1 + 1,
                    $Y2,
                    ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Ticks" => $Ticks]
                );
                $this->drawLine(
                    $X1,
                    $Y1,
                    $X1,
                    $Y2,
                    ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Ticks" => $Ticks]
                );
            }
        } else {
            $Color = $this->allocateColor($this->Picture, $R, $G, $B, $Alpha);
            imagerectangle($this->Picture, $X1, $Y1, $X2, $Y2, $Color);
        }
    }
699469
public void setIntColor(int x, int y, int c0, int c1, int c2) {
        int alpha = (arrIntColor[((y * width + x))] & 0xFF000000) >>> 24;
        setIntColor(x, y, alpha, c0, c1, c2);
    }
708456
public function line($x1, $y1, $x2, $y2, $color, $width, $style = array())
    {
        $this->_set_stroke_color($color);
        $this->_set_line_style($width, "butt", "", $style);

        $this->_pdf->line($x1, $this->y($y1),
            $x2, $this->y($y2));
        $this->_set_line_transparency("Normal", $this->_current_opacity);
    }
960463
public static function intersection(
        ImagickRendererLine $l1,
        ImagickRendererLine $l2
    ) {
        $rs = $l1->rx * $l2->ry - $l1->ry * $l2->rx;

        if ($rs == 0) {
            return null;
        }
        
        $u = (($l2->Px - $l1->Px) * $l1->ry - ($l2->Py - $l1->Py) * $l1->rx) / $rs;

        return new Point(
            $l2->Px + $u * $l2->rx,
            $l2->Py + $u * $l2->ry
        );
    }
225315
public function drawLine($X1, $Y1, $X2, $Y2, 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;
        $Ticks = isset($Format["Ticks"]) ? $Format["Ticks"] : null;
        $Cpt = isset($Format["Cpt"]) ? $Format["Cpt"] : 1;
        $Mode = isset($Format["Mode"]) ? $Format["Mode"] : 1;
        $Weight = isset($Format["Weight"]) ? $Format["Weight"] : null;
        $Threshold = isset($Format["Threshold"]) ? $Format["Threshold"] : null;

        if ($this->Antialias == false && $Ticks == null) {
            if ($this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0) {
                $ShadowColor = $this->allocateColor(
                    $this->Picture,
                    $this->ShadowR,
                    $this->ShadowG,
                    $this->ShadowB,
                    $this->Shadowa
                );
                imageline(
                    $this->Picture,
                    $X1 + $this->ShadowX,
                    $Y1 + $this->ShadowY,
                    $X2 + $this->ShadowX,
                    $Y2 + $this->ShadowY,
                    $ShadowColor
                );
            }

            $Color = $this->allocateColor($this->Picture, $R, $G, $B, $Alpha);
            imageline($this->Picture, $X1, $Y1, $X2, $Y2, $Color);
            return 0;
        }

        $Distance = sqrt(($X2 - $X1) * ($X2 - $X1) + ($Y2 - $Y1) * ($Y2 - $Y1));
        if ($Distance == 0) {
            return -1;
        }

        /* Derivative algorithm for overweighted lines, re-route to polygons primitives */
        if ($Weight != null) {
            $Angle = $this->getAngle($X1, $Y1, $X2, $Y2);
            $PolySettings = ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "BorderAlpha" => $Alpha];

            if ($Ticks == null) {
                $Points = [];
                $Points[] = cos(deg2rad($Angle - 90)) * $Weight + $X1;
                $Points[] = sin(deg2rad($Angle - 90)) * $Weight + $Y1;
                $Points[] = cos(deg2rad($Angle + 90)) * $Weight + $X1;
                $Points[] = sin(deg2rad($Angle + 90)) * $Weight + $Y1;
                $Points[] = cos(deg2rad($Angle + 90)) * $Weight + $X2;
                $Points[] = sin(deg2rad($Angle + 90)) * $Weight + $Y2;
                $Points[] = cos(deg2rad($Angle - 90)) * $Weight + $X2;
                $Points[] = sin(deg2rad($Angle - 90)) * $Weight + $Y2;

                $this->drawPolygon($Points, $PolySettings);
            } else {
                for ($i = 0; $i <= $Distance; $i = $i + $Ticks * 2) {
                    $Xa = (($X2 - $X1) / $Distance) * $i + $X1;
                    $Ya = (($Y2 - $Y1) / $Distance) * $i + $Y1;
                    $Xb = (($X2 - $X1) / $Distance) * ($i + $Ticks) + $X1;
                    $Yb = (($Y2 - $Y1) / $Distance) * ($i + $Ticks) + $Y1;

                    $Points = [];
                    $Points[] = cos(deg2rad($Angle - 90)) * $Weight + $Xa;
                    $Points[] = sin(deg2rad($Angle - 90)) * $Weight + $Ya;
                    $Points[] = cos(deg2rad($Angle + 90)) * $Weight + $Xa;
                    $Points[] = sin(deg2rad($Angle + 90)) * $Weight + $Ya;
                    $Points[] = cos(deg2rad($Angle + 90)) * $Weight + $Xb;
                    $Points[] = sin(deg2rad($Angle + 90)) * $Weight + $Yb;
                    $Points[] = cos(deg2rad($Angle - 90)) * $Weight + $Xb;
                    $Points[] = sin(deg2rad($Angle - 90)) * $Weight + $Yb;

                    $this->drawPolygon($Points, $PolySettings);
                }
            }

            return 1;
        }

        $XStep = ($X2 - $X1) / $Distance;
        $YStep = ($Y2 - $Y1) / $Distance;

        for ($i = 0; $i <= $Distance; $i++) {
            $X = $i * $XStep + $X1;
            $Y = $i * $YStep + $Y1;

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

            if ($Threshold != null) {
                foreach ($Threshold as $Key => $Parameters) {
                    if ($Y <= $Parameters["MinX"] && $Y >= $Parameters["MaxX"]) {
                        if (isset($Parameters["R"])) {
                            $RT = $Parameters["R"];
                        } else {
                            $RT = 0;
                        }
                        if (isset($Parameters["G"])) {
                            $GT = $Parameters["G"];
                        } else {
                            $GT = 0;
                        }
                        if (isset($Parameters["B"])) {
                            $BT = $Parameters["B"];
                        } else {
                            $BT = 0;
                        }
                        if (isset($Parameters["Alpha"])) {
                            $AlphaT = $Parameters["Alpha"];
                        } else {
                            $AlphaT = 0;
                        }
                        $Color = ["R" => $RT, "G" => $GT, "B" => $BT, "Alpha" => $AlphaT];
                    }
                }
            }

            if ($Ticks != null) {
                if ($Cpt % $Ticks == 0) {
                    $Cpt = 0;
                    if ($Mode == 1) {
                        $Mode = 0;
                    } else {
                        $Mode = 1;
                    }
                }

                if ($Mode == 1) {
                    $this->drawAntialiasPixel($X, $Y, $Color);
                }
                $Cpt++;
            } else {
                $this->drawAntialiasPixel($X, $Y, $Color);
            }
        }

        return [$Cpt, $Mode];
    }
1028966
public function draw($im) {
        $c = count($this->data);
        for ($i = 0; $i < $c; $i++) {
            $this->drawChar($im, $this->data[$i], true);
        }

        $this->drawChar($im, '1', true);
        $this->drawText($im, 0, 0, $this->positionX, $this->thickness);
    }
1246061
public function addRectangle($x1, $y1, $x2, $y2, $colors = [0, 0, 0])
    {
        $color = imagecolorallocate($this->image(), $colors[0],  $colors[1],  $colors[2]);
        imagerectangle ( $this->image() , $x1 , $y1 , $x2 , $y2 ,  $color );
    }
101221
@Override
    public void paintIcon(Component c, Graphics g, int x, int y) {
        Graphics2D g2d = (Graphics2D) g.create();
        g2d.translate(x, y);

        double coef1 = (double) this.width / (double) getOrigWidth();
        double coef2 = (double) this.height / (double) getOrigHeight();
        g2d.scale(coef1, coef2);
        paint(g2d);
        g2d.dispose();
    }
734474
function filled_rectangle($x1, $y1, $w, $h, $color) {
    $this->_set_fill_color($color);

    $y1 = $this->y($y1) - $h;

    $this->_pdf->rect(floatval($x1), floatval($y1), floatval($w), floatval($h));
    $this->_pdf->fill();
  }
1051798
public void paintIcon (Component c, Graphics g, int x, int y)
    {
        Graphics2D g2 = (Graphics2D) g;
        // turn on anti-aliasing
        Object oldAlias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);

        Rectangle bounds = _shape.getBounds();
        int dx = x - bounds.x;
        int dy = y - bounds.y;
        g2.translate(dx, dy);
        if (_fillColor != null) {
            g2.setColor(_fillColor);
            g2.fill(_shape);
        }
        if (_outlineColor != null) {
            g2.setColor(_outlineColor);
            g2.draw(_shape);
        }
        g2.translate(-dx, -dy);
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAlias);
    }
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)
272415
public function draw($im, $x, $y) {
        if ($this->getRotationAngle() !== 0) {
            if (!function_exists('imagerotate')) {
                throw new CINDrawException('The method imagerotate doesn\'t exist on your server. Do not use any rotation.');
            }

            $w = imagefontwidth($this->font) * strlen($this->text);
            $h = imagefontheight($this->font);
            $gd = imagecreatetruecolor($w, $h);
            imagefilledrectangle($gd, 0, 0, $w - 1, $h - 1, $this->backgroundColor->allocate($gd));
            imagestring($gd, $this->font, 0, 0, $this->text, $this->foregroundColor->allocate($gd));
            $gd = imagerotate($gd, $this->rotationAngle, 0);
            imagecopy($im, $gd, $x, $y, 0, 0, imagesx($gd), imagesy($gd));
        } else {
            imagestring($im, $this->font, $x, $y, $this->text, $this->foregroundColor->allocate($im));
        }
    }
562680
private function getPixel($x, $y, Color $color)
    {
        return (new Rectangle($x * 80 + 40, $y * 80 + 40, 80, 80))
            ->setFillColor($color)
            ->setStrokeWidth(0);
    }