# drawing a heart shape with PHP image functions

This PHP code (suggested by the user Licson) draws a star all right:

``````<?php

header("Content-type: image/png");

function drawStar(\$img,\$x,\$y,\$radius,\$sides,\$color,\$spikness=0.5) {

\$point =array();

\$t = 0;

for(\$a = 0;\$a <= 360;\$a += 360/(\$sides*2)) {

\$t++;

if(\$t % 2 == 0) {

\$point[] = \$x + (\$radius * \$spikness) * cos(deg2rad(\$a));

\$point[] = \$y + (\$radius * \$spikness) * sin(deg2rad(\$a));

}else{

\$point[] = \$x + \$radius * cos(deg2rad(\$a));

\$point[] = \$y + \$radius * sin(deg2rad(\$a));

}

}

return imagefilledpolygon(\$img,\$point,\$sides*2,\$color);

}

\$width = 600;

\$height = 600;

\$image = imagecreate(\$width, \$height) or die("Failed to create stream");

\$bgcolor = imagecolorallocate(\$image, 255, 255, 255);

\$curvecolor = imagecolorallocate(\$image, 211, 211, 211);

drawStar ( \$image, 300, 300, 80, 5, \$curvecolor, 3);

imagepng(\$image);

imagedestroy(\$image);
?>
``````

I would like to draw with the PHP function imageline() a heart shape. I found mathematical formulas for a heart shape, for example: Mathematical equations of love, heart or Heart Curve, and I would like to plot such a function.

However, I cannot figure out how I can translate such a mathematical equation into a functionng PHP code.