claviska / claviska/SimpleImage

Dashed lines

Open
#202 1 comment 0 reactions 0 assignees View on GitHub
Feature Help Wanted
Dominant language
PHP
Stars
1.4k
Forks
377
PR merge metrics
No merged PRs in 30d

Description

Hi,

I have create a new function to draw dashed line :

```php
//
// Draws a dashed line.
//
// $x1* (int) - The x coordinate for the first point.
// $y1* (int) - The y coordinate for the first point.
// $x2* (int) - The x coordinate for the second point.
// $y2* (int) - The y coordinate for the second point.
// $color (string|array) - The line color.
// $thickness (int) - The line thickness (default 1).
// $dashedLength (int) - Length of the dashed (default 4)
//
// Returns a SimpleImage object.
//
public function lineDashed($x1, $y1, $x2, $y2, $color, $thickness = 1, $dashedLength = 4) {
// Allocate the color
$color = $this->allocateColor($color);

// Draw a line
imagesetthickness($this->image, $thickness);
$transparent = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
$style = array();
for ($i = 0; $i < $dashedLength; $i++) {
$style[] = $color;
}
for ($i = 0; $i < $dashedLength; $i++) {
$style[] = $transparent;
}
imagesetstyle($this->image, $style);
imageline($this->image, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);

return $this;
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the SimpleImage class and its existing line-drawing methods, then compare the proposed lineDashed function with the project's conventions. The change is done when the dashed-line functionality is integrated consistently and its behavior is verified; no specific file or test is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
computer-graphics
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.