We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
strokeText is very slow for high input (eg 10).
The following code is much more efficient (up to 40 times faster for strokeText = 10)
protected function strokeText($x, $y, $text) { $size = $this->strokeSize; if ($size <= 0) return; /* // Current algorithm for ($c1 = $x - $size; $c1 <= $x + $size; $c1++) { for ($c2 = $y - $size; $c2 <= $y + $size; $c2++) { $this->drawInternal(new Point($c1, $c2), $this->strokeColor, $text); } } */ $tmp_box = $this->calculateBox($text); $textWidth = $tmp_box->getWidth(); $textHeight = 1.5 * $tmp_box->getHeight(); $tmp_img = imagecreatetruecolor($textWidth, $textHeight); imagesavealpha($tmp_img, true); imagefill($tmp_img, 0, 0, imagecolorallocatealpha($tmp_img, 0, 0, 0, 127)); imagettftext( $tmp_img, $this->getFontSizeInPoints(), 0, // no rotation 0, $tmp_box->getHeight(), $this->strokeColor->getIndex($tmp_img), $this->fontFace, $text ); for ($c1 = $x - $size; $c1 <= $x + $size; $c1++) { for ($c2 = $y - $size; $c2 <= $y + $size; $c2++) { imagecopy($this->im, $tmp_img, $c1, $c2 - $tmp_box->getHeight(), 0, 0, $textWidth, $textHeight); } } imagedestroy($tmp_img); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
strokeText is very slow for high input (eg 10).
The following code is much more efficient (up to 40 times faster for strokeText = 10)
The text was updated successfully, but these errors were encountered: