/usr/share/php/Imlib/class.ImlibPoly.php is in php-imlib 0.7-4.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | <?php
/**
* Does everything relevant to creating and drawing or filling an n-point polygon
*
* The routine for getting a polygon onto an image is generally to create one,
* add all its points (The order in which the points are added determines how
* the polygon will be drawn), set the image to draw on, and draw.
*
* @version 0.3
* @author Matt McClanahan <cardinal@dodds.net>
* @package Imlib
* @access public
*/
class ImlibPoly extends ImlibCliprect
{
/**
* Resource id# of the image to draw on
*
* @access private
*/
var $im;
/**
* The resource id# of the current polygon
*
* @access private
*/
var $poly;
/**
* ImlibPoly constructor
*
* @access public
*/
function ImlibPoly()
{
$this->cliprect = 0;
$this->cliprect_inuse = 0;
$this->color = 0;
$this->im = 0;
$this->poly = 0;
}
/**
* Add a point to the current polygon
*
* @param int X coordinate
* @param int Y coordinate
* @return bool False if there is no polygon set
* @access public
*/
function add_point($x,$y)
{
if (!is_resource($this->poly))
return false;
imlib_polygon_add_point($this->poly,$x,$y);
}
/**
* Checks if the current polygon contains a given point
*
* @param int X coordinate
* @param int Y coordinate
* @return bool True if it does, false otherwise
* @access public
*/
function contains_point($x,$y)
{
if (!is_resource($this->poly))
return false;
return imlib_polygon_contains_point($this->poly,$x,$y);
}
/**
* Draw the current polygon on the current image
*
* @param integer If true, the polygon will be drawn with the endpoints connected
* @return bool False if there is no polygon or image set
* @access public
*/
function draw($closed=1)
{
if (!is_resource($this->im) || !is_resource($this->poly))
return false;
if (!$this->get_color($r,$g,$b,$a))
list($r,$g,$b,$a) = Array(255,255,255,255);
if ($this->cliprect_inuse)
imlib_image_draw_polygon($this->im,$this->poly,$closed,$r,$g,$b,$a,
$this->get_cliprect_array());
else
imlib_image_draw_polygon($this->im,$this->poly,$closed,$r,$g,$b,$a);
}
/**
* Fill the current polygon on the current image
*
* @return bool False if there is no polygon or image set
* @access public
*/
function fill()
{
if (!is_resource($this->im) || !is_resource($this->poly))
return false;
if (!$this->get_color($r,$g,$b,$a))
list($r,$g,$b,$a) = Array(255,255,255,255);
if ($this->cliprect_inuse)
imlib_image_fill_polygon($this->im,$this->poly,$r,$g,$b,$a,
$this->get_cliprect_array());
else
imlib_image_fill_polygon($this->im,$this->poly,$r,$g,$b,$a);
}
/**
* Free the current polygon
*
* @return bool False if there is no polygon or image set
* @access public
*/
function free()
{
if (!is_resource($this->poly))
return false;
imlib_polygon_free($this->poly);
$this->poly = 0;
}
/**
* Get the bounds of the polygon
*
* @param int Upper left X coordinate
* @param int Upper left Y coordinate
* @param int Lower right X coordinate
* @param int Lower right Y coordinate
* @return bool False if there is no polygon or image set
* @access public
*/
function get_bounds(&$x1,&$y1,&$x2,&$y2)
{
if (!is_resource($this->poly))
return false;
imlib_polygon_get_bounds($this->poly,$x1,$y1,$x2,$y2);
}
/**
* Get the current image resource id#
*
* @return int Current image resource id#
* @access public
*/
function get_image()
{
return $this->im;
}
/**
* Create a new polygon
*
* @return int Resource id# of the new polygon
* @access public
*/
function new_poly()
{
if (is_resource($this->poly))
return false;
return $this->poly = imlib_polygon_new();
}
/**
* Set the image resource id# to draw on
*
* @param int Image resource id#
* @access public
*/
function set_image($im)
{
$this->im = $im;
}
};
?>
|