Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ozdemirburak committed Oct 19, 2023
1 parent 4d01791 commit 9d2cc51
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,33 +191,13 @@ echo $color->alpha(); // 0.33

### Color Cloning

There's some case that you need to clone the existing object. In this case, you
can use `clone()` feature to do such feat.
You can clone a color object to make a copy and modify it as needed.

```php
use OzdemirBurak\Iris\Color\Hex;

$hex = new Hex('#b2b2b2');
$hexa1 = $hex->toHexa()->alpha(0.5); // OzdemirBurak\Iris\Color\Hexa('#b2b2b27f')

$hexa2 = $hexa1->clone(); // OzdemirBurak\Iris\Color\Hexa('#b2b2b27f')
$hexa2->alpha(0.7); // OzdemirBurak\Iris\Color\Hexa('#b2b2b2b2')
$hexa2->red('14'); // OzdemirBurak\Iris\Color\Hexa('#14b2b2b2')
$hexa2->green('b8'); // OzdemirBurak\Iris\Color\Hexa('#14b8b2b2')
$hexa2->blue('a6'); // OzdemirBurak\Iris\Color\Hexa('#14b8a6b2')

echo $hexa1->red(); // b2
echo $hexa1->green(); // b2
echo $hexa1->blue(); // b2
echo $hexa1->alpha(); // 0.5

echo $hexa2->red(); // 14
echo $hexa2->green(); // b8
echo $hexa2->blue(); // a6
echo $hexa2->alpha(); // 0.5

echo $hexa1; // OzdemirBurak\Iris\Color\Hexa('#b2b2b27f')
echo $hexa2; // OzdemirBurak\Iris\Color\Hexa('#14b8a6b2')
$originalColor = new Hex('#b2b2b2');
$clonedColor = $hex->clone()->toHexa()->alpha(0.5); // OzdemirBurak\Iris\Color\Hexa('#b2b2b27f')
```

### Color Manipulation
Expand Down

0 comments on commit 9d2cc51

Please sign in to comment.