Skip to content

Commit

Permalink
rename ::fromScratch to ::newCanvas and ->create to ->resetCanvas
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck ALARY committed Sep 8, 2021
1 parent 6c7f11d commit 1dcab18
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions docs/classes/DantSu/PHPImageEditor/Image.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -173,7 +173,7 @@ Return true if image is initialized


---
### ::fromScratch
### ::newCanvas

(Static method) Create a new image with transparent background

Expand All @@ -199,7 +199,7 @@ Return true if image is initialized


---
### ->create
### ->resetCanvas

Create a new image with transparent background

Expand Down
6 changes: 3 additions & 3 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/samples/sample1.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1dcab18

Please sign in to comment.