diff --git a/README.md b/README.md index 1379491..0fd8c29 100644 --- a/README.md +++ b/README.md @@ -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)) ) ) ``` diff --git a/examples/gradient.nim b/examples/gradient.nim index 3c0fc0c..9a93ef2 100644 --- a/examples/gradient.nim +++ b/examples/gradient.nim @@ -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") diff --git a/examples/heart.nim b/examples/heart.nim index 690e364..ebff8d8 100644 --- a/examples/heart.nim +++ b/examples/heart.nim @@ -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( diff --git a/examples/image_tiled.nim b/examples/image_tiled.nim index cac5af5..c7e8ade 100644 --- a/examples/image_tiled.nim +++ b/examples/image_tiled.nim @@ -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 diff --git a/examples/image_tiled.png b/examples/image_tiled.png index 75363de..a892e15 100644 Binary files a/examples/image_tiled.png and b/examples/image_tiled.png differ