morepretty

This commit is contained in:
Ryan Oldenburg 2021-02-25 11:43:09 -06:00
parent 7b9d968381
commit 751b804679
8 changed files with 54 additions and 55 deletions

View file

@ -14,17 +14,17 @@ image.fillPath(
z z
""", """,
Paint( Paint(
kind:pkGradientRadial, kind: pkGradientRadial,
gradientHandlePositions: @[ gradientHandlePositions: @[
vec2(100, 100), vec2(100, 100),
vec2(200, 100), vec2(200, 100),
vec2(100, 200) vec2(100, 200)
], ],
gradientStops: @[ gradientStops: @[
ColorStop(color:rgba(255, 0, 0, 255).color, position: 0), ColorStop(color: rgba(255, 0, 0, 255).color, position: 0),
ColorStop(color:rgba(255, 0, 0, 40).color, position: 1.0), ColorStop(color: rgba(255, 0, 0, 40).color, position: 1.0),
] ]
) )
) )
image.writeFile("examples/paint.png") image.writeFile("examples/paint.png")

View file

@ -14,9 +14,9 @@ path.polygon(
image.fillPath( image.fillPath(
path, path,
Paint( Paint(
kind:pkImageTiled, kind: pkImageTiled,
image: readImage("tests/images/png/baboon.png"), 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,8 @@
import bumpy, chroma, flatty/binny, os, pixie/blends, pixie/common, import bumpy, chroma, flatty/binny, os, pixie/blends, pixie/common,
pixie/fileformats/bmp, pixie/fileformats/jpg, pixie/fileformats/png, pixie/fileformats/bmp, pixie/fileformats/jpg, pixie/fileformats/png,
pixie/fileformats/svg, pixie/paints, pixie/images, pixie/masks, pixie/fileformats/svg, pixie/images, pixie/masks, pixie/paints, pixie/paths, vmath
pixie/paths, vmath
export blends, bumpy, chroma, common, paints, images, masks, paths, vmath export blends, bumpy, chroma, common, images, masks, paints, paths, vmath
type type
FileFormat* = enum FileFormat* = enum

View file

@ -35,7 +35,6 @@ type
bmIntersectMask bmIntersectMask
bmExcludeMask bmExcludeMask
Blender* = proc(backdrop, source: ColorRGBA): ColorRGBA ## Function signature Blender* = proc(backdrop, source: ColorRGBA): ColorRGBA ## Function signature
## returned by blender. ## returned by blender.
Masker* = proc(backdrop, source: uint8): uint8 ## Function signature returned Masker* = proc(backdrop, source: uint8): uint8 ## Function signature returned

View file

@ -543,7 +543,9 @@ proc getRgbaSmooth*(image: Image, x, y: float32, wrapped = false): ColorRGBA =
lerp(bottomMix, topMix, diffY) lerp(bottomMix, topMix, diffY)
proc drawCorrect(a, b: Image | Mask, mat = mat3(), tiled = false, blendMode = bmNormal) = proc drawCorrect(
a, b: Image | Mask, mat = mat3(), tiled = false, blendMode = bmNormal
) =
## Draws one image onto another using matrix with color blending. ## Draws one image onto another using matrix with color blending.
when type(a) is Image: when type(a) is Image:

View file

@ -1,4 +1,4 @@
import chroma, common, images, vmath, blends import blends, chroma, common, images, vmath
type type
PaintKind* = enum PaintKind* = enum
@ -13,19 +13,19 @@ type
## Paint used to fill paths. ## Paint used to fill paths.
case kind*: PaintKind case kind*: PaintKind
of pkSolid: of pkSolid:
color*: ColorRGBA ## Color to fill with. color*: ColorRGBA ## Color to fill with.
of pkImage, pkImageTiled: of pkImage, pkImageTiled:
image*: Image ## Image to fill with. image*: Image ## Image to fill with.
imageMat*: Mat3 ## Matrix of the filled image. imageMat*: Mat3 ## Matrix of the filled image.
of pkGradientLinear, pkGradientRadial, pkGradientAngular: of pkGradientLinear, pkGradientRadial, pkGradientAngular:
gradientHandlePositions*: seq[Vec2] ## Gradient positions (image space). gradientHandlePositions*: seq[Vec2] ## Gradient positions (image space).
gradientStops*: seq[ColorStop] ## Color stops (gradient space). gradientStops*: seq[ColorStop] ## Color stops (gradient space).
blendMode*: BlendMode ## Blend mode. blendMode*: BlendMode ## Blend mode.
ColorStop* = object ColorStop* = object
## Color stop on a gradient curve. ## Color stop on a gradient curve.
color*: Color ## Color of the stop color*: Color ## Color of the stop
position*: float32 ## Gradient Stop position 0..1. position*: float32 ## Gradient Stop position 0..1.
proc toLineSpace(at, to, point: Vec2): float32 = proc toLineSpace(at, to, point: Vec2): float32 =
## Convert position on to where it would fall on a line between at and to. ## Convert position on to where it would fall on a line between at and to.

View file

@ -1,4 +1,4 @@
import blends, bumpy, chroma, common, images, masks, strutils, vmath, paints import blends, bumpy, chroma, common, images, masks, paints, strutils, vmath
when defined(amd64) and not defined(pixieNoSimd): when defined(amd64) and not defined(pixieNoSimd):
import nimsimd/sse2 import nimsimd/sse2
@ -35,7 +35,7 @@ type
SomePath* = Path | string | seq[seq[Vec2]] SomePath* = Path | string | seq[seq[Vec2]]
const epsilon = 0.0001 * PI ## Tiny value used for some computations. const epsilon = 0.0001 * PI ## Tiny value used for some computations.
when defined(release): when defined(release):
{.push checks: off.} {.push checks: off.}

View file

@ -14,8 +14,8 @@ block:
image.fillPath( image.fillPath(
heartShape, heartShape,
Paint( Paint(
kind:pkSolid, kind: pkSolid,
color:rgba(255, 0, 0, 255) color: rgba(255, 0, 0, 255)
) )
) )
image.writeFile("tests/images/paths/paintSolid.png") image.writeFile("tests/images/paths/paintSolid.png")
@ -26,9 +26,9 @@ block:
image.fillPath( image.fillPath(
heartShape, heartShape,
Paint( Paint(
kind:pkImage, kind: pkImage,
image:decodePng(readFile("tests/images/png/baboon.png")), image: decodePng(readFile("tests/images/png/baboon.png")),
imageMat:scale(vec2(0.2, 0.2)) imageMat: scale(vec2(0.2, 0.2))
) )
) )
image.writeFile("tests/images/paths/paintImage.png") image.writeFile("tests/images/paths/paintImage.png")
@ -39,30 +39,29 @@ block:
image.fillPath( image.fillPath(
heartShape, heartShape,
Paint( Paint(
kind:pkImageTiled, kind: pkImageTiled,
image:decodePng(readFile("tests/images/png/baboon.png")), image: decodePng(readFile("tests/images/png/baboon.png")),
imageMat:scale(vec2(0.02, 0.02)) imageMat: scale(vec2(0.02, 0.02))
) )
) )
image.writeFile("tests/images/paths/paintImageTiled.png") image.writeFile("tests/images/paths/paintImageTiled.png")
block: block:
let let
image = newImage(100, 100) image = newImage(100, 100)
image.fillPath( image.fillPath(
heartShape, heartShape,
Paint( Paint(
kind:pkGradientLinear, kind: pkGradientLinear,
gradientHandlePositions: @[ gradientHandlePositions: @[
vec2(0, 50), vec2(0, 50),
vec2(100, 50), vec2(100, 50),
], ],
gradientStops: @[ gradientStops: @[
ColorStop(color:rgba(255, 0, 0, 255).color, position: 0), ColorStop(color: rgba(255, 0, 0, 255).color, position: 0),
ColorStop(color:rgba(255, 0, 0, 40).color, position: 1.0), ColorStop(color: rgba(255, 0, 0, 40).color, position: 1.0),
] ]
) )
) )
image.writeFile("tests/images/paths/gradientLinear.png") image.writeFile("tests/images/paths/gradientLinear.png")
@ -72,17 +71,17 @@ block:
image.fillPath( image.fillPath(
heartShape, heartShape,
Paint( Paint(
kind:pkGradientRadial, kind: pkGradientRadial,
gradientHandlePositions: @[ gradientHandlePositions: @[
vec2(50, 50), vec2(50, 50),
vec2(100, 50), vec2(100, 50),
vec2(50, 100) vec2(50, 100)
], ],
gradientStops: @[ gradientStops: @[
ColorStop(color:rgba(255, 0, 0, 255).color, position: 0), ColorStop(color: rgba(255, 0, 0, 255).color, position: 0),
ColorStop(color:rgba(255, 0, 0, 40).color, position: 1.0), ColorStop(color: rgba(255, 0, 0, 40).color, position: 1.0),
] ]
) )
) )
image.writeFile("tests/images/paths/gradientRadial.png") image.writeFile("tests/images/paths/gradientRadial.png")
@ -93,17 +92,17 @@ block:
image.fillPath( image.fillPath(
heartShape, heartShape,
Paint( Paint(
kind:pkGradientAngular, kind: pkGradientAngular,
gradientHandlePositions: @[ gradientHandlePositions: @[
vec2(50, 50), vec2(50, 50),
vec2(100, 50), vec2(100, 50),
vec2(50, 100) vec2(50, 100)
], ],
gradientStops: @[ gradientStops: @[
ColorStop(color:rgba(255, 0, 0, 255).color, position: 0), ColorStop(color: rgba(255, 0, 0, 255).color, position: 0),
ColorStop(color:rgba(255, 0, 0, 40).color, position: 1.0), ColorStop(color: rgba(255, 0, 0, 40).color, position: 1.0),
] ]
) )
) )
image.writeFile("tests/images/paths/gradientAngular.png") image.writeFile("tests/images/paths/gradientAngular.png")