Menu

#60 Requesting squared corners on squared plots

None
open
nobody
1
None
2016-01-08
2016-01-08
Toewe
No

It has long bothered me that the squared plot type has ragged corners on the ploted lines if the line width is greater than 1. The lines below were added/removed from the current (version 6.2.0) of phplot.php file at line 8075 to accomplish truely square corners. There may be a more elegant method to accomplish the same result, but this works for me.
The basic idea is to extend the length of each end of each line by half the line width.
$fudge = intval( $this->line_widths[$idx] / 2 );
$fudge1 = ( $this->line_widths[$idx] % 2 == 0 ) ? $fudge-1 : $fudge;
$fudge2 = ( $y_mid > $y_now_pixels ) ? $fudge-1 : -$fudge;
$fudge3 = ( $y_mid > $y_now_pixels ) ? $fudge : -$fudge+1;
ImageLine($this->img, $lastx[$idx]-$fudge, $y_mid, $x_now_pixels+$fudge1, $y_mid, $style);
ImageLine($this->img, $x_now_pixels, $y_mid+$fudge2, $x_now_pixels, $y_now_pixels-$fudge3, $style);
// ImageLine($this->img, $lastx[$idx], $y_mid, $x_now_pixels, $y_mid, $style);
// ImageLine($this->img, $x_now_pixels, $y_mid, $x_now_pixels, $y_now_pixels, $style);

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.