You are here

function image_gd_textimage_draw_polygon in Textimage 7.3

Draw a polygon.

Parameters

object $image: Image

array $data: Effect data, an array: points - the polygon point coordinates array num_points - the number of polygon points fill_color - the rgba color of the polygon fill border_color - the rgba color of the polygon line

File

effects/textimage_text.gd.inc, line 258
GD2 toolkit for image manipulation within Textimage.

Code

function image_gd_textimage_draw_polygon($image, $data = array()) {
  if ($data['fill_color']) {
    $color = image_toolkit_invoke('textimage_imagecolor', $image, array(
      array(
        'rgba' => $data['fill_color'],
      ),
    ));
    $success = imagefilledpolygon($image->resource, $data['points'], $data['num_points'], $color);
    if (!$success) {
      return FALSE;
    }
  }
  if ($data['border_color']) {
    $color = image_toolkit_invoke('textimage_imagecolor', $image, array(
      array(
        'rgba' => $data['border_color'],
      ),
    ));
    $success = imagepolygon($image->resource, $data['points'], $data['num_points'], $color);
    if (!$success) {
      return FALSE;
    }
  }
}