Skip to content

Commit e7cf9be

Browse files
committed
add mask()
1 parent e11cfc8 commit e7cf9be

3 files changed

Lines changed: 55 additions & 0 deletions

File tree

docs/reference/assets/mask1.webp

2.63 KB
Loading

docs/reference/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ An offline version of this documentation is available for [download](/download/#
8080
* [image()](image.md)
8181
* [imageMode()](imageMode.md)
8282
* [loadImage()](loadImage.md)
83+
* [mask()](mask.md)
8384
* [noTint()](noTint.md)
8485
* [tint()](tint.md)
8586

docs/reference/mask.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# mask()
2+
3+
Masks part of the image with another.
4+
5+
`mask()` uses another image's alpha channel as the alpha channel for this image. Masks are cumulative and can't be removed once applied. If the mask has a different pixel density from this image, the mask will be scaled.
6+
7+
## Examples
8+
9+
![mask example 1](assets/mask1.webp)
10+
11+
```lua
12+
require 'L5'
13+
14+
function setup()
15+
size(100,100)
16+
windowTitle('mask example')
17+
18+
-- Load the images
19+
photo = loadImage('assets/rockies.jpg')
20+
maskImage = loadImage('assets/mask2.png')
21+
22+
-- Apply the mask
23+
mask(photo, maskImage)
24+
25+
-- Display the image
26+
image(photo, 0, 0, width, height)
27+
28+
describe('An image of a mountain landscape. The right side of the image has a faded patch of white.')
29+
end
30+
```
31+
32+
## Syntax
33+
34+
```lua
35+
mask(targetImage, maskImage)
36+
```
37+
38+
## Parameters
39+
40+
| Parameter | |
41+
| - | -------------------------------------------------- |
42+
| targetImage | image: texture that mask will be applied to. |
43+
| maskImage | image: texture that will be applied as a mask. |
44+
45+
46+
## Related
47+
48+
* [blend()](blend.md)
49+
* [copy()](copy.md)
50+
* [filter()](filter.md)
51+
52+
---
53+
54+
*This reference page contains content adapted from [p5.js](https://p5js.org/) and [Processing](https://processing.org) by [p5.js Contributors](https://github.com/processing/p5.js?tab=readme-ov-file#contributors) and [Processing Foundation](https://processingfoundation.org/people), licensed under [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/).*

0 commit comments

Comments
 (0)