Skip to content

Loading…

This the a fork and pull request by Daniel O'Connor. #1

Closed
wants to merge 1 commit into from

2 participants

@CloCkWeRX
PEAR - PHP Extension and Application Repository member

Hey Steve, thanks a lot for this. Is there any chance you can adjust the code to fit with PEAR CS?

github UI is really unintuitive. I couldn't figure out how edit this patch or reply to this patch with the revised patch. The revised patch is here:

48bf8c8

Feel free to close this request.... if that's what supposed to be done....

PEAR - PHP Extension and Application Repository member
@CloCkWeRX
PEAR - PHP Extension and Application Repository member

Try
if (is_array(...)) {

@CloCkWeRX
PEAR - PHP Extension and Application Repository member

Indentation seems off here - should be a 4 space tab indent

@CloCkWeRX
PEAR - PHP Extension and Application Repository member

In a few places, there are nested if statements that all try to add to a result.

It might be clearer in the code to return $result when no more things can be added to it (the above seems to be one)

That also lets you swap the code from being
if () {
if () {
if() {
} else () {
}
}
}

to
if (!condition) {
return $result;
}

if (!condition2) {
return $result;
}
... etc

This tends to be a lot cleaner/more readable.

@CloCkWeRX
PEAR - PHP Extension and Application Repository member

48bf8c8 covers the review comments :)

@CloCkWeRX CloCkWeRX closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 36 additions and 8 deletions.
  1. +36 −8 Image/Canvas/SVG.php
View
44 Image/Canvas/SVG.php
@@ -227,14 +227,42 @@ function _getLineStyle($lineStyle = false)
}
// TODO Linestyles (i.e. fx. dotted) does not work
-
- if (($lineStyle != 'transparent') && ($lineStyle !== false)) {
- $result = 'stroke-width:' . $this->_thickness . ';';
- $result .= 'stroke:' .$this->_color($lineStyle) . ';';
- if ($opacity = $this->_opacity($lineStyle)) {
- $result .= 'stroke-opacity:' . $opacity . ';';
- }
- }
+ if(is_array($lineStyle))
+ {
+ if(count($lineStyle) == 2)
+ {
+ //dotted
+ if (($lineStyle[0] != 'transparent') && ($lineStyle[0] !== false)) {
+ $result = 'stroke-width:' . $this->_thickness . ';';
+ $result .= 'stroke:' .$this->_color($lineStyle[0]) . ';';
+ if ($opacity = $this->_opacity($lineStyle[0])) {
+ $result .= 'stroke-opacity:' . $opacity . ';';
+ }
+ $result .= 'stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:1;stroke-dasharray:1,4;stroke-dashoffset:1;';
+ }
+ }
+ else if(count($lineStyle) == 6)
+ {
+ //dashed
+ if (($lineStyle[0] != 'transparent') && ($lineStyle[0] !== false)) {
+ $result = 'stroke-width:' . $this->_thickness . ';';
+ $result .= 'stroke:' .$this->_color($lineStyle[0]) . ';';
+ if ($opacity = $this->_opacity($lineStyle[0])) {
+ $result .= 'stroke-opacity:' . $opacity . ';';
+ }
+ $result .= 'stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:1;stroke-dasharray:4,4;stroke-dashoffset:1;';
+ }
+ }
+ }
+ else{
+ if (($lineStyle != 'transparent') && ($lineStyle !== false)) {
+ $result = 'stroke-width:' . $this->_thickness . ';';
+ $result .= 'stroke:' .$this->_color($lineStyle) . ';';
+ if ($opacity = $this->_opacity($lineStyle)) {
+ $result .= 'stroke-opacity:' . $opacity . ';';
+ }
+ }
+ }
return $result;
}
Something went wrong with that request. Please try again.