1: #!/usr/local/bin/perl
2:
3: use GD;
4: require 5.002;
5: $file = "miss.gif";
6: $xp = 100;
7: $yp = 200;
8: $angle = 45;
9:
10: open(GIF,$file) || die("Cannot open $file.");
11: $im = newFromGif GD::Image(GIF) || die(
   "Cannot create image from $file.");
12: close GIF;
13:
14:
15: $color = $im->colorAllocate(0,0,255);
16:
17: $poly = &makeArrow($xp,$yp,$angle);
18:
19: $im->filledPolygon($poly,$color);
20:
21: print "Content-type: image/gif\n\n";
22: print $im->gif;
23: exit;
24:
25:
26: sub makeArrow {
27:   local($xpos,$ypos,$degrees) = @_;
28:   local(@x,@y,$xcenter,$ycenter,$theta);
29:   local($poly,$nx,$ny,$sin,$cos,$i);
30:
31:   $xcenter = 75;
32:   $ycenter = 75;
33:   @x = (75,50,65,65,85,85,100);
34:   @y = (75,100,100,140,140,100,100);
35:   $theta=$degrees/90.0*1.570796;
36:
37:   $poly = new GD::Polygon;
38:   for ($i=0 ; $i<scalar(@x) ; $i++) {
39:      $cos = cos($theta);
40:      $sin = sin($theta);
41:      $nx = $x[$i]*$cos - $y[$i]*$sin +
      $xcenter*(1.0-$cos) + $ycenter*$sin;
42:      $ny = $x[$i]*$sin + $y[$i]*$cos +
      $ycenter*(1.0-$cos) - $xcenter*$sin;
43:      $poly->addPt($nx + $xpos - 75,$ny +
      $ypos - 75);
44:   }
45:   return $poly;
46: }