Add a masking example.
This commit is contained in:
parent
ea418082a6
commit
8032c9963c
4 changed files with 54 additions and 0 deletions
23
README.md
23
README.md
|
@ -142,6 +142,29 @@ image.fillPath(
|
||||||
```
|
```
|
||||||

|

|
||||||
|
|
||||||
|
### Masking
|
||||||
|
[examples/masking.nim](examples/masking.nim)
|
||||||
|
```nim
|
||||||
|
lines.strokeSegment(
|
||||||
|
segment(vec2(25, 25), vec2(175, 175)), color, strokeWidth = 30)
|
||||||
|
lines.strokeSegment(
|
||||||
|
segment(vec2(25, 175), vec2(175, 25)), color, strokeWidth = 30)
|
||||||
|
|
||||||
|
mask.fillPath(
|
||||||
|
"""
|
||||||
|
M 20 60
|
||||||
|
A 40 40 90 0 1 100 60
|
||||||
|
A 40 40 90 0 1 180 60
|
||||||
|
Q 180 120 100 180
|
||||||
|
Q 20 120 20 60
|
||||||
|
z
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
lines.draw(mask)
|
||||||
|
image.draw(lines)
|
||||||
|
```
|
||||||
|

|
||||||
|
|
||||||
### Shadow
|
### Shadow
|
||||||
[examples/shadow.nim](examples/shadow.nim)
|
[examples/shadow.nim](examples/shadow.nim)
|
||||||
```nim
|
```nim
|
||||||
|
|
30
examples/masking.nim
Normal file
30
examples/masking.nim
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import pixie
|
||||||
|
|
||||||
|
let
|
||||||
|
image = newImage(200, 200)
|
||||||
|
lines = newImage(200, 200)
|
||||||
|
mask = newMask(200, 200)
|
||||||
|
color = parseHtmlColor("#F8D1DD").rgba
|
||||||
|
|
||||||
|
lines.fill(parseHtmlColor("#FC427B").rgba)
|
||||||
|
image.fill(rgba(255, 255, 255, 255))
|
||||||
|
|
||||||
|
lines.strokeSegment(
|
||||||
|
segment(vec2(25, 25), vec2(175, 175)), color, strokeWidth = 30)
|
||||||
|
lines.strokeSegment(
|
||||||
|
segment(vec2(25, 175), vec2(175, 25)), color, strokeWidth = 30)
|
||||||
|
|
||||||
|
mask.fillPath(
|
||||||
|
"""
|
||||||
|
M 20 60
|
||||||
|
A 40 40 90 0 1 100 60
|
||||||
|
A 40 40 90 0 1 180 60
|
||||||
|
Q 180 120 100 180
|
||||||
|
Q 20 120 20 60
|
||||||
|
z
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
lines.draw(mask)
|
||||||
|
image.draw(lines)
|
||||||
|
|
||||||
|
image.writeFile("examples/masking.png")
|
BIN
examples/masking.png
Normal file
BIN
examples/masking.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
|
@ -15,6 +15,7 @@ var exampleFiles = [
|
||||||
"examples/line.nim",
|
"examples/line.nim",
|
||||||
"examples/rounded_rectangle.nim",
|
"examples/rounded_rectangle.nim",
|
||||||
"examples/heart.nim",
|
"examples/heart.nim",
|
||||||
|
"examples/masking.nim",
|
||||||
"examples/shadow.nim",
|
"examples/shadow.nim",
|
||||||
"examples/blur.nim",
|
"examples/blur.nim",
|
||||||
"examples/tiger.nim"
|
"examples/tiger.nim"
|
||||||
|
|
Loading…
Reference in a new issue