morepretty
This commit is contained in:
parent
46cf47bdeb
commit
f00860a9cc
4 changed files with 38 additions and 40 deletions
|
@ -45,7 +45,7 @@ when defined(release):
|
||||||
proc min(a, b: uint32): uint32 {.inline.} =
|
proc min(a, b: uint32): uint32 {.inline.} =
|
||||||
if a < b: a else: b
|
if a < b: a else: b
|
||||||
|
|
||||||
proc alphaFix(backdrop, source, mixed: ColorRGBA): ColorRGBA =
|
proc alphaFix(backdrop, source, mixed: ColorRGBA): ColorRGBA =
|
||||||
## After mixing an image, adjust its alpha value to be correct.
|
## After mixing an image, adjust its alpha value to be correct.
|
||||||
let
|
let
|
||||||
sa = source.a.uint32
|
sa = source.a.uint32
|
||||||
|
@ -68,7 +68,7 @@ proc alphaFix(backdrop, source, mixed: ColorRGBA): ColorRGBA =
|
||||||
result.b = (b div a div 255).uint8
|
result.b = (b div a div 255).uint8
|
||||||
result.a = a.uint8
|
result.a = a.uint8
|
||||||
|
|
||||||
proc alphaFix(backdrop, source, mixed: Color): Color =
|
proc alphaFix(backdrop, source, mixed: Color): Color =
|
||||||
## After mixing an image, adjust its alpha value to be correct.
|
## After mixing an image, adjust its alpha value to be correct.
|
||||||
result.a = (source.a + backdrop.a * (1.0 - source.a))
|
result.a = (source.a + backdrop.a * (1.0 - source.a))
|
||||||
if result.a == 0:
|
if result.a == 0:
|
||||||
|
@ -165,7 +165,7 @@ proc SetSat(C: Color, s: float32): Color {.inline.} =
|
||||||
if satC > 0:
|
if satC > 0:
|
||||||
result = (C - min([C.r, C.g, C.b])) * s / satC
|
result = (C - min([C.r, C.g, C.b])) * s / satC
|
||||||
|
|
||||||
proc blendNormal(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendNormal(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
if backdrop.a == 0:
|
if backdrop.a == 0:
|
||||||
return source
|
return source
|
||||||
if source.a == 255:
|
if source.a == 255:
|
||||||
|
@ -179,7 +179,7 @@ proc blendNormal(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
result.b = source.b + ((backdrop.b.uint32 * k) div 255).uint8
|
result.b = source.b + ((backdrop.b.uint32 * k) div 255).uint8
|
||||||
result.a = blendAlpha(backdrop.a, source.a)
|
result.a = blendAlpha(backdrop.a, source.a)
|
||||||
|
|
||||||
proc blendDarken(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendDarken(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
proc blend(
|
proc blend(
|
||||||
backdropColor, backdropAlpha, sourceColor, sourceAlpha: uint8
|
backdropColor, backdropAlpha, sourceColor, sourceAlpha: uint8
|
||||||
): uint8 {.inline.} =
|
): uint8 {.inline.} =
|
||||||
|
@ -193,7 +193,7 @@ proc blendDarken(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
result.b = blend(backdrop.b, backdrop.a, source.b, source.a)
|
result.b = blend(backdrop.b, backdrop.a, source.b, source.a)
|
||||||
result.a = blendAlpha(backdrop.a, source.a)
|
result.a = blendAlpha(backdrop.a, source.a)
|
||||||
|
|
||||||
proc blendMultiply(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendMultiply(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
proc blend(
|
proc blend(
|
||||||
backdropColor, backdropAlpha, sourceColor, sourceAlpha: uint8
|
backdropColor, backdropAlpha, sourceColor, sourceAlpha: uint8
|
||||||
): uint8 {.inline.} =
|
): uint8 {.inline.} =
|
||||||
|
@ -218,7 +218,7 @@ proc blendMultiply(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
# result = alphaFix(backdrop, source, result)
|
# result = alphaFix(backdrop, source, result)
|
||||||
# result = result.toPremultipliedAlpha()
|
# result = result.toPremultipliedAlpha()
|
||||||
|
|
||||||
proc blendColorBurn(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendColorBurn(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
let
|
let
|
||||||
backdrop = backdrop.rgba()
|
backdrop = backdrop.rgba()
|
||||||
source = source.rgba()
|
source = source.rgba()
|
||||||
|
@ -235,7 +235,7 @@ proc blendColorBurn(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
blended.b = blend(backdrop.b, source.b)
|
blended.b = blend(backdrop.b, source.b)
|
||||||
result = alphaFix(backdrop, source, blended).rgbx()
|
result = alphaFix(backdrop, source, blended).rgbx()
|
||||||
|
|
||||||
proc blendLighten(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendLighten(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
proc blend(
|
proc blend(
|
||||||
backdropColor, backdropAlpha, sourceColor, sourceAlpha: uint8
|
backdropColor, backdropAlpha, sourceColor, sourceAlpha: uint8
|
||||||
): uint8 {.inline.} =
|
): uint8 {.inline.} =
|
||||||
|
@ -249,7 +249,7 @@ proc blendLighten(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
result.b = blend(backdrop.b, backdrop.a, source.b, source.a)
|
result.b = blend(backdrop.b, backdrop.a, source.b, source.a)
|
||||||
result.a = blendAlpha(backdrop.a, source.a)
|
result.a = blendAlpha(backdrop.a, source.a)
|
||||||
|
|
||||||
proc blendScreen(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendScreen(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
result.r = screen(backdrop.r, source.r)
|
result.r = screen(backdrop.r, source.r)
|
||||||
result.g = screen(backdrop.g, source.g)
|
result.g = screen(backdrop.g, source.g)
|
||||||
result.b = screen(backdrop.b, source.b)
|
result.b = screen(backdrop.b, source.b)
|
||||||
|
@ -265,7 +265,7 @@ proc blendScreen(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
# result = alphaFix(backdrop, source, result)
|
# result = alphaFix(backdrop, source, result)
|
||||||
# result = result.toPremultipliedAlpha()
|
# result = result.toPremultipliedAlpha()
|
||||||
|
|
||||||
proc blendColorDodge(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendColorDodge(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
let
|
let
|
||||||
backdrop = backdrop.rgba()
|
backdrop = backdrop.rgba()
|
||||||
source = source.rgba()
|
source = source.rgba()
|
||||||
|
@ -282,13 +282,13 @@ proc blendColorDodge(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
blended.b = blend(backdrop.b, source.b)
|
blended.b = blend(backdrop.b, source.b)
|
||||||
result = alphaFix(backdrop, source, blended).rgbx()
|
result = alphaFix(backdrop, source, blended).rgbx()
|
||||||
|
|
||||||
proc blendOverlay(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendOverlay(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
result.r = hardLight(source.r, source.a, backdrop.r, backdrop.a)
|
result.r = hardLight(source.r, source.a, backdrop.r, backdrop.a)
|
||||||
result.g = hardLight(source.g, source.a, backdrop.g, backdrop.a)
|
result.g = hardLight(source.g, source.a, backdrop.g, backdrop.a)
|
||||||
result.b = hardLight(source.b, source.a, backdrop.b, backdrop.a)
|
result.b = hardLight(source.b, source.a, backdrop.b, backdrop.a)
|
||||||
result.a = blendAlpha(backdrop.a, source.a)
|
result.a = blendAlpha(backdrop.a, source.a)
|
||||||
|
|
||||||
proc blendSoftLight(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendSoftLight(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
# proc softLight(backdrop, source: int32): uint8 {.inline.} =
|
# proc softLight(backdrop, source: int32): uint8 {.inline.} =
|
||||||
# ## Pegtop
|
# ## Pegtop
|
||||||
# (
|
# (
|
||||||
|
@ -362,13 +362,13 @@ proc blendSoftLight(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
|
|
||||||
result = rgba.rgbx()
|
result = rgba.rgbx()
|
||||||
|
|
||||||
proc blendHardLight(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendHardLight(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
result.r = hardLight(backdrop.r, backdrop.a, source.r, source.a)
|
result.r = hardLight(backdrop.r, backdrop.a, source.r, source.a)
|
||||||
result.g = hardLight(backdrop.g, backdrop.a, source.g, source.a)
|
result.g = hardLight(backdrop.g, backdrop.a, source.g, source.a)
|
||||||
result.b = hardLight(backdrop.b, backdrop.a, source.b, source.a)
|
result.b = hardLight(backdrop.b, backdrop.a, source.b, source.a)
|
||||||
result.a = blendAlpha(backdrop.a, source.a)
|
result.a = blendAlpha(backdrop.a, source.a)
|
||||||
|
|
||||||
proc blendDifference(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendDifference(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
proc blend(
|
proc blend(
|
||||||
backdropColor, backdropAlpha, sourceColor, sourceAlpha: uint8
|
backdropColor, backdropAlpha, sourceColor, sourceAlpha: uint8
|
||||||
): uint8 {.inline.} =
|
): uint8 {.inline.} =
|
||||||
|
@ -384,7 +384,7 @@ proc blendDifference(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
result.b = blend(backdrop.b, backdrop.a, source.b, source.a)
|
result.b = blend(backdrop.b, backdrop.a, source.b, source.a)
|
||||||
result.a = blendAlpha(backdrop.a, source.a)
|
result.a = blendAlpha(backdrop.a, source.a)
|
||||||
|
|
||||||
proc blendExclusion(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendExclusion(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
proc blend(backdrop, source: uint32): uint8 {.inline.} =
|
proc blend(backdrop, source: uint32): uint8 {.inline.} =
|
||||||
let v = (backdrop + source).int32 - ((2 * backdrop * source) div 255).int32
|
let v = (backdrop + source).int32 - ((2 * backdrop * source) div 255).int32
|
||||||
max(0, v).uint8
|
max(0, v).uint8
|
||||||
|
@ -393,56 +393,56 @@ proc blendExclusion(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
result.b = blend(backdrop.b.uint32, source.b.uint32)
|
result.b = blend(backdrop.b.uint32, source.b.uint32)
|
||||||
result.a = blendAlpha(backdrop.a, source.a)
|
result.a = blendAlpha(backdrop.a, source.a)
|
||||||
|
|
||||||
proc blendColor(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendColor(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
let
|
let
|
||||||
backdrop = backdrop.rgba().color
|
backdrop = backdrop.rgba().color
|
||||||
source = source.rgba().color
|
source = source.rgba().color
|
||||||
blended = SetLum(source, Lum(backdrop))
|
blended = SetLum(source, Lum(backdrop))
|
||||||
result = alphaFix(backdrop, source, blended).rgba.rgbx()
|
result = alphaFix(backdrop, source, blended).rgba.rgbx()
|
||||||
|
|
||||||
proc blendLuminosity(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendLuminosity(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
let
|
let
|
||||||
backdrop = backdrop.rgba().color
|
backdrop = backdrop.rgba().color
|
||||||
source = source.rgba().color
|
source = source.rgba().color
|
||||||
blended = SetLum(backdrop, Lum(source))
|
blended = SetLum(backdrop, Lum(source))
|
||||||
result = alphaFix(backdrop, source, blended).rgba.rgbx()
|
result = alphaFix(backdrop, source, blended).rgba.rgbx()
|
||||||
|
|
||||||
proc blendHue(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendHue(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
let
|
let
|
||||||
backdrop = backdrop.rgba().color
|
backdrop = backdrop.rgba().color
|
||||||
source = source.rgba().color
|
source = source.rgba().color
|
||||||
blended = SetLum(SetSat(source, Sat(backdrop)), Lum(backdrop))
|
blended = SetLum(SetSat(source, Sat(backdrop)), Lum(backdrop))
|
||||||
result = alphaFix(backdrop, source, blended).rgba.rgbx()
|
result = alphaFix(backdrop, source, blended).rgba.rgbx()
|
||||||
|
|
||||||
proc blendSaturation(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendSaturation(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
let
|
let
|
||||||
backdrop = backdrop.rgba().color
|
backdrop = backdrop.rgba().color
|
||||||
source = source.rgba().color
|
source = source.rgba().color
|
||||||
blended = SetLum(SetSat(backdrop, Sat(source)), Lum(backdrop))
|
blended = SetLum(SetSat(backdrop, Sat(source)), Lum(backdrop))
|
||||||
result = alphaFix(backdrop, source, blended).rgba.rgbx()
|
result = alphaFix(backdrop, source, blended).rgba.rgbx()
|
||||||
|
|
||||||
proc blendMask(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendMask(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
let k = source.a.uint32
|
let k = source.a.uint32
|
||||||
result.r = ((backdrop.r * k) div 255).uint8
|
result.r = ((backdrop.r * k) div 255).uint8
|
||||||
result.g = ((backdrop.g * k) div 255).uint8
|
result.g = ((backdrop.g * k) div 255).uint8
|
||||||
result.b = ((backdrop.b * k) div 255).uint8
|
result.b = ((backdrop.b * k) div 255).uint8
|
||||||
result.a = ((backdrop.a * k) div 255).uint8
|
result.a = ((backdrop.a * k) div 255).uint8
|
||||||
|
|
||||||
proc blendSubtractMask(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendSubtractMask(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
let a = (backdrop.a.uint32 * (255 - source.a)) div 255
|
let a = (backdrop.a.uint32 * (255 - source.a)) div 255
|
||||||
result.r = ((backdrop.r * a) div 255).uint8
|
result.r = ((backdrop.r * a) div 255).uint8
|
||||||
result.g = ((backdrop.g * a) div 255).uint8
|
result.g = ((backdrop.g * a) div 255).uint8
|
||||||
result.b = ((backdrop.b * a) div 255).uint8
|
result.b = ((backdrop.b * a) div 255).uint8
|
||||||
result.a = a.uint8
|
result.a = a.uint8
|
||||||
|
|
||||||
proc blendExcludeMask(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendExcludeMask(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
let a = max(backdrop.a, source.a).uint32 - min(backdrop.a, source.a)
|
let a = max(backdrop.a, source.a).uint32 - min(backdrop.a, source.a)
|
||||||
result.r = ((source.r * a) div 255).uint8
|
result.r = ((source.r * a) div 255).uint8
|
||||||
result.g = ((source.g * a) div 255).uint8
|
result.g = ((source.g * a) div 255).uint8
|
||||||
result.b = ((source.b * a) div 255).uint8
|
result.b = ((source.b * a) div 255).uint8
|
||||||
result.a = a.uint8
|
result.a = a.uint8
|
||||||
|
|
||||||
proc blendOverwrite(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendOverwrite(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
source
|
source
|
||||||
|
|
||||||
# proc blendWhite(backdrop, source: ColorRGBX): ColorRGBX =
|
# proc blendWhite(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
|
@ -475,21 +475,21 @@ proc blender*(blendMode: BlendMode): Blender {.raises: [].} =
|
||||||
of bmSubtractMask: blendSubtractMask
|
of bmSubtractMask: blendSubtractMask
|
||||||
of bmExcludeMask: blendExcludeMask
|
of bmExcludeMask: blendExcludeMask
|
||||||
|
|
||||||
proc maskNormal(backdrop, source: uint8): uint8 =
|
proc maskNormal(backdrop, source: uint8): uint8 =
|
||||||
## Blending masks
|
## Blending masks
|
||||||
blendAlpha(backdrop, source)
|
blendAlpha(backdrop, source)
|
||||||
|
|
||||||
proc maskMask(backdrop, source: uint8): uint8 =
|
proc maskMask(backdrop, source: uint8): uint8 =
|
||||||
## Masking masks
|
## Masking masks
|
||||||
((backdrop.uint32 * source) div 255).uint8
|
((backdrop.uint32 * source) div 255).uint8
|
||||||
|
|
||||||
proc maskSubtract(backdrop, source: uint8): uint8 =
|
proc maskSubtract(backdrop, source: uint8): uint8 =
|
||||||
((backdrop.uint32 * (255 - source)) div 255).uint8
|
((backdrop.uint32 * (255 - source)) div 255).uint8
|
||||||
|
|
||||||
proc maskExclude(backdrop, source: uint8): uint8 =
|
proc maskExclude(backdrop, source: uint8): uint8 =
|
||||||
max(backdrop, source) - min(backdrop, source)
|
max(backdrop, source) - min(backdrop, source)
|
||||||
|
|
||||||
proc maskOverwrite(backdrop, source: uint8): uint8 =
|
proc maskOverwrite(backdrop, source: uint8): uint8 =
|
||||||
source
|
source
|
||||||
|
|
||||||
proc masker*(blendMode: BlendMode): Masker {.raises: [PixieError].} =
|
proc masker*(blendMode: BlendMode): Masker {.raises: [PixieError].} =
|
||||||
|
@ -512,7 +512,7 @@ when defined(amd64) and not defined(pixieNoSimd):
|
||||||
MaskerSimd* = proc(blackdrop, source: M128i): M128i {.raises: [].}
|
MaskerSimd* = proc(blackdrop, source: M128i): M128i {.raises: [].}
|
||||||
## Function signature returned by maskerSimd.
|
## Function signature returned by maskerSimd.
|
||||||
|
|
||||||
proc blendNormalSimd(backdrop, source: M128i): M128i =
|
proc blendNormalSimd(backdrop, source: M128i): M128i =
|
||||||
let
|
let
|
||||||
alphaMask = mm_set1_epi32(cast[int32](0xff000000))
|
alphaMask = mm_set1_epi32(cast[int32](0xff000000))
|
||||||
oddMask = mm_set1_epi16(cast[int16](0xff00))
|
oddMask = mm_set1_epi16(cast[int16](0xff00))
|
||||||
|
@ -541,7 +541,7 @@ when defined(amd64) and not defined(pixieNoSimd):
|
||||||
mm_or_si128(backdropEven, mm_slli_epi16(backdropOdd, 8))
|
mm_or_si128(backdropEven, mm_slli_epi16(backdropOdd, 8))
|
||||||
)
|
)
|
||||||
|
|
||||||
proc blendMaskSimd(backdrop, source: M128i): M128i =
|
proc blendMaskSimd(backdrop, source: M128i): M128i =
|
||||||
let
|
let
|
||||||
alphaMask = mm_set1_epi32(cast[int32](0xff000000))
|
alphaMask = mm_set1_epi32(cast[int32](0xff000000))
|
||||||
oddMask = mm_set1_epi16(cast[int16](0xff00))
|
oddMask = mm_set1_epi16(cast[int16](0xff00))
|
||||||
|
@ -562,7 +562,7 @@ when defined(amd64) and not defined(pixieNoSimd):
|
||||||
|
|
||||||
mm_or_si128(backdropEven, mm_slli_epi16(backdropOdd, 8))
|
mm_or_si128(backdropEven, mm_slli_epi16(backdropOdd, 8))
|
||||||
|
|
||||||
proc blendOverwriteSimd(backdrop, source: M128i): M128i =
|
proc blendOverwriteSimd(backdrop, source: M128i): M128i =
|
||||||
source
|
source
|
||||||
|
|
||||||
proc blenderSimd*(blendMode: BlendMode): BlenderSimd {.raises: [PixieError].} =
|
proc blenderSimd*(blendMode: BlendMode): BlenderSimd {.raises: [PixieError].} =
|
||||||
|
@ -578,7 +578,7 @@ when defined(amd64) and not defined(pixieNoSimd):
|
||||||
## Is there a blend function for a given blend mode with SIMD support?
|
## Is there a blend function for a given blend mode with SIMD support?
|
||||||
blendMode in {bmNormal, bmMask, bmOverwrite}
|
blendMode in {bmNormal, bmMask, bmOverwrite}
|
||||||
|
|
||||||
proc maskNormalSimd(backdrop, source: M128i): M128i =
|
proc maskNormalSimd(backdrop, source: M128i): M128i =
|
||||||
## Blending masks
|
## Blending masks
|
||||||
let
|
let
|
||||||
oddMask = mm_set1_epi16(cast[int16](0xff00))
|
oddMask = mm_set1_epi16(cast[int16](0xff00))
|
||||||
|
@ -615,7 +615,7 @@ when defined(amd64) and not defined(pixieNoSimd):
|
||||||
|
|
||||||
mm_or_si128(blendedEven, mm_slli_epi16(blendedOdd, 8))
|
mm_or_si128(blendedEven, mm_slli_epi16(blendedOdd, 8))
|
||||||
|
|
||||||
proc maskMaskSimd(backdrop, source: M128i): M128i =
|
proc maskMaskSimd(backdrop, source: M128i): M128i =
|
||||||
let
|
let
|
||||||
oddMask = mm_set1_epi16(cast[int16](0xff00))
|
oddMask = mm_set1_epi16(cast[int16](0xff00))
|
||||||
div255 = mm_set1_epi16(cast[int16](0x8081))
|
div255 = mm_set1_epi16(cast[int16](0x8081))
|
||||||
|
|
|
@ -495,7 +495,7 @@ proc getLineDash*(ctx: Context): seq[float32] {.inline, raises: [].} =
|
||||||
proc setLineDash*(ctx: Context, lineDash: seq[float32]) {.inline, raises: [].} =
|
proc setLineDash*(ctx: Context, lineDash: seq[float32]) {.inline, raises: [].} =
|
||||||
ctx.lineDash = lineDash
|
ctx.lineDash = lineDash
|
||||||
|
|
||||||
proc getTransform*(ctx: Context): Mat3 {.inline, raises: []} =
|
proc getTransform*(ctx: Context): Mat3 {.inline, raises: [].} =
|
||||||
## Retrieves the current transform matrix being applied to the context.
|
## Retrieves the current transform matrix being applied to the context.
|
||||||
ctx.mat
|
ctx.mat
|
||||||
|
|
||||||
|
|
|
@ -884,10 +884,10 @@ proc draw*(
|
||||||
|
|
||||||
proc drawTiled*(
|
proc drawTiled*(
|
||||||
dst, src: Image, mat: Mat3, blendMode = bmNormal
|
dst, src: Image, mat: Mat3, blendMode = bmNormal
|
||||||
) {.raises: [PixieError]} =
|
) {.raises: [PixieError].} =
|
||||||
dst.drawCorrect(src, mat, true, blendMode)
|
dst.drawCorrect(src, mat, true, blendMode)
|
||||||
|
|
||||||
proc resize*(srcImage: Image, width, height: int): Image {.raises: [PixieError]} =
|
proc resize*(srcImage: Image, width, height: int): Image {.raises: [PixieError].} =
|
||||||
## Resize an image to a given height and width.
|
## Resize an image to a given height and width.
|
||||||
if width == srcImage.width and height == srcImage.height:
|
if width == srcImage.width and height == srcImage.height:
|
||||||
result = srcImage.copy()
|
result = srcImage.copy()
|
||||||
|
@ -904,7 +904,7 @@ proc resize*(srcImage: Image, width, height: int): Image {.raises: [PixieError]}
|
||||||
|
|
||||||
proc shadow*(
|
proc shadow*(
|
||||||
image: Image, offset: Vec2, spread, blur: float32, color: SomeColor
|
image: Image, offset: Vec2, spread, blur: float32, color: SomeColor
|
||||||
): Image {.raises: [PixieError]} =
|
): Image {.raises: [PixieError].} =
|
||||||
## Create a shadow of the image with the offset, spread and blur.
|
## Create a shadow of the image with the offset, spread and blur.
|
||||||
let
|
let
|
||||||
mask = image.newMask()
|
mask = image.newMask()
|
||||||
|
@ -916,7 +916,7 @@ proc shadow*(
|
||||||
result.fill(color)
|
result.fill(color)
|
||||||
result.draw(shifted, blendMode = bmMask)
|
result.draw(shifted, blendMode = bmMask)
|
||||||
|
|
||||||
proc superImage*(image: Image, x, y, w, h: int): Image {.raises: [PixieError]} =
|
proc superImage*(image: Image, x, y, w, h: int): Image {.raises: [PixieError].} =
|
||||||
## Either cuts a sub image or returns a super image with padded transparency.
|
## Either cuts a sub image or returns a super image with padded transparency.
|
||||||
if x >= 0 and x + w <= image.width and y >= 0 and y + h <= image.height:
|
if x >= 0 and x + w <= image.width and y >= 0 and y + h <= image.height:
|
||||||
result = image.subImage(x, y, w, h)
|
result = image.subImage(x, y, w, h)
|
||||||
|
|
|
@ -1252,9 +1252,7 @@ proc computeCoverages(
|
||||||
for j in i ..< fillStart + fillLen:
|
for j in i ..< fillStart + fillLen:
|
||||||
coverages[j - startX] += sampleCoverage
|
coverages[j - startX] += sampleCoverage
|
||||||
|
|
||||||
proc clearUnsafe(
|
proc clearUnsafe(target: Image | Mask, startX, startY, toX, toY: int) =
|
||||||
target: Image | Mask, startX, startY, toX, toY: int
|
|
||||||
) =
|
|
||||||
## Clears data from [start, to).
|
## Clears data from [start, to).
|
||||||
if startX == target.width or startY == target.height:
|
if startX == target.width or startY == target.height:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue