Skip to content

Commit

Permalink
docs: reorder, stack explaination
Browse files Browse the repository at this point in the history
  • Loading branch information
naomai committed Jul 29, 2024
1 parent 600029f commit 34483a1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion docs/Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,24 @@ $data = $image->export()->asBinaryData(format: 'webp');
```

## Managing layers
PHPLayers makes use of a *Layer Stack*. This structure gives flexibility on
which layer goes on top of other. Now, the things going on the top
don't have to be drawn at the very end of script.

![Bottom layer is the lowest number](images/layerIndex.webp)

`LayerStack` is a sequence of layers, beginning at index 0 (bottom),
then going up to the top. PHPLayers allows *reordering* of layers
after their creation. The *Layer index* is referring to order of the stack,
not the order of creating layers.

`Layer` is *attached* to the `Image`, when it is present on its Layer Stack.


### newLayer
`Image::newLayer(string $name=null) : Layer`

Create new layer and put it on top of layer set.
Create new layer and put it on top of layer stack.

- `name` (optional) - passed to internal `Layer::name` property that can be used
in alternate layer composers, such as `Composers\TiledComposer`.
Expand Down Expand Up @@ -115,3 +129,16 @@ $layerTop = $image->getLayerByIndex(2);
$layerTop = $image->getLayerByIndex(-1); // same layer as above
$layerOutOfBounds = $image->getLayerByIndex(3); // null
```

### reorder
`reorder(Layer $layerToMove) : Helpers\LayerReorderCall`

Access helper object for changing layer order on stack.

- `layerToMove` - a `Layer` to be relocated, **must** be attached to the `Image`

**Returns** helper object providing reordering methods.

```php
$image->reorder($layerBottom)->putOver($layerTop);
```
Binary file added docs/images/layerIndex.webp
Binary file not shown.

0 comments on commit 34483a1

Please sign in to comment.