PHP 8.5.0 Alpha 1 available for testing

Voting

: two minus one?
(Example: nine)

The Note You're Voting On

pb_2001 at haefft dot de
19 years ago
This is a function to make a dotted line. It accepts (it actually requires) 7 parameters and returns 1 if everything went OK and 0 if there was a problem.

int imagelinedotted ( resource im, int x1, int y1, int x2, int y2, int dist, int col )

imagelinedotted() draws a line from x1, y1 to x2, y2 (top left is 0, 0) in image im of colour col where dist defines the distance (measured in pixels) between one dot and another.

<?php
function imagelinedotted ($im, $x1, $y1, $x2, $y2, $dist, $col) {
$transp = imagecolortransparent ($im);

$style = array ($col);

for (
$i=0; $i<$dist; $i++) {
array_push($style, $transp); // Generate style array - loop needed for customisable distance between the dots
}

imagesetstyle ($im, $style);
return (integer)
imageline ($im, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
imagesetstyle ($im, array($col)); // Reset style - just in case...
}
?>

<< Back to user notes page

To Top