nimpretty bandaid

This commit is contained in:
Ryan Oldenburg 2021-02-25 12:05:46 -06:00
parent 3c3cd499ea
commit 29479a7c6a
5 changed files with 34 additions and 35 deletions

View file

@ -168,6 +168,19 @@ image.draw(lines)
### Gradient
[examples/gradient.nim](examples/gradient.nim)
```nim
let paint = Paint(
kind: pkGradientRadial,
gradientHandlePositions: @[
vec2(100, 100),
vec2(200, 100),
vec2(100, 200)
],
gradientStops: @[
ColorStop(color: rgba(255, 0, 0, 255).color, position: 0),
ColorStop(color: rgba(255, 0, 0, 40).color, position: 1.0),
]
)
image.fillPath(
"""
M 20 60
@ -177,18 +190,7 @@ image.fillPath(
Q 20 120 20 60
z
""",
Paint(
kind:pkGradientRadial,
gradientHandlePositions: @[
vec2(100, 100),
vec2(200, 100),
vec2(100, 200)
],
gradientStops: @[
ColorStop(color:rgba(255, 0, 0, 255).color, position: 0),
ColorStop(color:rgba(255, 0, 0, 40).color, position: 1.0),
]
)
paint
)
```
![example output](examples/gradient.png)
@ -205,9 +207,9 @@ path.polygon(
image.fillPath(
path,
Paint(
kind:pkImageTiled,
kind: pkImageTiled,
image: readImage("tests/images/png/baboon.png"),
imageMat:scale(vec2(0.08, 0.08))
imageMat: scale(vec2(0.08, 0.08))
)
)
```

View file

@ -1,9 +1,21 @@
import pixie
let
image = newImage(200, 200)
let image = newImage(200, 200)
image.fill(rgba(255, 255, 255, 255))
let paint = Paint(
kind: pkGradientRadial,
gradientHandlePositions: @[
vec2(100, 100),
vec2(200, 100),
vec2(100, 200)
],
gradientStops: @[
ColorStop(color: rgba(255, 0, 0, 255).color, position: 0),
ColorStop(color: rgba(255, 0, 0, 40).color, position: 1.0),
]
)
image.fillPath(
"""
M 20 60
@ -13,18 +25,7 @@ image.fillPath(
Q 20 120 20 60
z
""",
Paint(
kind: pkGradientRadial,
gradientHandlePositions: @[
vec2(100, 100),
vec2(200, 100),
vec2(100, 200)
],
gradientStops: @[
ColorStop(color: rgba(255, 0, 0, 255).color, position: 0),
ColorStop(color: rgba(255, 0, 0, 40).color, position: 1.0),
]
)
paint
)
image.writeFile("examples/paint.png")

View file

@ -1,8 +1,6 @@
import pixie
let
image = newImage(200, 200)
let image = newImage(200, 200)
image.fill(rgba(255, 255, 255, 255))
image.fillPath(

View file

@ -1,8 +1,6 @@
import pixie
let
image = newImage(200, 200)
let image = newImage(200, 200)
image.fill(rgba(255, 255, 255, 255))
var path: Path

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB