Closed maPer77 closed 3 years ago
Optimization of "border()", without using "for()".
The "border()" can be drawn with a simple rectangle with thickness. Uses less processing.
Thanks for your continued effort here. Just let me know when you're ready for this to be reviewed. 😄
Left | Right |
---|---|
Center | Justify |
---|---|
Leading +7 | Leading -7 |
---|---|
Font Scriptina | Font Queenstown Signature |
---|---|
Hello @claviska The code is ready for review. I have doubts about the best order for the parameters in the documentation. As it got a little big, more than 200 lines, I thought it was better to separate the code in another file and use "trait". Can you tell me how you feel better.
/**
* Adds text with a line break to the image.
*
* @param string $text The desired text.
* @param array $options
* An array of options.
* - fontFile* (string) - The TrueType (or compatible) font file to use.
* - size (integer) - The size of the font in pixels (default 12).
* - color (string|array) - The text color (default black).
* - anchor (string) - The anchor point: 'center', 'top', 'bottom', 'left', 'right', 'top left', 'top right', 'bottom left', 'bottom right' (default 'center').
* - xOffset (integer) - The horizontal offset in pixels (default 0).
* - yOffset (integer) - The vertical offset in pixels (default 0).
* - shadow (array) - Text shadow params.
* - x* (integer) - Horizontal offset in pixels.
* - y* (integer) - Vertical offset in pixels.
* - color* (string|array) - The text shadow color.
* - $calcuateOffsetFromEdge (bool) - Calculate Offset referring to the edges of the image (default true).
* - width (int) - Width of text box (Default image width).
* - justify (string) - The justify: 'left', 'right', 'center', 'justify' (default 'left').
* - $leading (float) - Increase/decrease spacing between lines of text (default 0).
* - $opacity (float) - The opacity level of the text 0-1 (default 1).
* @throws \Exception
* @return \claviska\SimpleImage
*/
Only one thought: array_key_last() requires PHP 7 >= 7.3.0, but SimpleImage no.
@adaniello Thank you very much!!! I fixed it.
Fixes the problem when thickness is greater than 1, it occurs mainly with colors that have transparency. The thickness of the Ellipse was being drawn inside, all other shapes are drawn in the center. If you think it is better to keep the thickness inside I can change it.
Before
After