Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 1.17 KB

how-to-draw-empty-circle.md

File metadata and controls

41 lines (27 loc) · 1.17 KB

How to draw circle

Check antialiasing strategies to get smooth drawing.

<?php

$im = imagecreatetruecolor(400, 300);

$c_black = imageColorAllocate($im, 0,0,0);
$c_green = imageColorAllocate($im, 46,204,64);

imageellipse($im, 200, 150, 100, 100, $c_green);

imagePng($im, '/tmp/image.png');
  • imagecreatetruecolor - creates true color lib:GD image object with specified width & height
  • imageColorAllocate - creates color object to later use in image
  • imageellipse - creates ellipse with specified coordinates, radius and border color
  • 200, 150 - coordinates of center of circle
  • 100, 100 - horizontal and vertical radius should be equal to get circle
  • $c_green - fill color
  • imagePng - saves image in PNG format to the given path

group: circle

Example:

<?php

$im = imagecreatetruecolor(400, 300);

$c_black = imageColorAllocate($im, 0,0,0);
$c_green = imageColorAllocate($im, 46,204,64);

imageellipse($im, 200, 150, 100, 100, $c_green);

imagePng($im, '/tmp/image.png');