claviska / SimpleImage

A PHP class that makes working with images and GD as simple as possible.
MIT License
1.38k stars 383 forks source link

Fix thickness problem with arc() and ellipse() #269

Closed maPer77 closed 3 years ago

maPer77 commented 3 years ago

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 teste11_before

After teste11_after

maPer77 commented 3 years ago

Optimization of "border()", without using "for()".

The "border()" can be drawn with a simple rectangle with thickness. Uses less processing.

claviska commented 3 years ago

Thanks for your continued effort here. Just let me know when you're ready for this to be reviewed. 😄

maPer77 commented 3 years ago
Left Right
teste14_before teste14_before
Center Justify
teste14_before teste14_before
Leading +7 Leading -7
teste14_before teste14_before
Font Scriptina Font Queenstown Signature
teste14_before teste14_before
maPer77 commented 3 years ago

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
    */
adaniello commented 3 years ago

Only one thought: array_key_last() requires PHP 7 >= 7.3.0, but SimpleImage no.

maPer77 commented 3 years ago

@adaniello Thank you very much!!! I fixed it.