More enum renames.

This commit is contained in:
treeform 2022-02-13 20:02:37 -08:00
parent a68512d065
commit 3e5926c92c
29 changed files with 262 additions and 262 deletions

View file

@ -235,7 +235,7 @@ image.draw(lines)
### Gradient
nim c -r [examples/gradient.nim](examples/gradient.nim)
```nim
let paint = newPaint(PaintGradientRadial)
let paint = newPaint(RadialGradientPaint)
paint.gradientHandlePositions = @[
vec2(100, 100),
vec2(200, 100),
@ -270,7 +270,7 @@ path.polygon(
sides = 8
)
let paint = newPaint(PaintImageTiled)
let paint = newPaint(TiledImagePaint)
paint.image = readImage("examples/data/mandrill.png")
paint.imageMat = scale(vec2(0.08, 0.08))
@ -309,7 +309,7 @@ let mask = newMask(200, 200)
mask.fillPath(path)
blur.blur(20)
blur.draw(mask, blendMode = BlendMask)
blur.draw(mask, blendMode = MaskBlend)
image.draw(trees)
image.draw(blur)

View file

@ -14,7 +14,7 @@ let mask = newMask(200, 200)
mask.fillPath(path)
blur.blur(20)
blur.draw(mask, blendMode = BlendMask)
blur.draw(mask, blendMode = MaskBlend)
image.draw(trees)
image.draw(blur)

View file

@ -3,7 +3,7 @@ import pixie
let image = newImage(200, 200)
image.fill(rgba(255, 255, 255, 255))
let paint = newPaint(PaintGradientRadial)
let paint = newPaint(RadialGradientPaint)
paint.gradientHandlePositions = @[
vec2(100, 100),
vec2(200, 100),

View file

@ -10,7 +10,7 @@ path.polygon(
sides = 8
)
let paint = newPaint(PaintImageTiled)
let paint = newPaint(TiledImagePaint)
paint.image = readImage("examples/data/mandrill.png")
paint.imageMat = scale(vec2(0.08, 0.08))

View file

@ -358,9 +358,9 @@ block:
# doDiff(readImage("cairo4.png"), a, "4")
var b: Image
let paint = newPaint(PaintSolid)
let paint = newPaint(SolidPaint)
paint.color = color(1, 0, 0, 0.5)
paint.blendMode = BlendOverwrite
paint.blendMode = OverwriteBlend
timeIt "pixie4 overwrite":
b = newImage(1000, 1000)

View file

@ -78,7 +78,7 @@ block:
timeIt "pixie draw overwrite":
# tmp.fill(rgbx(127, 127, 127, 255))
tmp.draw(backdrop, blendMode = BlendOverwrite)
tmp.draw(backdrop, blendMode = OverwriteBlend)
tmp.draw(source)
# tmp.writeFile("tmp2.png")
@ -124,7 +124,7 @@ block:
timeIt "pixie draw mask":
tmp.draw(backdrop)
tmp.draw(source, blendMode = BlendMask)
tmp.draw(source, blendMode = MaskBlend)
# tmp.writeFile("tmp_masked2.png")

View file

@ -192,7 +192,7 @@ proc decodeCtxInternal(inherited: Ctx, node: XmlNode): Ctx =
let id = fill[5 .. ^2]
if id in result.linearGradients:
let linearGradient = result.linearGradients[id]
result.fill = newPaint(PaintGradientLinear)
result.fill = newPaint(LinearGradientPaint)
result.fill.gradientHandlePositions = @[
result.transform * vec2(linearGradient.x1, linearGradient.y1),
result.transform * vec2(linearGradient.x2, linearGradient.y2)

View file

@ -716,7 +716,7 @@ block:
# var mask = newMask(image)
# mask.fillPath2(p)
# image.draw(mask, blendMode = BlendOverwrite)
# image.draw(mask, blendMode = OverwriteBlend)
# image.writeFile("experiments/trapezoids/heart.png")

View file

@ -157,7 +157,7 @@ proc binaryInsert(arr: var seq[float32], v: float32) =
arr.insert(v, L + 1)
proc fillPath2(image: Image, p: Path, color: Color, windingRule = NonZero, blendMode = BlendNormal) =
proc fillPath2(image: Image, p: Path, color: Color, windingRule = NonZero, blendMode = NormalBlend) =
const q = 1/256.0
let rgbx = color.rgbx
var segments = p.commandsToShapes(true, 1.0).shapesToSegments()

View file

@ -274,7 +274,7 @@ block:
# var mask = newMask(image)
# mask.fillPath2(p)
# image.draw(mask, blendMode = BlendOverwrite)
# image.draw(mask, blendMode = OverwriteBlend)
# image.writeFile("experiments/trapezoids/heart.png")

View file

@ -472,7 +472,7 @@ block:
# var mask = newMask(image)
# mask.fillPath2(p)
# image.draw(mask, blendMode = BlendOverwrite)
# image.draw(mask, blendMode = OverwriteBlend)
# image.writeFile("experiments/trapezoids/heart.png")

View file

@ -8,7 +8,7 @@ export bumpy, chroma, common, contexts, fonts, images, masks, paints, paths, vma
type
FileFormat* = enum
FormatPng, FormatBmp, FormatJpg, FormatGif, FormatQoi, FormatPpm
PngFormat, BmpFormat, JpgFormat, GifFormat, QoiFormat, PpmFormat
converter autoStraightAlpha*(c: ColorRGBX): ColorRGBA {.inline, raises: [].} =
## Convert a premultiplied alpha RGBA to a straight alpha RGBA.
@ -62,23 +62,23 @@ proc readMask*(filePath: string): Mask {.raises: [PixieError].} =
proc encodeImage*(image: Image, fileFormat: FileFormat): string {.raises: [PixieError].} =
## Encodes an image into memory.
case fileFormat:
of FormatPng:
of PngFormat:
image.encodePng()
of FormatJpg:
of JpgFormat:
image.encodeJpg()
of FormatBmp:
of BmpFormat:
image.encodeBmp()
of FormatQoi:
of QoiFormat:
image.encodeQoi()
of FormatGif:
of GifFormat:
raise newException(PixieError, "Unsupported file format")
of FormatPpm:
of PpmFormat:
image.encodePpm()
proc encodeMask*(mask: Mask, fileFormat: FileFormat): string {.raises: [PixieError].} =
## Encodes a mask into memory.
case fileFormat:
of FormatPng:
of PngFormat:
mask.encodePng()
else:
raise newException(PixieError, "Unsupported file format")
@ -86,11 +86,11 @@ proc encodeMask*(mask: Mask, fileFormat: FileFormat): string {.raises: [PixieErr
proc writeFile*(image: Image, filePath: string) {.raises: [PixieError].} =
## Writes an image to a file.
let fileFormat = case splitFile(filePath).ext.toLowerAscii():
of ".png": FormatPng
of ".bmp": FormatBmp
of ".jpg", ".jpeg": FormatJpg
of ".qoi": FormatQoi
of ".ppm": FormatPpm
of ".png": PngFormat
of ".bmp": BmpFormat
of ".jpg", ".jpeg": JpgFormat
of ".qoi": QoiFormat
of ".ppm": PpmFormat
else:
raise newException(PixieError, "Unsupported file extension")
@ -102,11 +102,11 @@ proc writeFile*(image: Image, filePath: string) {.raises: [PixieError].} =
proc writeFile*(mask: Mask, filePath: string) {.raises: [PixieError].} =
## Writes a mask to a file.
let fileFormat = case splitFile(filePath).ext.toLowerAscii():
of ".png": FormatPng
of ".bmp": FormatBmp
of ".jpg", ".jpeg": FormatJpg
of ".qoi": FormatQoi
of ".ppm": FormatPpm
of ".png": PngFormat
of ".bmp": BmpFormat
of ".jpg", ".jpeg": JpgFormat
of ".qoi": QoiFormat
of ".ppm": PpmFormat
else:
raise newException(PixieError, "Unsupported file extension")

View file

@ -425,28 +425,28 @@ proc blendOverwrite(backdrop, source: ColorRGBX): ColorRGBX =
proc blender*(blendMode: BlendMode): Blender {.raises: [].} =
## Returns a blend function for a given blend mode.
case blendMode:
of BlendNormal: blendNormal
of BlendDarken: blendDarken
of BlendMultiply: blendMultiply
of NormalBlend: blendNormal
of DarkenBlend: blendDarken
of MultiplyBlend: blendMultiply
# of BlendLinearBurn: blendLinearBurn
of BlendColorBurn: blendColorBurn
of BlendLighten: blendLighten
of BlendScreen: blendScreen
of ColorBurnBlend: blendColorBurn
of LightenBlend: blendLighten
of ScreenBlend: blendScreen
# of BlendLinearDodge: blendLinearDodge
of BlendColorDodge: blendColorDodge
of BlendOverlay: blendOverlay
of BlendSoftLight: blendSoftLight
of BlendHardLight: blendHardLight
of BlendDifference: blendDifference
of BlendExclusion: blendExclusion
of BlendHue: blendHue
of BlendSaturation: blendSaturation
of BlendColor: blendColor
of BlendLuminosity: blendLuminosity
of BlendMask: blendMask
of BlendOverwrite: blendOverwrite
of BlendSubtractMask: blendSubtractMask
of BlendExcludeMask: blendExcludeMask
of ColorDodgeBlend: blendColorDodge
of OverlayBlend: blendOverlay
of SoftLightBlend: blendSoftLight
of HardLightBlend: blendHardLight
of DifferenceBlend: blendDifference
of ExclusionBlend: blendExclusion
of HueBlend: blendHue
of SaturationBlend: blendSaturation
of ColorBlend: blendColor
of LuminosityBlend: blendLuminosity
of MaskBlend: blendMask
of OverwriteBlend: blendOverwrite
of SubtractMaskBlend: blendSubtractMask
of ExcludeMaskBlend: blendExcludeMask
proc maskNormal(backdrop, source: uint8): uint8 =
## Blending masks
@ -471,11 +471,11 @@ proc maskOverwrite(backdrop, source: uint8): uint8 =
proc masker*(blendMode: BlendMode): Masker {.raises: [PixieError].} =
## Returns a blend masking function for a given blend masking mode.
case blendMode:
of BlendNormal: maskNormal
of BlendMask: maskMask
of BlendOverwrite: maskOverwrite
of BlendSubtractMask: maskSubtract
of BlendExcludeMask: maskExclude
of NormalBlend: maskNormal
of MaskBlend: maskMask
of OverwriteBlend: maskOverwrite
of SubtractMaskBlend: maskSubtract
of ExcludeMaskBlend: maskExclude
else:
raise newException(PixieError, "No masker for " & $blendMode)
@ -548,15 +548,15 @@ when defined(amd64) and not defined(pixieNoSimd):
proc blenderSimd*(blendMode: BlendMode): BlenderSimd {.raises: [PixieError].} =
## Returns a blend function for a given blend mode with SIMD support.
case blendMode:
of BlendNormal: blendNormalSimd
of BlendMask: blendMaskSimd
of BlendOverwrite: blendOverwriteSimd
of NormalBlend: blendNormalSimd
of MaskBlend: blendMaskSimd
of OverwriteBlend: blendOverwriteSimd
else:
raise newException(PixieError, "No SIMD blender for " & $blendMode)
proc hasSimdBlender*(blendMode: BlendMode): bool {.inline, raises: [].} =
## Is there a blend function for a given blend mode with SIMD support?
blendMode in {BlendNormal, BlendMask, BlendOverwrite}
blendMode in {NormalBlend, MaskBlend, OverwriteBlend}
proc maskNormalInlineSimd*(backdrop, source: M128i): M128i {.inline.} =
## Blending masks
@ -625,15 +625,15 @@ when defined(amd64) and not defined(pixieNoSimd):
proc maskerSimd*(blendMode: BlendMode): MaskerSimd {.raises: [PixieError].} =
## Returns a blend masking function with SIMD support.
case blendMode:
of BlendNormal: maskNormalSimd
of BlendMask: maskMaskSimd
of BlendOverwrite: blendOverwriteSimd
of NormalBlend: maskNormalSimd
of MaskBlend: maskMaskSimd
of OverwriteBlend: blendOverwriteSimd
else:
raise newException(PixieError, "No SIMD masker for " & $blendMode)
proc hasSimdMasker*(blendMode: BlendMode): bool {.inline, raises: [].} =
## Is there a blend masking function with SIMD support?
blendMode in {BlendNormal, BlendMask, BlendOverwrite}
blendMode in {NormalBlend, MaskBlend, OverwriteBlend}
when defined(release):
{.pop.}

View file

@ -4,29 +4,29 @@ type
PixieError* = object of ValueError ## Raised if an operation fails.
BlendMode* = enum
BlendNormal
BlendDarken
BlendMultiply
NormalBlend
DarkenBlend
MultiplyBlend
# BlendLinearBurn
BlendColorBurn
BlendLighten
BlendScreen
ColorBurnBlend
LightenBlend
ScreenBlend
# BlendLinearDodge
BlendColorDodge
BlendOverlay
BlendSoftLight
BlendHardLight
BlendDifference
BlendExclusion
BlendHue
BlendSaturation
BlendColor
BlendLuminosity
ColorDodgeBlend
OverlayBlend
SoftLightBlend
HardLightBlend
DifferenceBlend
ExclusionBlend
HueBlend
SaturationBlend
ColorBlend
LuminosityBlend
BlendMask ## Special blend mode that is used for masking
BlendOverwrite ## Special blend mode that just copies pixels
BlendSubtractMask ## Inverse mask
BlendExcludeMask
MaskBlend ## Special blend mode that is used for masking
OverwriteBlend ## Special blend mode that just copies pixels
SubtractMaskBlend ## Inverse mask
ExcludeMaskBlend
proc mix*(a, b: uint8, t: float32): uint8 {.inline, raises: [].} =
## Linearly interpolate between a and b using t.

View file

@ -53,9 +53,9 @@ proc newContext*(image: Image): Context {.raises: [].} =
result.globalAlpha = 1
result.lineWidth = 1
result.miterLimit = 10
result.fillStyle = newPaint(PaintSolid)
result.fillStyle = newPaint(SolidPaint)
result.fillStyle.color = color(0, 0, 0, 1)
result.strokeStyle = newPaint(PaintSolid)
result.strokeStyle = newPaint(SolidPaint)
result.strokeStyle.color = color(0, 0, 0, 1)
result.fontSize = 12
@ -370,7 +370,7 @@ proc clip*(
ctx.mask = newMask(ctx.image.width, ctx.image.height)
ctx.mask.fillPath(path, windingRule = windingRule)
else:
ctx.mask.fillPath(path, windingRule = windingRule, blendMode = BlendMask)
ctx.mask.fillPath(path, windingRule = windingRule, blendMode = MaskBlend)
proc clip*(
ctx: Context, windingRule = NonZero
@ -397,8 +397,8 @@ proc stroke*(ctx: Context) {.inline, raises: [PixieError].} =
proc clearRect*(ctx: Context, rect: Rect) {.raises: [PixieError].} =
## Erases the pixels in a rectangular area.
let paint = newPaint(PaintSolid)
paint.blendMode = BlendOverwrite
let paint = newPaint(SolidPaint)
paint.blendMode = OverwriteBlend
let path = newPath()
path.rect(rect)
@ -541,7 +541,7 @@ proc drawImage*(
))
savedFillStyle = ctx.fillStyle
ctx.fillStyle = newPaint(PaintImage)
ctx.fillStyle = newPaint(ImagePaint)
ctx.fillStyle.image = image
ctx.fillStyle.imageMat = imageMat

View file

@ -169,7 +169,7 @@ proc decodeCtxInternal(inherited: Ctx, node: XmlNode): Ctx =
let id = fill[5 .. ^2]
if id in result.linearGradients:
let linearGradient = result.linearGradients[id]
result.fill = newPaint(PaintGradientLinear)
result.fill = newPaint(LinearGradientPaint)
result.fill.gradientHandlePositions = @[
result.transform * vec2(linearGradient.x1, linearGradient.y1),
result.transform * vec2(linearGradient.x2, linearGradient.y2)

View file

@ -37,19 +37,19 @@ type
selectionRects*: seq[Rect] ## The selection rects for each glyph.
HorizontalAlignment* = enum
AlignLeft
AlignCenter
AlignRight
LeftAlign
CenterAlign
RightAlign
VerticalAlignment* = enum
AlignTop
AlignMiddle
AlignBottom
TopAlign
MiddleAlign
BottomAlign
TextCase* = enum
NormalCase
Uppercase
Lowercase
UpperCase
LowerCase
TitleCase
# tcSmallCaps
# tcSmallCapsForced
@ -197,7 +197,7 @@ proc newFont*(typeface: Typeface): Font {.raises: [].} =
result.typeface = typeface
result.size = 12
result.lineHeight = autoLineHeight
result.paint = newPaint(PaintSolid)
result.paint = newPaint(SolidPaint)
result.paint.color = color(0, 0, 0, 1)
proc newSpan*(text: string, font: Font): Span {.raises: [].} =
@ -210,10 +210,10 @@ proc convertTextCase(runes: var seq[Rune], textCase: TextCase) =
case textCase:
of NormalCase:
discard
of Uppercase:
of UpperCase:
for rune in runes.mitems:
rune = rune.toUpper()
of Lowercase:
of LowerCase:
for rune in runes.mitems:
rune = rune.toLower()
of TitleCase:
@ -229,8 +229,8 @@ proc canWrap(rune: Rune): bool {.inline.} =
proc typeset*(
spans: seq[Span],
bounds = vec2(0, 0),
hAlign = AlignLeft,
vAlign = AlignTop,
hAlign = LeftAlign,
vAlign = TopAlign,
wrap = true
): Arrangement {.raises: [].} =
## Lays out the character glyphs and returns the arrangement.
@ -325,7 +325,7 @@ proc typeset*(
result.lines[^1][1] = result.runes.len - 1
if hAlign != AlignLeft:
if hAlign != LeftAlign:
# Since horizontal alignment adjustments are different for each line,
# find the start and stop of each line of text.
for (start, stop) in result.lines:
@ -337,11 +337,11 @@ proc typeset*(
var xAdjustment: float32
case hAlign:
of AlignLeft:
of LeftAlign:
discard
of AlignCenter:
of CenterAlign:
xAdjustment = (bounds.x - furthestX) / 2
of AlignRight:
of RightAlign:
xAdjustment = bounds.x - furthestX
if xAdjustment != 0:
@ -415,18 +415,18 @@ proc typeset*(
baseline - round(font.typeface.ascent * font.scale)
result.selectionRects[runeIndex].h = lineHeight
if vAlign != AlignTop:
if vAlign != TopAlign:
let
finalSelectionRect = result.selectionRects[^1]
furthestY = finalSelectionRect.y + finalSelectionRect.h
var yAdjustment: float32
case vAlign:
of AlignTop:
of TopAlign:
discard
of AlignMiddle:
of MiddleAlign:
yAdjustment = round((bounds.y - furthestY) / 2)
of AlignBottom:
of BottomAlign:
yAdjustment = bounds.y - furthestY
if yAdjustment != 0:
@ -450,8 +450,8 @@ proc typeset*(
font: Font,
text: string,
bounds = vec2(0, 0),
hAlign = AlignLeft,
vAlign = AlignTop,
hAlign = LeftAlign,
vAlign = TopAlign,
wrap = true
): Arrangement {.inline, raises: [].} =
## Lays out the character glyphs and returns the arrangement.
@ -596,8 +596,8 @@ proc fillText*(
text: string,
transform = mat3(),
bounds = vec2(0, 0),
hAlign = AlignLeft,
vAlign = AlignTop
hAlign = LeftAlign,
vAlign = TopAlign
) {.inline, raises: [PixieError].} =
## Typesets and fills the text. Optional parameters:
## transform: translation or matrix to apply
@ -636,8 +636,8 @@ proc strokeText*(
transform = mat3(),
strokeWidth: float32 = 1.0,
bounds = vec2(0, 0),
hAlign = AlignLeft,
vAlign = AlignTop,
hAlign = LeftAlign,
vAlign = TopAlign,
lineCap = ButtCap,
lineJoin = MiterJoin,
miterLimit = defaultMiterLimit,

View file

@ -595,7 +595,7 @@ proc getRgbaSmooth*(
topMix
proc drawCorrect(
a, b: Image | Mask, transform = mat3(), blendMode = BlendNormal, tiled = false
a, b: Image | Mask, transform = mat3(), blendMode = NormalBlend, tiled = false
) {.raises: [PixieError].} =
## Draws one image onto another using matrix with color blending.
@ -719,7 +719,7 @@ proc drawUber(
else: # a is a Mask
let masker = blendMode.masker()
if blendMode == BlendMask:
if blendMode == MaskBlend:
if yMin > 0:
zeroMem(a.data[0].addr, 4 * yMin * a.width)
@ -754,7 +754,7 @@ proc drawUber(
if xStart == a.width or xStop == 0:
continue
if blendMode == BlendMask:
if blendMode == MaskBlend:
if xStart > 0:
zeroMem(a.data[a.dataIndex(0, y)].addr, 4 * xStart)
@ -793,7 +793,7 @@ proc drawUber(
var sx = srcPos.x.int
when type(a) is Image and type(b) is Image:
if blendMode in {BlendNormal, BlendOverwrite} and
if blendMode in {NormalBlend, OverwriteBlend} and
isOpaque(b.data, b.dataIndex(sx, sy), xStop - xStart):
copyMem(
a.data[a.dataIndex(x, y)].addr,
@ -804,7 +804,7 @@ proc drawUber(
when defined(amd64) and not defined(pixieNoSimd):
case blendMode:
of BlendOverwrite:
of OverwriteBlend:
for _ in 0 ..< (xStop - xStart) div 16:
when type(a) is Image:
when type(b) is Image:
@ -831,7 +831,7 @@ proc drawUber(
mm_storeu_si128(a.data[a.dataIndex(x, y)].addr, sourceVec)
x += 16
sx += 16
of BlendNormal:
of NormalBlend:
let vec255 = mm_set1_epi32(cast[int32](uint32.high))
for _ in 0 ..< (xStop - xStart) div 16:
when type(a) is Image:
@ -889,7 +889,7 @@ proc drawUber(
)
x += 16
sx += 16
of BlendMask:
of MaskBlend:
let vec255 = mm_set1_epi32(cast[int32](uint32.high))
for _ in 0 ..< (xStop - xStart) div 16:
when type(a) is Image:
@ -1004,7 +1004,7 @@ proc drawUber(
)
case blendMode:
of BlendOverwrite:
of OverwriteBlend:
for x in x ..< xStop:
let samplePos = ivec2((srcPos.x - h).int32, (srcPos.y - h).int32)
when type(a) is Image:
@ -1022,7 +1022,7 @@ proc drawUber(
if source > 0:
a.unsafe[x, y] = source
srcPos += dx
of BlendNormal:
of NormalBlend:
for x in x ..< xStop:
let samplePos = ivec2((srcPos.x - h).int32, (srcPos.y - h).int32)
when type(a) is Image:
@ -1048,7 +1048,7 @@ proc drawUber(
let backdrop = a.unsafe[x, y]
a.unsafe[x, y] = blendAlpha(backdrop, source)
srcPos += dx
of BlendMask:
of MaskBlend:
for x in x ..< xStop:
let samplePos = ivec2((srcPos.x - h).int32, (srcPos.y - h).int32)
when type(a) is Image:
@ -1095,16 +1095,16 @@ proc drawUber(
a.unsafe[x, y] = masker(backdrop, sample)
srcPos += dx
if blendMode == BlendMask:
if blendMode == MaskBlend:
if a.width - xStop > 0:
zeroMem(a.data[a.dataIndex(xStop, y)].addr, 4 * (a.width - xStop))
if blendMode == BlendMask:
if blendMode == MaskBlend:
if a.height - yMax > 0:
zeroMem(a.data[a.dataIndex(0, yMax)].addr, 4 * a.width * (a.height - yMax))
proc draw*(
a, b: Image, transform = mat3(), blendMode = BlendNormal
a, b: Image, transform = mat3(), blendMode = NormalBlend
) {.inline, raises: [PixieError].} =
## Draws one image onto another using matrix with color blending.
when type(transform) is Vec2:
@ -1113,7 +1113,7 @@ proc draw*(
a.drawUber(b, transform, blendMode)
proc draw*(
a, b: Mask, transform = mat3(), blendMode = BlendMask
a, b: Mask, transform = mat3(), blendMode = MaskBlend
) {.inline, raises: [PixieError].} =
## Draws a mask onto a mask using a matrix with color blending.
when type(transform) is Vec2:
@ -1122,7 +1122,7 @@ proc draw*(
a.drawUber(b, transform, blendMode)
proc draw*(
image: Image, mask: Mask, transform = mat3(), blendMode = BlendMask
image: Image, mask: Mask, transform = mat3(), blendMode = MaskBlend
) {.inline, raises: [PixieError].} =
## Draws a mask onto an image using a matrix with color blending.
when type(transform) is Vec2:
@ -1131,7 +1131,7 @@ proc draw*(
image.drawUber(mask, transform, blendMode)
proc draw*(
mask: Mask, image: Image, transform = mat3(), blendMode = BlendMask
mask: Mask, image: Image, transform = mat3(), blendMode = MaskBlend
) {.inline, raises: [PixieError].} =
## Draws a image onto a mask using a matrix with color blending.
when type(transform) is Vec2:
@ -1140,7 +1140,7 @@ proc draw*(
mask.drawUber(image, transform, blendMode)
proc drawTiled*(
dst, src: Image, mat: Mat3, blendMode = BlendNormal
dst, src: Image, mat: Mat3, blendMode = NormalBlend
) {.raises: [PixieError].} =
dst.drawCorrect(src, mat, blendMode, true)
@ -1156,7 +1156,7 @@ proc resize*(srcImage: Image, width, height: int): Image {.raises: [PixieError].
width.float32 / srcImage.width.float32,
height.float32 / srcImage.height.float32
)),
BlendOverwrite
OverwriteBlend
)
proc shadow*(
@ -1170,7 +1170,7 @@ proc shadow*(
shifted = mask
else:
shifted = newMask(mask.width, mask.height)
shifted.draw(mask, translate(offset), BlendOverwrite)
shifted.draw(mask, translate(offset), OverwriteBlend)
shifted.spread(spread)
shifted.blur(blur)
@ -1188,7 +1188,7 @@ proc superImage*(image: Image, x, y, w, h: int): Image {.raises: [PixieError].}
result = newImage(w, h)
else:
result = newImage(w, h)
result.draw(image, translate(vec2(-x.float32, -y.float32)), BlendOverwrite)
result.draw(image, translate(vec2(-x.float32, -y.float32)), OverwriteBlend)
when defined(release):
{.pop.}

View file

@ -5,24 +5,24 @@ when defined(amd64) and not defined(pixieNoSimd):
type
PaintKind* = enum
PaintSolid
PaintImage
PaintImageTiled
PaintGradientLinear
PaintGradientRadial
PaintGradientAngular
SolidPaint
ImagePaint
TiledImagePaint
LinearGradientPaint
RadialGradientPaint
AngularGradientPaint
Paint* = ref object
## Paint used to fill paths.
kind*: PaintKind
blendMode*: BlendMode ## Blend mode.
opacity*: float32
# PaintSolid
# SolidPaint
color*: Color ## Color to fill with.
# PaintImage, PaintImageTiled:
# ImagePaint, TiledImagePaint:
image*: Image ## Image to fill with.
imageMat*: Mat3 ## Matrix of the filled image.
# PaintGradientLinear, PaintGradientRadial, PaintGradientAngular:
# LinearGradientPaint, RadialGradientPaint, AngularGradientPaint:
gradientHandlePositions*: seq[Vec2] ## Gradient positions (image space).
gradientStops*: seq[ColorStop] ## Color stops (gradient space).
@ -51,13 +51,13 @@ proc newPaint*(paint: Paint): Paint {.raises: [].} =
converter parseSomePaint*(paint: SomePaint): Paint {.inline.} =
## Given SomePaint, parse it in different ways.
when type(paint) is string:
result = newPaint(PaintSolid)
result = newPaint(SolidPaint)
try:
result.color = parseHtmlColor(paint)
except:
raise newException(PixieError, "Unable to parse color " & paint)
elif type(paint) is SomeColor:
result = newPaint(PaintSolid)
result = newPaint(SolidPaint)
when type(paint) is Color:
result.color = paint
else:
@ -229,11 +229,11 @@ proc fillGradient*(image: Image, paint: Paint) {.raises: [PixieError].} =
## Fills with the Paint gradient.
case paint.kind:
of PaintGradientLinear:
of LinearGradientPaint:
image.fillGradientLinear(paint)
of PaintGradientRadial:
of RadialGradientPaint:
image.fillGradientRadial(paint)
of PaintGradientAngular:
of AngularGradientPaint:
image.fillGradientAngular(paint)
else:
raise newException(PixieError, "Paint must be a gradient")

View file

@ -1335,10 +1335,10 @@ proc fillCoverage(
# If the coverages are not all zero
if mm_movemask_epi8(mm_cmpeq_epi32(coverageVec, vec255)) == 0xffff:
# If the coverages are all 255
if blendMode == BlendOverwrite:
if blendMode == OverwriteBlend:
for i in 0 ..< 4:
mm_storeu_si128(image.data[index + i * 4].addr, colorVec)
elif blendMode == BlendNormal:
elif blendMode == NormalBlend:
if rgbx.a == 255:
for i in 0 ..< 4:
mm_storeu_si128(image.data[index + i * 4].addr, colorVec)
@ -1378,7 +1378,7 @@ proc fillCoverage(
source = mm_or_si128(sourceEven, mm_slli_epi16(sourceOdd, 8))
if blendMode == BlendOverwrite:
if blendMode == OverwriteBlend:
mm_storeu_si128(image.data[index + i * 4].addr, source)
else:
let backdrop = mm_loadu_si128(image.data[index + i * 4].addr)
@ -1389,12 +1389,12 @@ proc fillCoverage(
coverageVec = mm_srli_si128(coverageVec, 4)
if blendMode == BlendNormal:
if blendMode == NormalBlend:
useCoverage(blendNormalInlineSimd)
else:
useCoverage(blenderSimd)
elif blendMode == BlendMask:
elif blendMode == MaskBlend:
for i in 0 ..< 4:
mm_storeu_si128(image.data[index + i * 4].addr, vecZero)
@ -1403,8 +1403,8 @@ proc fillCoverage(
let blender = blendMode.blender()
for x in x ..< startX + coverages.len:
let coverage = coverages[x - startX]
if coverage != 0 or blendMode == BlendExcludeMask:
if blendMode == BlendNormal and coverage == 255 and rgbx.a == 255:
if coverage != 0 or blendMode == ExcludeMaskBlend:
if blendMode == NormalBlend and coverage == 255 and rgbx.a == 255:
# Skip blending
image.unsafe[x, y] = rgbx
continue
@ -1416,15 +1416,15 @@ proc fillCoverage(
source.b = ((source.b.uint32 * coverage) div 255).uint8
source.a = ((source.a.uint32 * coverage) div 255).uint8
if blendMode == BlendOverwrite:
if blendMode == OverwriteBlend:
image.unsafe[x, y] = source
else:
let backdrop = image.unsafe[x, y]
image.unsafe[x, y] = blender(backdrop, source)
elif blendMode == BlendMask:
elif blendMode == MaskBlend:
image.unsafe[x, y] = rgbx(0, 0, 0, 0)
if blendMode == BlendMask:
if blendMode == MaskBlend:
image.clearUnsafe(0, y, startX, y)
image.clearUnsafe(startX + coverages.len, y, image.width, y)
@ -1446,7 +1446,7 @@ proc fillCoverage(
coverageVec = mm_loadu_si128(coverages[x - startX].unsafeAddr)
if mm_movemask_epi8(mm_cmpeq_epi16(coverageVec, vecZero)) != 0xffff:
# If the coverages are not all zero
if blendMode == BlendOverwrite:
if blendMode == OverwriteBlend:
mm_storeu_si128(mask.data[index].addr, coverageVec)
else:
let backdrop = mm_loadu_si128(mask.data[index].addr)
@ -1454,23 +1454,23 @@ proc fillCoverage(
mask.data[index].addr,
maskerSimd(backdrop, coverageVec)
)
elif blendMode == BlendMask:
elif blendMode == MaskBlend:
mm_storeu_si128(mask.data[index].addr, vecZero)
x += 16
let masker = blendMode.masker()
for x in x ..< startX + coverages.len:
let coverage = coverages[x - startX]
if coverage != 0 or blendMode == BlendExcludeMask:
if blendMode == BlendOverwrite:
if coverage != 0 or blendMode == ExcludeMaskBlend:
if blendMode == OverwriteBlend:
mask.unsafe[x, y] = coverage
else:
let backdrop = mask.unsafe[x, y]
mask.unsafe[x, y] = masker(backdrop, coverage)
elif blendMode == BlendMask:
elif blendMode == MaskBlend:
mask.unsafe[x, y] = 0
if blendMode == BlendMask:
if blendMode == MaskBlend:
mask.clearUnsafe(0, y, startX, y)
mask.clearUnsafe(startX + coverages.len, y, mask.width, y)
@ -1496,7 +1496,7 @@ proc fillHits(
filledTo = fillStart + fillLen
if blendMode == BlendOverwrite or (blendMode == BlendNormal and rgbx.a == 255):
if blendMode == OverwriteBlend or (blendMode == NormalBlend and rgbx.a == 255):
fillUnsafe(image.data, rgbx, image.dataIndex(fillStart, y), fillLen)
continue
@ -1505,8 +1505,8 @@ proc fillHits(
if blendMode.hasSimdBlender():
# When supported, SIMD blend as much as possible
let colorVec = mm_set1_epi32(cast[int32](rgbx))
if blendMode == BlendNormal:
# For path filling, BlendNormal is almost always used.
if blendMode == NormalBlend:
# For path filling, NormalBlend is almost always used.
# Inline SIMD is faster here.
for _ in 0 ..< fillLen div 4:
let
@ -1533,7 +1533,7 @@ proc fillHits(
let backdrop = image.unsafe[x, y]
image.unsafe[x, y] = blender(backdrop, rgbx)
if blendMode == BlendMask:
if blendMode == MaskBlend:
image.clearUnsafe(0, y, startX, y)
image.clearUnsafe(filledTo, y, image.width, y)
@ -1558,7 +1558,7 @@ proc fillHits(
filledTo = fillStart + fillLen
if blendMode in {BlendNormal, BlendOverwrite}:
if blendMode in {NormalBlend, OverwriteBlend}:
fillUnsafe(mask.data, 255, mask.dataIndex(fillStart, y), fillLen)
continue
@ -1582,7 +1582,7 @@ proc fillHits(
let backdrop = mask.unsafe[x, y]
mask.unsafe[x, y] = masker(backdrop, 255)
if blendMode == BlendMask:
if blendMode == MaskBlend:
mask.clearUnsafe(0, y, startX, y)
mask.clearUnsafe(filledTo, y, mask.width, y)
@ -1650,7 +1650,7 @@ proc fillShapes(
blendMode
)
if blendMode == BlendMask:
if blendMode == MaskBlend:
image.clearUnsafe(0, 0, 0, startY)
image.clearUnsafe(0, pathHeight, 0, image.height)
@ -1699,7 +1699,7 @@ proc fillShapes(
else:
mask.fillHits(startX, y, hits, numHits, windingRule, blendMode)
if blendMode == BlendMask:
if blendMode == MaskBlend:
mask.clearUnsafe(0, 0, 0, startY)
mask.clearUnsafe(0, pathHeight, 0, mask.height)
@ -1883,7 +1883,7 @@ proc fillPath*(
path: SomePath,
transform = mat3(),
windingRule = NonZero,
blendMode = BlendNormal
blendMode = NormalBlend
) {.raises: [PixieError].} =
## Fills a path.
var shapes = parseSomePath(path, true, transform.pixelScale())
@ -1901,8 +1901,8 @@ proc fillPath*(
if paint.opacity == 0:
return
if paint.kind == PaintSolid:
if paint.color.a > 0 or paint.blendMode == BlendOverwrite:
if paint.kind == SolidPaint:
if paint.color.a > 0 or paint.blendMode == OverwriteBlend:
var shapes = parseSomePath(path, true, transform.pixelScale())
shapes.transform(transform)
var color = paint.color
@ -1922,13 +1922,13 @@ proc fillPath*(
paint.opacity = 1
case paint.kind:
of PaintSolid:
of SolidPaint:
discard # Handled above
of PaintImage:
of ImagePaint:
fill.draw(paint.image, paint.imageMat)
of PaintImageTiled:
of TiledImagePaint:
fill.drawTiled(paint.image, paint.imageMat)
of PaintGradientLinear, PaintGradientRadial, PaintGradientAngular:
of LinearGradientPaint, RadialGradientPaint, AngularGradientPaint:
fill.fillGradient(paint)
paint.opacity = savedOpacity
@ -1948,7 +1948,7 @@ proc strokePath*(
lineJoin = MiterJoin,
miterLimit = defaultMiterLimit,
dashes: seq[float32] = @[],
blendMode = BlendNormal
blendMode = NormalBlend
) {.raises: [PixieError].} =
## Strokes a path.
let pixelScale = transform.pixelScale()
@ -1979,8 +1979,8 @@ proc strokePath*(
if paint.opacity == 0:
return
if paint.kind == PaintSolid:
if paint.color.a > 0 or paint.blendMode == BlendOverwrite:
if paint.kind == SolidPaint:
if paint.color.a > 0 or paint.blendMode == OverwriteBlend:
var strokeShapes = strokeShapes(
parseSomePath(path, false, transform.pixelScale()),
strokeWidth,
@ -2016,13 +2016,13 @@ proc strokePath*(
paint.opacity = 1
case paint.kind:
of PaintSolid:
of SolidPaint:
discard # Handled above
of PaintImage:
of ImagePaint:
fill.draw(paint.image, paint.imageMat)
of PaintImageTiled:
of TiledImagePaint:
fill.drawTiled(paint.image, paint.imageMat)
of PaintGradientLinear, PaintGradientRadial, PaintGradientAngular:
of LinearGradientPaint, RadialGradientPaint, AngularGradientPaint:
fill.fillGradient(paint)
paint.opacity = savedOpacity

View file

@ -10,7 +10,7 @@ block:
b.fill(rgba(0, 255, 0, 255))
timeIt "drawCorrect small-on-big":
a.drawCorrect(b, translate(vec2(25, 25)), blendMode = BlendNormal)
a.drawCorrect(b, translate(vec2(25, 25)), blendMode = NormalBlend)
keep(b)
block:
@ -21,7 +21,7 @@ block:
b.fill(rgba(0, 255, 0, 255))
timeIt "drawUber small-on-big":
a.drawUber(b, translate(vec2(25, 25)), blendMode = BlendNormal)
a.drawUber(b, translate(vec2(25, 25)), blendMode = NormalBlend)
keep(b)
block:
@ -32,7 +32,7 @@ block:
b.fill(rgba(0, 255, 0, 255))
timeIt "drawCorrect small-on-big smooth":
a.drawCorrect(b, translate(vec2(25.1, 25.1)), blendMode = BlendNormal)
a.drawCorrect(b, translate(vec2(25.1, 25.1)), blendMode = NormalBlend)
keep(b)
block:
@ -43,5 +43,5 @@ block:
b.fill(rgba(0, 255, 0, 255))
timeIt "drawUber small-on-big smooth":
a.drawUber(b, translate(vec2(25.1, 25.1)), blendMode = BlendNormal)
a.drawUber(b, translate(vec2(25.1, 25.1)), blendMode = NormalBlend)
keep(b)

View file

@ -7,8 +7,8 @@ block:
a.fill(rgba(255, 0, 0, 255))
b.fill(rgba(0, 255, 0, 255))
timeIt "draw small-on-big BlendNormal":
a.draw(b, translate(vec2(25, 25)), BlendNormal)
timeIt "draw small-on-big NormalBlend":
a.draw(b, translate(vec2(25, 25)), NormalBlend)
keep(b)
block:
@ -18,8 +18,8 @@ block:
a.fill(rgba(255, 0, 0, 255))
b.fill(rgba(0, 255, 0, 255))
timeIt "draw small-on-big Smooth BlendNormal":
a.draw(b, translate(vec2(25.2, 25.2)), BlendNormal)
timeIt "draw small-on-big Smooth NormalBlend":
a.draw(b, translate(vec2(25.2, 25.2)), NormalBlend)
keep(b)
block:
@ -29,8 +29,8 @@ block:
a.fill(rgba(255, 0, 0, 255))
b.fill(rgba(0, 255, 0, 255))
timeIt "draw big-on-bigger BlendNormal":
a.draw(b, translate(vec2(25, 25)), BlendNormal)
timeIt "draw big-on-bigger NormalBlend":
a.draw(b, translate(vec2(25, 25)), NormalBlend)
keep(b)
block:
@ -41,7 +41,7 @@ block:
b.fill(rgba(0, 255, 0, 255))
timeIt "draw [scale 0.5]":
a.draw(b, translate(vec2(25, 25)) * scale(vec2(0.5, 0.5)), BlendNormal)
a.draw(b, translate(vec2(25, 25)) * scale(vec2(0.5, 0.5)), NormalBlend)
keep(b)
block:
@ -52,7 +52,7 @@ block:
b.fill(rgba(0, 255, 0, 255))
timeIt "draw [scale 2]":
a.draw(b, translate(vec2(25, 25)) * scale(vec2(2, 2)), BlendNormal)
a.draw(b, translate(vec2(25, 25)) * scale(vec2(2, 2)), NormalBlend)
keep(b)
block:
@ -63,7 +63,7 @@ block:
b.fill(rgba(0, rand(255).uint8, 0, 255))
timeIt "draw Smooth [x translate]":
a.draw(b, translate(vec2(25.2, 0)), BlendNormal)
a.draw(b, translate(vec2(25.2, 0)), NormalBlend)
keep(b)
block:
@ -74,7 +74,7 @@ block:
b.fill(rgba(0, rand(255).uint8, 0, 255))
timeIt "draw Smooth [y translate]":
a.draw(b, translate(vec2(0, 25.2)), BlendNormal)
a.draw(b, translate(vec2(0, 25.2)), NormalBlend)
keep(b)
block:
@ -85,7 +85,7 @@ block:
b.fill(rgba(0, rand(255).uint8, 0, 255))
timeIt "draw Smooth [x + y translate]":
a.draw(b, translate(vec2(25.2, 25.2)), BlendNormal)
a.draw(b, translate(vec2(25.2, 25.2)), NormalBlend)
keep(b)
block:
@ -96,7 +96,7 @@ block:
b.fill(rgba(0, rand(255).uint8, 0, 255))
timeIt "draw Smooth [rotate 45 deg]":
a.draw(b, translate(vec2(0, 500)) * rotate(toRadians(45)), BlendNormal)
a.draw(b, translate(vec2(0, 500)) * rotate(toRadians(45)), NormalBlend)
keep(b)
block:
@ -107,7 +107,7 @@ block:
b.fill(rand(255).uint8)
timeIt "draw mask Smooth [rotate 45 deg]":
a.draw(b, translate(vec2(0, 500)) * rotate(toRadians(45)), BlendNormal)
a.draw(b, translate(vec2(0, 500)) * rotate(toRadians(45)), NormalBlend)
keep(b)
block:

View file

@ -3,7 +3,7 @@ import benchy, pixie
let image = newImage(1000, 1000)
timeIt "GradientLinear vertical":
let paint = newPaint(PaintGradientLinear)
let paint = newPaint(LinearGradientPaint)
paint.gradientHandlePositions = @[
vec2(50, 0),
vec2(50, 1000),
@ -15,7 +15,7 @@ timeIt "GradientLinear vertical":
image.fillGradient(paint)
timeIt "GradientLinear horizontal":
let paint = newPaint(PaintGradientLinear)
let paint = newPaint(LinearGradientPaint)
paint.gradientHandlePositions = @[
vec2(0, 50),
vec2(1000, 50),
@ -30,7 +30,7 @@ timeIt "GradientLinear horizontal":
# discard
timeIt "GradientLinear angular":
let paint = newPaint(PaintGradientAngular)
let paint = newPaint(AngularGradientPaint)
paint.gradientHandlePositions = @[
vec2(500, 500),
vec2(1000, 500),

View file

@ -54,7 +54,7 @@ proc renderEmojiSet(index: int) =
rendered.draw(
icon,
translate(pos),
BlendOverwrite
OverwriteBlend
)
rendered.writeFile(&"tests/fileformats/svg/{emojiSet.name}.png")

View file

@ -55,7 +55,7 @@ proc renderIconSet(index: int) =
rendered.draw(
icon,
translate(pos),
BlendOverwrite
OverwriteBlend
)
rendered.writeFile(&"tests/fileformats/svg/{iconSet.name}.png")

View file

@ -526,9 +526,9 @@ block:
image.fill(rgba(255, 255, 255, 255))
let paint = newPaint(PaintSolid)
let paint = newPaint(SolidPaint)
paint.color = color(0, 0, 1, 1)
paint.blendMode = BlendExclusion
paint.blendMode = ExclusionBlend
ctx.fillStyle = paint

View file

@ -223,7 +223,7 @@ block:
font,
"a b c d e f g h i j k l m n o p",
bounds = vec2(200, 0),
hAlign = AlignRight
hAlign = RightAlign
)
doDiff(image, "basic10")
@ -588,72 +588,72 @@ block:
font,
"TopLeft",
bounds = image.wh,
hAlign = AlignLeft,
vAlign = AlignTop
hAlign = LeftAlign,
vAlign = TopAlign
)
image.fillText(
font,
"TopCenter",
bounds = image.wh,
hAlign = AlignCenter,
vAlign = AlignTop
hAlign = CenterAlign,
vAlign = TopAlign
)
image.fillText(
font,
"TopRight",
bounds = image.wh,
hAlign = AlignRight,
vAlign = AlignTop
hAlign = RightAlign,
vAlign = TopAlign
)
image.fillText(
font,
"MiddleLeft",
bounds = image.wh,
hAlign = AlignLeft,
vAlign = AlignMiddle
hAlign = LeftAlign,
vAlign = MiddleAlign
)
image.fillText(
font,
"MiddleCenter",
bounds = image.wh,
hAlign = AlignCenter,
vAlign = AlignMiddle
hAlign = CenterAlign,
vAlign = MiddleAlign
)
image.fillText(
font,
"MiddleRight",
bounds = image.wh,
hAlign = AlignRight,
vAlign = AlignMiddle
hAlign = RightAlign,
vAlign = MiddleAlign
)
image.fillText(
font,
"BottomLeft",
bounds = image.wh,
hAlign = AlignLeft,
vAlign = AlignBottom
hAlign = LeftAlign,
vAlign = BottomAlign
)
image.fillText(
font,
"BottomCenter",
bounds = image.wh,
hAlign = AlignCenter,
vAlign = AlignBottom
hAlign = CenterAlign,
vAlign = BottomAlign
)
image.fillText(
font,
"BottomRight",
bounds = image.wh,
hAlign = AlignRight,
vAlign = AlignBottom
hAlign = RightAlign,
vAlign = BottomAlign
)
doDiff(image, "alignments")
@ -661,7 +661,7 @@ block:
block:
var font = readFont("tests/fonts/IBMPlexSans-Regular_2.ttf")
font.size = 48
font.paint = newPaint(PaintGradientLinear)
font.paint = newPaint(LinearGradientPaint)
font.paint.gradientHandlePositions = @[
vec2(0, 50),
vec2(100, 50),

View file

@ -14,19 +14,19 @@ block:
heartShape,
rgba(255, 0, 0, 255)
)
image.writeFile("tests/paths/paintSolid.png")
image.writeFile("tests/paths/SolidPaint.png")
block:
let paint = newPaint(PaintImage)
let paint = newPaint(ImagePaint)
paint.image = decodePng(readFile("tests/fileformats/png/mandrill.png"))
paint.imageMat = scale(vec2(0.2, 0.2))
let image = newImage(100, 100)
image.fillPath(heartShape, paint)
image.writeFile("tests/paths/paintImage.png")
image.writeFile("tests/paths/ImagePaint.png")
block:
let paint = newPaint(PaintImage)
let paint = newPaint(ImagePaint)
paint.image = decodePng(readFile("tests/fileformats/png/mandrill.png"))
paint.imageMat = scale(vec2(0.2, 0.2))
paint.opacity = 0.5
@ -36,16 +36,16 @@ block:
image.writeFile("tests/paths/paintImageOpacity.png")
block:
let paint = newPaint(PaintImageTiled)
let paint = newPaint(TiledImagePaint)
paint.image = decodePng(readFile("tests/fileformats/png/mandrill.png"))
paint.imageMat = scale(vec2(0.02, 0.02))
let image = newImage(100, 100)
image.fillPath(heartShape, paint)
image.writeFile("tests/paths/paintImageTiled.png")
image.writeFile("tests/paths/TiledImagePaint.png")
block:
let paint = newPaint(PaintImageTiled)
let paint = newPaint(TiledImagePaint)
paint.image = decodePng(readFile("tests/fileformats/png/mandrill.png"))
paint.imageMat = scale(vec2(0.02, 0.02))
paint.opacity = 0.5
@ -55,7 +55,7 @@ block:
image.writeFile("tests/paths/paintImageTiledOpacity.png")
block:
let paint = newPaint(PaintGradientLinear)
let paint = newPaint(LinearGradientPaint)
paint.gradientHandlePositions = @[
vec2(0, 50),
vec2(100, 50),
@ -70,7 +70,7 @@ block:
image.writeFile("tests/paths/gradientLinear.png")
block:
let paint = newPaint(PaintGradientLinear)
let paint = newPaint(LinearGradientPaint)
paint.gradientHandlePositions = @[
vec2(50, 0),
vec2(50, 100),
@ -85,7 +85,7 @@ block:
image.writeFile("tests/paths/gradientLinear2.png")
block:
let paint = newPaint(PaintGradientRadial)
let paint = newPaint(RadialGradientPaint)
paint.gradientHandlePositions = @[
vec2(50, 50),
vec2(100, 50),
@ -101,7 +101,7 @@ block:
image.writeFile("tests/paths/gradientRadial.png")
block:
let paint = newPaint(PaintGradientAngular)
let paint = newPaint(AngularGradientPaint)
paint.gradientHandlePositions = @[
vec2(50, 50),
vec2(100, 50),
@ -117,7 +117,7 @@ block:
image.writeFile("tests/paths/gradientAngular.png")
block:
let paint = newPaint(PaintGradientAngular)
let paint = newPaint(AngularGradientPaint)
paint.gradientHandlePositions = @[
vec2(50, 50),
vec2(100, 50),

View file

@ -390,9 +390,9 @@ block:
rgbx(255, 0, 0, 255)
)
let paint = newPaint(PaintSolid)
let paint = newPaint(SolidPaint)
paint.color = color(0, 1, 0, 1)
paint.blendMode = BlendExcludeMask
paint.blendMode = ExcludeMaskBlend
image.fillPath(
"M 30 30 H 80 V 80 H 30 z",
@ -407,9 +407,9 @@ block:
rgbx(255, 0, 0, 255)
)
let paint = newPaint(PaintSolid)
let paint = newPaint(SolidPaint)
paint.color = color(0, 1, 0, 1)
paint.blendMode = BlendExcludeMask
paint.blendMode = ExcludeMaskBlend
image.fillPath(
"M 30.1 30.1 H 80.1 V 80.1 H 30.1 z",
@ -424,9 +424,9 @@ block:
rgbx(255, 0, 0, 255)
)
let paint = newPaint(PaintSolid)
let paint = newPaint(SolidPaint)
paint.color = color(0, 1, 0, 1)
paint.blendMode = BlendMask
paint.blendMode = MaskBlend
image.fillPath(
"M 30 30 H 80 V 80 H 30 z",
@ -441,9 +441,9 @@ block:
rgbx(255, 0, 0, 255)
)
let paint = newPaint(PaintSolid)
let paint = newPaint(SolidPaint)
paint.color = color(0, 1, 0, 1)
paint.blendMode = BlendMask
paint.blendMode = MaskBlend
image.fillPath(
"M 30.1 30.1 H 80.1 V 80.1 H 30.1 z",
@ -454,25 +454,25 @@ block:
block:
let mask = newMask(100, 100)
mask.fillPath("M 10 10 H 60 V 60 H 10 z")
mask.fillPath("M 30 30 H 80 V 80 H 30 z", blendMode = BlendExcludeMask)
mask.fillPath("M 30 30 H 80 V 80 H 30 z", blendMode = ExcludeMaskBlend)
writeFile("tests/paths/maskRectExcludeMask.png", mask.encodePng())
block:
let mask = newMask(100, 100)
mask.fillPath("M 10.1 10.1 H 60.1 V 60.1 H 10.1 z")
mask.fillPath("M 30.1 30.1 H 80.1 V 80.1 H 30.1 z", blendMode = BlendExcludeMask)
mask.fillPath("M 30.1 30.1 H 80.1 V 80.1 H 30.1 z", blendMode = ExcludeMaskBlend)
writeFile("tests/paths/maskRectExcludeMaskAA.png", mask.encodePng())
block:
let mask = newMask(100, 100)
mask.fillPath("M 10 10 H 60 V 60 H 10 z")
mask.fillPath("M 30 30 H 80 V 80 H 30 z", blendMode = BlendMask)
mask.fillPath("M 30 30 H 80 V 80 H 30 z", blendMode = MaskBlend)
writeFile("tests/paths/maskRectMask.png", mask.encodePng())
block:
let mask = newMask(100, 100)
mask.fillPath("M 10.1 10.1 H 60.1 V 60.1 H 10.1 z")
mask.fillPath("M 30.1 30.1 H 80.1 V 80.1 H 30.1 z", blendMode = BlendMask)
mask.fillPath("M 30.1 30.1 H 80.1 V 80.1 H 30.1 z", blendMode = MaskBlend)
writeFile("tests/paths/maskRectMaskAA.png", mask.encodePng())
block:
@ -613,7 +613,7 @@ block:
let path = newPath()
path.circle(50, 50, 30)
let paint = newPaint(PaintSolid)
let paint = newPaint(SolidPaint)
paint.color = color(1, 0, 1, 1)
paint.opacity = 0.5
@ -626,7 +626,7 @@ block:
let path = newPath()
path.circle(50, 50, 30)
let paint = newPaint(PaintSolid)
let paint = newPaint(SolidPaint)
paint.color = color(1, 0, 1, 1)
paint.opacity = 0.5