Wrapper taking custom units and margins into account
@see \ZendPdf\Page::drawCircle() for documentation
15524
public function drawCircle($x, $y, $radius, $param4 = null, $param5 = null, $param6 = null)
    {
        // Don't convert units and call parent::drawCircle(), since it calls drawEllipse which will convert units twice!
        return $this->drawEllipse($x - $radius, $y - $radius, $x + $radius, $y + $radius, $param4, $param5, $param6);
    }
849841
public function drawEllipse($x1, $y1, $x2, $y2, $param5 = null, $param6 = null, $param7 = null)
    {
        $this->convertCoordinatesFromUserSpace($x1, $y1);
        $this->convertCoordinatesFromUserSpace($x2, $y2);
        list($y1, $y2) = array($y2, $y1);
        return parent::drawEllipse($x1, $y1, $x2, $y2, $param5, $param6, $param7);
    }
1266609
def drawPara(self, debug=0):
        """"""

        if self.debug:
            print (id(self), "drawPara", self.blPara.kind)

        #stash the key facts locally for speed
        canvas = self.canv
        style = self.style
        blPara = self.blPara
        lines = blPara.lines
        leading = style.leading
        autoLeading = getattr(self, 'autoLeading', getattr(style, 'autoLeading', ''))

        #work out the origin for line 1
        leftIndent = style.leftIndent
        cur_x = leftIndent

        if debug:
            bw = 0.5
            bc = Color(1, 1, 0)
            bg = Color(0.9, 0.9, 0.9)
        else:
            bw = getattr(style, 'borderWidth', None)
            bc = getattr(style, 'borderColor', None)
            bg = style.backColor

        #if has a background or border, draw it
        if bg or (bc and bw):
            canvas.saveState()
            op = canvas.rect
            kwds = dict(fill=0, stroke=0)
            if bc and bw:
                canvas.setStrokeColor(bc)
                canvas.setLineWidth(bw)
                kwds['stroke'] = 1
                br = getattr(style, 'borderRadius', 0)
                if br and not debug:
                    op = canvas.roundRect
                    kwds['radius'] = br
            if bg:
                canvas.setFillColor(bg)
                kwds['fill'] = 1
            bp = getattr(style, 'borderPadding', 0)
            op(leftIndent - bp,
               -bp,
               self.width - (leftIndent + style.rightIndent) + 2 * bp,
               self.height + 2 * bp,
               **kwds)
            canvas.restoreState()

        nLines = len(lines)
        bulletText = self.bulletText
        if nLines > 0:
            _offsets = getattr(self, '_offsets', [0])
            _offsets += (nLines - len(_offsets)) * [_offsets[-1]]
            canvas.saveState()
            alignment = style.alignment
            offset = style.firstLineIndent + _offsets[0]
            lim = nLines - 1
            noJustifyLast = not (hasattr(self, '_JustifyLast') and self._JustifyLast)

            if blPara.kind == 0:
                if alignment == TA_LEFT:
                    dpl = _leftDrawParaLine
                elif alignment == TA_CENTER:
                    dpl = _centerDrawParaLine
                elif self.style.alignment == TA_RIGHT:
                    dpl = _rightDrawParaLine
                elif self.style.alignment == TA_JUSTIFY:
                    dpl = _justifyDrawParaLine
                f = blPara
                cur_y = self.height - getattr(f, 'ascent', f.fontSize)    # TODO fix XPreformatted to remove this hack
                if bulletText:
                    offset = _drawBullet(canvas, offset, cur_y, bulletText, style)

                #set up the font etc.
                canvas.setFillColor(f.textColor)

                tx = self.beginText(cur_x, cur_y)
                if autoLeading == 'max':
                    leading = max(leading, LEADING_FACTOR * f.fontSize)
                elif autoLeading == 'min':
                    leading = LEADING_FACTOR * f.fontSize

                #now the font for the rest of the paragraph
                tx.setFont(f.fontName, f.fontSize, leading)
                ws = getattr(tx, '_wordSpace', 0)  
                t_off = dpl(tx, offset, ws, lines[0][1], noJustifyLast and nLines == 1)
                if f.underline or f.link or f.strike:
                    xs = tx.XtraState = ABag()
                    xs.cur_y = cur_y
                    xs.f = f
                    xs.style = style
                    xs.lines = lines
                    xs.underlines = []
                    xs.underlineColor = None
                    # XXX Modified for XHTML2PDF
                    xs.backgrounds = []
                    xs.backgroundColor = None
                    xs.backgroundFontSize = None
                    xs.strikes = []
                    xs.strikeColor = None
                    # XXX Modified for XHTML2PDF
                    xs.strikeFontSize = None
                    xs.links = []
                    xs.link = f.link
                    canvas.setStrokeColor(f.textColor)
                    dx = t_off + leftIndent
                    if dpl != _justifyDrawParaLine: ws = 0
                    # XXX Never underline!
                    underline = f.underline
                    strike = f.strike
                    link = f.link
                    if underline:
                        _do_under_line(0, dx, ws, tx)
                    if strike:
                        _do_under_line(0, dx, ws, tx, lm=0.125)
                    if link: _do_link_line(0, dx, ws, tx)

                    #now the middle of the paragraph, aligned with the left margin which is our origin.
                    for i in six.moves.range(1, nLines):
                        ws = lines[i][0]
                        t_off = dpl(tx, _offsets[i], ws, lines[i][1], noJustifyLast and i == lim)
                        if dpl != _justifyDrawParaLine: ws = 0
                        if underline: _do_under_line(i, t_off + leftIndent, ws, tx)
                        if strike: _do_under_line(i, t_off + leftIndent, ws, tx, lm=0.125)
                        if link: _do_link_line(i, t_off + leftIndent, ws, tx)
                else:
                    for i in six.moves.range(1, nLines):
                        dpl(tx, _offsets[i], lines[i][0], lines[i][1], noJustifyLast and i == lim)
            else:
                f = lines[0]
                cur_y = self.height - getattr(f, 'ascent', f.fontSize)    # TODO fix XPreformatted to remove this hack
                # default?
                dpl = _leftDrawParaLineX
                if bulletText:
                    offset = _drawBullet(canvas, offset, cur_y, bulletText, style)
                if alignment == TA_LEFT:
                    dpl = _leftDrawParaLineX
                elif alignment == TA_CENTER:
                    dpl = _centerDrawParaLineX
                elif self.style.alignment == TA_RIGHT:
                    dpl = _rightDrawParaLineX
                elif self.style.alignment == TA_JUSTIFY:
                    dpl = _justifyDrawParaLineX
                else:
                    raise ValueError("bad align %s" % repr(alignment))

                #set up the font etc.
                tx = self.beginText(cur_x, cur_y)
                xs = tx.XtraState = ABag()
                xs.textColor = None
                # XXX Modified for XHTML2PDF
                xs.backColor = None
                xs.rise = 0
                xs.underline = 0
                xs.underlines = []
                xs.underlineColor = None
                # XXX Modified for XHTML2PDF
                xs.background = 0
                xs.backgrounds = []
                xs.backgroundColor = None
                xs.backgroundFontSize = None
                xs.strike = 0
                xs.strikes = []
                xs.strikeColor = None
                # XXX Modified for XHTML2PDF
                xs.strikeFontSize = None
                xs.links = []
                xs.link = None
                xs.leading = style.leading
                xs.leftIndent = leftIndent
                tx._leading = None
                tx._olb = None
                xs.cur_y = cur_y
                xs.f = f
                xs.style = style
                xs.autoLeading = autoLeading

                tx._fontname, tx._fontsize = None, None
                dpl(tx, offset, lines[0], noJustifyLast and nLines == 1)
                _do_post_text(tx)

                #now the middle of the paragraph, aligned with the left margin which is our origin.
                for i in six.moves.range(1, nLines):
                    f = lines[i]
                    dpl(tx, _offsets[i], f, noJustifyLast and i == lim)
                    _do_post_text(tx)

            canvas.drawText(tx)
            canvas.restoreState()
1051557
public function svgEllipse($x0, $y0, $rx, $ry, $style)
    {
        // get the Closing operator from the PDF Style
        if ($style === 'F') {
            $op='f';
        } elseif ($style === 'FD' || $style === 'DF') {
            $op='B';
        } else {
            $op='S';
        }

        // drawing
        $this->_Arc($x0, $y0, $rx, $ry, 0, 2*M_PI, true, true, true);
        $this->_out($op);
    }
1238685
public void drawCircles( double[][][] houghValues, byte[] circlespixels ) {

        // Copy original input pixels into output
        // circle location display image and
        // combine with saturation at 100
        int roiaddr = 0;
        for( int y = offy; y < offy + height; y++ ) {
            for( int x = offx; x < offx + width; x++ ) {
                // Copy;
                circlespixels[roiaddr] = imageValues[x + offset * y];
                // Saturate
                if (circlespixels[roiaddr] != 0)
                    circlespixels[roiaddr] = 100;
                else
                    circlespixels[roiaddr] = 0;
                roiaddr++;
            }
        }
        // Copy original image to the circlespixels image.
        // Changing pixels values to 100, so that the marked
        // circles appears more clear. Must be improved in
        // the future to show the resuls in a colored image.
        // for(int i = 0; i < width*height ;++i ) {
        // if(imageValues[i] != 0 )
        // if(circlespixels[i] != 0 )
        // circlespixels[i] = 100;
        // else
        // circlespixels[i] = 0;
        // }
        // if (centerPoints == null) {
        // if (useThreshold)
        // getCenterPointsByThreshold(threshold);
        // else
        Coordinate[] centerPoints = getCenterPoints(houghValues, maxCircles);
        // }
        byte cor = -1;
        // Redefine these so refer to ROI coordinates exclusively
        int offset = width;
        int offx = 0;
        int offy = 0;

        for( int l = 0; l < maxCircles; l++ ) {
            int i = (int) centerPoints[l].x;
            int j = (int) centerPoints[l].y;
            // Draw a gray cross marking the center of each circle.
            for( int k = -10; k <= 10; ++k ) {
                int p = (j + k + offy) * offset + (i + offx);
                if (!outOfBounds(j + k + offy, i + offx))
                    circlespixels[(j + k + offy) * offset + (i + offx)] = cor;
                if (!outOfBounds(j + offy, i + k + offx))
                    circlespixels[(j + offy) * offset + (i + k + offx)] = cor;
            }
            for( int k = -2; k <= 2; ++k ) {
                if (!outOfBounds(j - 2 + offy, i + k + offx))
                    circlespixels[(j - 2 + offy) * offset + (i + k + offx)] = cor;
                if (!outOfBounds(j + 2 + offy, i + k + offx))
                    circlespixels[(j + 2 + offy) * offset + (i + k + offx)] = cor;
                if (!outOfBounds(j + k + offy, i - 2 + offx))
                    circlespixels[(j + k + offy) * offset + (i - 2 + offx)] = cor;
                if (!outOfBounds(j + k + offy, i + 2 + offx))
                    circlespixels[(j + k + offy) * offset + (i + 2 + offx)] = cor;
            }
        }
    }
954674
private function _renderAreaChart($groupCount, $dimensions = '2d') {
		require_once('jpgraph_line.php');

		$this->_renderCartesianPlotArea();

		for($i = 0; $i < $groupCount; ++$i) {
			$this->_renderPlotLine($i,True,False,$dimensions);
		}
	}
977180
public /*internal*/ function draw($im, $x1, $y1, $x2, $y2) {
        $x = 0;
        $y = 0;

        $fontDimension = $this->font->getDimension();

        if ($this->position === self::POSITION_TOP || $this->position === self::POSITION_BOTTOM) {
            if ($this->position === self::POSITION_TOP) {
                $y = $y1 - $this->spacing - $fontDimension[1];
            } elseif ($this->position === self::POSITION_BOTTOM) {
                $y = $y2 + $this->spacing;
            }

            if ($this->alignment === self::ALIGN_CENTER) {
                $x = ($x2 - $x1) / 2 + $x1 - $fontDimension[0] / 2 + $this->offset;
            } elseif ($this->alignment === self::ALIGN_LEFT)  {
                $x = $x1 + $this->offset;
            } else {
                $x = $x2 + $this->offset - $fontDimension[0];
            }
        } else {
            if ($this->position === self::POSITION_LEFT) {
                $x = $x1 - $this->spacing - $fontDimension[0];
            } elseif ($this->position === self::POSITION_RIGHT) {
                $x = $x2 + $this->spacing;
            }

            if ($this->alignment === self::ALIGN_CENTER) {
                $y = ($y2 - $y1) / 2 + $y1 - $fontDimension[1] / 2 + $this->offset;
            } elseif ($this->alignment === self::ALIGN_TOP)  {
                $y = $y1 + $this->offset;
            } else {
                $y = $y2 + $this->offset - $fontDimension[1];
            }
        }

        $this->font->setText($this->text);
        $this->font->draw($im, $x, $y);
    }
1240874
private void drawCircleDown(@NonNull Canvas canvas, float step, float radius) {
    canvas.drawCircle(
            xCoordinate + step,
            getMeasuredHeight() / 2,
            bounceDotRadius - radius,
            endPaint
    );
  }
678198
public function drawImage($PDFFilePath = '', $outputPath = '', $dpi = 92, $page = 1, $imageType = 'JPEG')
    {
        $draw = new \PDFDraw();
        $draw->SetDPI($dpi);

        $doc = new \PDFDoc($PDFFilePath);
        $doc->InitSecurityHandler();
        $pg = $doc->GetPage($page);
        $draw->Export($pg, $outputPath, $imageType);
        $doc->Close();
    }
263921
public function getIconBounds() 
    {
        // Round padding to nearest integer
        $padding = (int)($this->style->getPadding() * $this->size + 0.5);
        
        return new Rectangle(
            $padding, $padding,
            $this->size - $padding * 2,
            $this->size - $padding * 2);
    }
326516
function drawEndMarker(){
            if (circle) {
                svg.selectAll('.sparkline-circle').remove();
            }

            circle = svg.selectAll('.chart-group')
              .append('circle')
                .attr('class', 'sparkline-circle')
                .attr('cx', xScale(data[data.length - 1].date))
                .attr('cy', yScale(data[data.length - 1].value))
                .attr('r', markerSize);
        }
191041
function DrawLegend($which_x1,$which_y1,$which_boxtype) {
    //Base code submitted by Marlin Viss
    $max_legend_length=0;
    reset($this->legend);
    while (list(,$leg) = each($this->legend)) {
      $len = strlen($leg);
      if ($max_legend_length < $len) {
        $max_legend_length = $len;
      }
    }

    $line_spacing = 1.25;
    $vert_margin = $this->small_font_height/2 ;
    $dot_height = $this->small_font_height*$line_spacing - 1;

  //Upper Left
    if ((!$which_x1) || (!$which_y1) ) {
      $box_start_x = $this->plot_area[2] - $this->small_font_width*($max_legend_length+4);
      $box_start_y = $this->plot_area[1] + 4;
    } else {
      $box_start_x = $which_x1;
      $box_start_y = $which_y1;
    }

  //Lower Right
    $box_end_y = $box_start_y + $this->small_font_height*(count($this->legend)+1) + 2*$vert_margin;
    //$box_end_x = $this->plot_area[2] - 5;
    $box_end_x = $box_start_x + $this->small_font_width*($max_legend_length+4) - 5;


  // Draw box for legend
    ImageFilledRectangle($this->img,
      $box_start_x, $box_start_y,$box_end_x,
      $box_end_y, $this->ndx_bg_color);
    ImageRectangle($this->img,
      $box_start_x, $box_start_y,$box_end_x,
      $box_end_y, $this->ndx_grid_color);

    $color_index=0;
    $i = 0;


    reset($this->legend);


    while (list(,$leg) = each($this->legend)) {
      $y_pos = $box_start_y + $this->small_font_height*($i)*($line_spacing) + $vert_margin;

      ImageString($this->img, $this->small_font,
      $box_start_x + $this->small_font_width*( $max_legend_length - strlen($leg) + 1 ) ,
      $y_pos,
      $leg, $this->ndx_text_color);

      if ($color_index >= count($this->ndx_data_color)) $color_index=0;
  // Draw a box in the data color
      ImageFilledRectangle($this->img,
        $box_end_x - $this->small_font_width*2,
        $y_pos + 1, $box_end_x - $this->small_font_width,
        $y_pos + $dot_height,
        $this->ndx_data_color[$color_index]);

      ImageRectangle($this->img,
        $box_end_x - $this->small_font_width*2,
        $y_pos + 1, $box_end_x - $this->small_font_width,
        $y_pos + $dot_height,
        $this->ndx_text_color);
      $i++;
      $color_index++;
    }
  }
637002
private void drawCircleUp(@NonNull Canvas canvas, float step, float radius) {
    canvas.drawCircle(
            xCoordinate + step,
            getMeasuredHeight() / 2,
            dotRadius + radius,
            startPaint
    );
  }
545045
private void drawCenterCircle(Canvas canvas) {
        final PieChartData data = dataProvider.getPieChartData();
        final float circleRadius = originCircleOval.width() / 2f;
        final float centerRadius = circleRadius * data.getCenterCircleScale();
        final float centerX = originCircleOval.centerX();
        final float centerY = originCircleOval.centerY();

        canvas.drawCircle(centerX, centerY, centerRadius, centerCirclePaint);

        // Draw center text1 and text2 if not empty.
        if (!TextUtils.isEmpty(data.getCenterText1())) {

            final int text1Height = Math.abs(centerCircleText1FontMetrics.ascent);

            if (!TextUtils.isEmpty(data.getCenterText2())) {
                // Draw text 2 only if text 1 is not empty.
                final int text2Height = Math.abs(centerCircleText2FontMetrics.ascent);
                canvas.drawText(data.getCenterText1(), centerX, centerY - text1Height * 0.2f, centerCircleText1Paint);
                canvas.drawText(data.getCenterText2(), centerX, centerY + text2Height, centerCircleText2Paint);
            } else {
                canvas.drawText(data.getCenterText1(), centerX, centerY + text1Height / 4, centerCircleText1Paint);
            }
        }
    }
960072
private function drawCapatchaImageText()
	{
		
		#	Create Image Text
	
		# here we will first create background text, then front text
		# we will set x- position
		# initial front text position 'initial_x'
		# current position 'current_x'
		
		$this->_front_text['initial_x'] = $this->_front_text['x'] = rand( 10, 25 );
		
		# Background Text
		# X, Y positions
		
		$this->_background_text['x'] = $this->_front_text['x'] / 2;
		$this->_background_text['y'] = ( $this->_calculated_text_box['dimensions']['height'] ) + ( $this->_calculated_text_box['additional_height'] / 2 );

		// Developing::preview( $this->_calculated_text_box['additional_height'], $this->_image_info['height'] - $this->_calculated_text_box['dimensions']['height'] );
		
		$characters = str_split( $this->_code, 1 );
		
		# Generating background text By Drawing letter by letter
		foreach( $characters as $char )
		{
			# character rotation angle
			$rotation_angle = rand( 0 - $this->_rotation_angle, $this->_rotation_angle );

			# get color rgb values
			$rgb = $this->getRGBFromRange(
				$this->_background_text['color'][0],
				$this->_background_text['color'][1],
				$this->_background_text['color'][2],
				$this->_background_text['color']['range']
				);
			
			$character_color = imagecolorallocatealpha(
				$this->_image_resource,
				$rgb[0],
				$rgb[1],
				$rgb[2],
				$this->_background_text['color'][3]
				);

			# check to add the blocks seperation distance
			if( $char === ' ' )
				$this->_background_text['x'] += $this->_blocks_seperation;
			
			# Draw Character to the image
			imagettftext(
				$this->_image_resource,					# Image resource
				$this->_background_text['size'],		# Font Size
				$rotation_angle,						# Text Angle
				$this->_background_text['x'],			# X Position
				$this->_background_text['y'],			# Y Position
				$character_color,						# Color
				$this->_background_text['font'],		# Font
				$char 									# Text
				);
			
			# move x to the next position			
			// $this->_background_text['x'] += $this->getTextBoxDimensions(
			// 	$this->_background_text['size'],
			// 	$rotation_angle,
			// 	$this->_background_text['font'],
			// 	$char
			// 	)['width'];

			$box_dimension = $this->getTextBoxDimensions(
				$this->_background_text['size'],
				$rotation_angle,
				$this->_background_text['font'],
				$char
				);

			$this->_background_text['x'] += $box_dimension['width'];
			

			# Method End
		}
		
		
		# space between characters equal 1/4  average character width
		$space_between_chars = $this->_calculated_text_box['char_width'] / 4;

		# final character index
		$final_character_index = $this->_code_length - 1;
		
		
		# Front Text
		foreach( $characters as $index => $char )
		{
			
			# the same as background text
			
			$rotation_angle = rand( 0 - $this->_rotation_angle, $this->_rotation_angle );
			
			# get color rgb values
			$rgb = $this->getRGBFromRange(
				$this->_front_text['color'][0],
				$this->_front_text['color'][1],
				$this->_front_text['color'][2],
				$this->_front_text['color']['range']
				);

			$character_color = imagecolorallocatealpha(
				$this->_image_resource,
				$rgb[0],
				$rgb[1],
				$rgb[2],
				$this->_front_text['color'][3]
				);

			# Calculate Character Dimensions
			$character_box = $this->getTextBoxDimensions(
				$this->_front_text['size'],
				$rotation_angle,
				$this->_front_text['font'],
				$char
				);

			# # calculate y position
			// $this->_front_text['y'] = ( $character_box['height'] - abs( $character_box['points'][1] ) ) + ( ( $this->_image_info['height'] - $character_box['height'] ) / 2 );
			// Developing::preview( 'index' . $index . ': ' . ( $character_box['height'] - abs( $character_box['points'][1] ) ), 'index' . $index . ': ' . $character_box['points'][5] );
			// exit;
			
			$this->_front_text['y'] = abs( $character_box['height'] ) + ( ( $this->_image_info['height'] - $character_box['height'] ) / 2 ) ; 
			
			# check to add the blocks seperation distance
			if( $char === ' ' )
				$this->_front_text['x'] += $this->_blocks_seperation;
			
			
			# Draw Character To Image
			imagettftext(
						 $this->_image_resource,
						 $this->_front_text['size'],
						 $rotation_angle,
						 $this->_front_text['x'],
						 $this->_front_text['y'],
						 $character_color,
						 $this->_front_text['font'],
						 $char
						);
			
			$this->_front_text['x'] += $character_box['width'];
			
			$this->_front_text['x'] += ( $index !== $final_character_index ) ? $space_between_chars : null;
		
		}

		# Method End	
	}
757460
def _draw_background(self, divisions=10):
        
        self.canvas.create_arc(2, 2, self.size-2, self.size-2,
                               style=tk.PIESLICE, start=-60, extent=30,
                               fill='red')
        self.canvas.create_arc(2, 2, self.size-2, self.size-2,
                               style=tk.PIESLICE, start=-30, extent=60,
                               fill='yellow')
        self.canvas.create_arc(2, 2, self.size-2, self.size-2,
                               style=tk.PIESLICE, start=30, extent=210,
                               fill='green')

        # find the distance between the center and the inner tick radius
        inner_tick_radius = int(self.size * 0.4)
        outer_tick_radius = int(self.size * 0.5)

        for tick in range(divisions):
            angle_in_radians = (2.0 * cmath.pi / 3.0) \
                               + tick/divisions * (5.0 * cmath.pi / 3.0)
            inner_point = cmath.rect(inner_tick_radius, angle_in_radians)
            outer_point = cmath.rect(outer_tick_radius, angle_in_radians)

            self.canvas.create_line(
                *self.to_absolute(inner_point.real, inner_point.imag),
                *self.to_absolute(outer_point.real, outer_point.imag),
                width=1
            )
1248547
def draw_oval(x, y, width, height)
      @context.drawOval(x, y, width, height)
    end