From 1dcab184b8cf7bc46440336bc292a1cf9e4b6b8e Mon Sep 17 00:00:00 2001 From: Franck ALARY Date: Wed, 8 Sep 2021 11:00:34 +0200 Subject: [PATCH] rename ::fromScratch to ::newCanvas and ->create to ->resetCanvas --- README.md | 2 +- docs/classes/DantSu/PHPImageEditor/Image.md | 8 ++++---- src/Image.php | 6 +++--- src/samples/sample1.php | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0f31aac..c04a88b 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ use \DantSu\PHPImageEditor\Image; \header('Content-type: image/png'); -$image = Image::fromScratch(500, 500) +$image = Image::newCanvas(500, 500) ->drawRectangle(0, 0, 500, 500, '#444') ->drawRectangle(0, 350, 500, 500, '#FF8800') ->writeText('I got the power !', __DIR__ . '/resources/font.ttf', 40, '#FFFFFF', Image::ALIGN_CENTER, 310) diff --git a/docs/classes/DantSu/PHPImageEditor/Image.md b/docs/classes/DantSu/PHPImageEditor/Image.md index 5cf5dec..8d666f2 100644 --- a/docs/classes/DantSu/PHPImageEditor/Image.md +++ b/docs/classes/DantSu/PHPImageEditor/Image.md @@ -31,8 +31,8 @@ DantSu\PHPImageEditor\Image is PHP library to easily edit image with GD extensio - [getType](#-gettype) - [getImage](#-getimage) - [isImageDefined](#-isimagedefined) -- *(static)* [fromScratch](#fromscratch) -- [create](#-create) +- *(static)* [newCanvas](#newcanvas) +- [resetCanvas](#-resetcanvas) - *(static)* [fromPath](#frompath) - [path](#-path) - *(static)* [fromForm](#fromform) @@ -173,7 +173,7 @@ Return true if image is initialized --- -### ::fromScratch +### ::newCanvas (Static method) Create a new image with transparent background @@ -199,7 +199,7 @@ Return true if image is initialized --- -### ->create +### ->resetCanvas Create a new image with transparent background diff --git a/src/Image.php b/src/Image.php index 3cd7675..99bc9bc 100644 --- a/src/Image.php +++ b/src/Image.php @@ -99,9 +99,9 @@ public function isImageDefined(): bool * @param int $height Pixel height of the image * @return Image Return Image instance */ - public static function fromScratch(int $width, int $height): Image + public static function newCanvas(int $width, int $height): Image { - return (new Image)->create($width, $height); + return (new Image)->resetCanvas($width, $height); } /** @@ -111,7 +111,7 @@ public static function fromScratch(int $width, int $height): Image * @param int $height Pixel height of the image * @return $this Fluent interface */ - public function create(int $width, int $height): Image + public function resetCanvas(int $width, int $height): Image { if (($this->image = \imagecreatetruecolor($width, $height)) === false) { $this->resetFields(); diff --git a/src/samples/sample1.php b/src/samples/sample1.php index 2eb4247..6a055ad 100644 --- a/src/samples/sample1.php +++ b/src/samples/sample1.php @@ -7,7 +7,7 @@ \header('Content-type: image/png'); -$image = Image::fromScratch(500, 500) +$image = Image::newCanvas(500, 500) ->drawRectangle(0, 0, 500, 500, '#444') ->drawRectangle(0, 350, 500, 500, '#FF8800') ->writeText('I got the power !', __DIR__ . '/resources/font.ttf', 40, '#FFFFFF', Image::ALIGN_CENTER, 310)