Merge pull request #271 from guzba/master

use nicer bindy
This commit is contained in:
treeform 2021-08-31 16:29:47 -07:00 committed by GitHub
commit 569b3668b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 399 additions and 317 deletions

View file

@ -6,7 +6,7 @@ proc takeError*(): string =
result = lastError.msg result = lastError.msg
lastError = nil lastError = nil
proc checkError*(): bool = proc checkError*(): bool =
result = lastError != nil result = lastError != nil
type type
@ -38,32 +38,30 @@ proc drawImage3*(
ctx.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) ctx.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight)
exportConsts: exportConsts:
export defaultMiterLimit
defaultMiterLimit, autoLineHeight
autoLineHeight
exportEnums: exportEnums:
export FileFormat
FileFormat, BlendMode
BlendMode, PaintKind
PaintKind, WindingRule
WindingRule, LineCap
LineCap, LineJoin
LineJoin, HorizontalAlignment
HorizontalAlignment, VerticalAlignment
VerticalAlignment, TextCase
TextCase
exportProcs: exportProcs:
export checkError
bindings.checkError, takeError
bindings.takeError
exportObject Vector2: exportObject Vector2:
discard discard
exportObject Matrix3: exportObject Matrix3:
discard matrix3() constructor:
matrix3
exportObject Rect: exportObject Rect:
discard discard
@ -81,175 +79,220 @@ exportSeq seq[float32]:
discard discard
exportSeq seq[Span]: exportSeq seq[Span]:
export procs:
pixie.typeset, typeset(seq[Span], Vec2, HorizontalAlignment, VerticalAlignment, bool)
pixie.computeBounds computeBounds(seq[Span])
exportRefObject Image, ["width", "height"]: exportRefObject Image:
discard newImage(0, 0) fields:
export width
pixie.writeFile, height
pixie.wh, constructor:
pixie.copy, newImage(int, int)
pixie.getColor, procs:
pixie.setColor, writeFile(Image, string)
pixie.fill, wh(Image)
pixie.flipHorizontal, copy(Image)
pixie.flipVertical, getColor
pixie.subImage, setColor
pixie.minifyBy2, fill(Image, Color)
pixie.magnifyBy2, flipHorizontal
pixie.applyOpacity, flipVertical
pixie.invert, subImage
pixie.blur, minifyBy2(Image, int)
pixie.newMask, magnifyBy2
pixie.resize, applyOpacity(Image, float32)
pixie.shadow, invert(Image)
pixie.superImage, blur(Image, float32, Color)
pixie.draw, newMask(Image)
pixie.fillGradient, resize(Image, int, int)
pixie.fillText, shadow(Image, Vec2, float32, float32, Color)
pixie.strokeText, superImage
pixie.fillPath, draw(Image, Image, Mat3, BlendMode)
pixie.strokePath, draw(Image, Mask, Mat3, BlendMode)
pixie.newContext fillGradient
fillText(Image, Font, string, Mat3, Vec2, HorizontalAlignment, VerticalAlignment)
fillText(Image, Arrangement, Mat3)
strokeText(Image, Font, string, Mat3, float32, Vec2, HorizontalAlignment, VerticalAlignment, LineCap, LineJoin, float32, seq[float32])
strokeText(Image, Arrangement, Mat3, float32, LineCap, LineJoin, float32, seq[float32])
fillPath(Image, Path, Paint, Mat3, WindingRule)
strokePath(Image, Path, Paint, Mat3, float32, LineCap, LineJoin, float32, seq[float32])
newContext(Image)
exportRefObject Mask, ["width", "height"]: exportRefObject Mask:
discard newMask(0, 0) fields:
export width
pixie.writeFile, height
pixie.wh, constructor:
pixie.copy, newMask(int, int)
pixie.getValue, procs:
pixie.setValue, writeFile(Mask, string)
pixie.fill, wh(Mask)
pixie.minifyBy2, copy(Mask)
pixie.spread, getValue
pixie.ceil, setValue
pixie.newImage, fill(Mask, uint8)
pixie.applyOpacity, minifyBy2(Mask, int)
pixie.invert, spread
pixie.blur, ceil(Mask)
pixie.draw, newImage(Mask)
pixie.fillText, applyOpacity(Mask, float32)
pixie.strokeText, invert(Mask)
pixie.fillPath, blur(Mask, float32, uint8)
pixie.strokePath draw(Mask, Mask, Mat3, BlendMode)
draw(Mask, Image, Mat3, BlendMode)
fillText(Mask, Font, string, Mat3, Vec2, HorizontalAlignment, VerticalAlignment)
fillText(Mask, Arrangement, Mat3)
strokeText(Mask, Font, string, Mat3, float32, Vec2, HorizontalAlignment, VerticalAlignment, LineCap, LineJoin, float32, seq[float32])
strokeText(Mask, Arrangement, Mat3, float32, LineCap, LineJoin, float32, seq[float32])
fillPath(Mask, Path, Mat3, WindingRule)
strokePath(Mask, Path, Mat3, float32, LineCap, LineJoin, float32, seq[float32])
exportRefObject Paint, ["*"]: exportRefObject Paint:
discard newPaint(pkSolid) fields:
export kind
pixie.newPaint blendMode
opacity
color
image
imageMat
gradientHandlePositions
gradientStops
constructor:
newPaint(PaintKind)
procs:
newPaint(Paint)
exportRefObject Path, ["*"]: exportRefObject Path:
discard newPath() constructor:
export newPath
pixie.transform, procs:
pixie.addPath, transform(Path, Mat3)
pixie.closePath, addPath(Path, Path)
pixie.computeBounds, closePath(Path)
pixie.fillOverlaps, computeBounds(Path)
pixie.strokeOverlaps fillOverlaps
strokeOverlaps
moveTo(Path, float32, float32)
lineTo(Path, float32, float32)
bezierCurveTo(Path, float32, float32, float32, float32, float32, float32)
quadraticCurveTo(Path, float32, float32, float32, float32)
ellipticalArcTo(Path, float32, float32, float32, bool, bool, float32, float32)
arc(Path, float32, float32, float32, float32, float32, bool)
arcTo(Path, float32, float32, float32, float32, float32)
rect(Path, float32, float32, float32, float32)
roundedRect(Path, float32, float32, float32, float32, float32, float32, float32, float32, bool)
ellipse(Path, float32, float32, float32, float32)
circle(Path, float32, float32, float32)
polygon(Path, float32, float32, float32, int)
toggleBasicOnly() exportRefObject Typeface:
fields:
filePath
procs:
ascent
descent
lineGap
lineHeight
getGlyphPath
getAdvance
getKerningAdjustment
newFont
export exportRefObject Font:
pixie.moveTo, fields:
pixie.lineTo, typeface
pixie.bezierCurveTo, size
pixie.quadraticCurveTo, lineHeight
pixie.ellipticalArcTo, paints
pixie.arc, textCase
pixie.arcTo, underline
pixie.rect, strikethrough
pixie.roundedRect, noKerningAdjustments
pixie.ellipse, procs:
pixie.circle, scale(Font)
pixie.polygon defaultLineHeight
typeset(Font, string, Vec2, HorizontalAlignment, VerticalAlignment, bool)
computeBounds(Font, string)
exportRefObject Typeface, ["*"]: exportRefObject Span:
discard fields:
export text
pixie.ascent, font
pixie.descent, constructor:
pixie.lineGap, newSpan
pixie.lineHeight,
pixie.getGlyphPath,
pixie.getAdvance,
pixie.getKerningAdjustment,
pixie.newFont
exportRefObject Font, ["*"]: exportRefObject Arrangement:
discard procs:
export computeBounds(Arrangement)
pixie.scale,
pixie.defaultLineHeight,
pixie.typeset,
pixie.computeBounds
exportRefObject Span, ["*"]: exportRefObject Context:
discard newSpan("", Font()) fields:
image
exportRefObject Arrangement, []: fillStyle
discard strokeStyle
export globalAlpha
pixie.computeBounds lineWidth
miterLimit
exportRefObject Context, ["*"]: lineCap
discard newContext(0, 0) lineJoin
export font
pixie.save, fontSize
pixie.saveLayer, textAlign
pixie.restore, constructor:
pixie.beginPath, newContext(int, int)
pixie.closePath, procs:
pixie.fill, save
pixie.clip, saveLayer
pixie.stroke, restore
pixie.measureText, beginPath
pixie.getTransform, closePath(Context)
pixie.setTransform, fill(Context, WindingRule)
pixie.transform, fill(Context, Path, WindingRule)
pixie.resetTransform, clip(Context, WindingRule)
bindings.drawImage1, clip(Context, Path, WindingRule)
bindings.drawImage2, stroke(Context)
bindings.drawImage3 stroke(Context, Path)
measureText
toggleBasicOnly() getTransform
setTransform
export transform(Context, Mat3)
pixie.moveTo, resetTransform
pixie.lineTo, drawImage1
pixie.bezierCurveTo, drawImage2
pixie.quadraticCurveTo, drawImage3
pixie.ellipticalArcTo, moveTo(Context, float32, float32)
pixie.arc, lineTo(Context, float32, float32)
pixie.arcTo, bezierCurveTo(Context, float32, float32, float32, float32, float32, float32)
pixie.rect, quadraticCurveTo(Context, float32, float32, float32, float32)
pixie.roundedRect, arc(Context, float32, float32, float32, float32, float32, bool)
pixie.ellipse, arcTo(Context, float32, float32, float32, float32, float32)
pixie.circle, rect(Context, float32, float32, float32, float32)
pixie.polygon, roundedRect(Context, float32, float32, float32, float32, float32, float32, float32, float32)
pixie.clearRect, ellipse(Context, float32, float32, float32, float32)
pixie.fillRect, circle(Context, float32, float32, float32)
pixie.strokeRect, polygon(Context, float32, float32, float32, int)
pixie.fillText, clearRect(Context, float32, float32, float32, float32)
pixie.strokeText, fillRect(Context, float32, float32, float32, float32)
pixie.translate, strokeRect(Context, float32, float32, float32, float32)
pixie.scale, fillText(Context, string, float32, float32)
pixie.rotate, strokeText(Context, string, float32, float32)
pixie.isPointInPath, translate(Context, float32, float32)
pixie.isPointInStroke scale(Context, float32, float32)
rotate(Context, float32)
isPointInPath(Context, float32, float32, WindingRule)
isPointInPath(Context, Path, float32, float32, WindingRule)
isPointInStroke(Context, float32, float32)
isPointInStroke(Context, Path, float32, float32)
exportProcs: exportProcs:
export readImage
pixie.readImage, readmask
pixie.readmask, readTypeface
pixie.readTypeface, readFont
pixie.readFont, parsePath
pixie.parsePath, miterLimitToAngle
pixie.miterLimitToAngle, angleToMiterLimit
pixie.angleToMiterLimit
writeFiles("bindings/generated", "pixie") writeFiles("bindings/generated", "pixie")

View file

@ -172,15 +172,15 @@ proc pixie_image_super_image*(image: Image, x: int, y: int, w: int, h: int): Ima
except PixieError as e: except PixieError as e:
lastError = e lastError = e
proc pixie_image_mask_draw*(image: Image, mask: Mask, transform: Mat3, blend_mode: BlendMode) {.raises: [], cdecl, exportc, dynlib.} = proc pixie_image_draw*(a: Image, b: Image, transform: Mat3, blend_mode: BlendMode) {.raises: [], cdecl, exportc, dynlib.} =
try: try:
draw(image, mask, transform, blend_mode) draw(a, b, transform, blend_mode)
except PixieError as e: except PixieError as e:
lastError = e lastError = e
proc pixie_image_image_draw*(a: Image, b: Image, transform: Mat3, blend_mode: BlendMode) {.raises: [], cdecl, exportc, dynlib.} = proc pixie_image_mask_draw*(image: Image, mask: Mask, transform: Mat3, blend_mode: BlendMode) {.raises: [], cdecl, exportc, dynlib.} =
try: try:
draw(a, b, transform, blend_mode) draw(image, mask, transform, blend_mode)
except PixieError as e: except PixieError as e:
lastError = e lastError = e
@ -190,15 +190,21 @@ proc pixie_image_fill_gradient*(image: Image, paint: Paint) {.raises: [], cdecl,
except PixieError as e: except PixieError as e:
lastError = e lastError = e
proc pixie_image_fill_text*(target: Image, font: Font, text: cstring, transform: Mat3, bounds: Vec2, h_align: HorizontalAlignment, v_align: VerticalAlignment) {.raises: [], cdecl, exportc, dynlib.} =
try:
fillText(target, font, text.`$`, transform, bounds, h_align, v_align)
except PixieError as e:
lastError = e
proc pixie_image_arrangement_fill_text*(target: Image, arrangement: Arrangement, transform: Mat3) {.raises: [], cdecl, exportc, dynlib.} = proc pixie_image_arrangement_fill_text*(target: Image, arrangement: Arrangement, transform: Mat3) {.raises: [], cdecl, exportc, dynlib.} =
try: try:
fillText(target, arrangement, transform) fillText(target, arrangement, transform)
except PixieError as e: except PixieError as e:
lastError = e lastError = e
proc pixie_image_font_fill_text*(target: Image, font: Font, text: cstring, transform: Mat3, bounds: Vec2, h_align: HorizontalAlignment, v_align: VerticalAlignment) {.raises: [], cdecl, exportc, dynlib.} = proc pixie_image_stroke_text*(target: Image, font: Font, text: cstring, transform: Mat3, stroke_width: float32, bounds: Vec2, h_align: HorizontalAlignment, v_align: VerticalAlignment, line_cap: LineCap, line_join: LineJoin, miter_limit: float32, dashes: SeqFloat32) {.raises: [], cdecl, exportc, dynlib.} =
try: try:
fillText(target, font, text.`$`, transform, bounds, h_align, v_align) strokeText(target, font, text.`$`, transform, stroke_width, bounds, h_align, v_align, line_cap, line_join, miter_limit, dashes.s)
except PixieError as e: except PixieError as e:
lastError = e lastError = e
@ -208,12 +214,6 @@ proc pixie_image_arrangement_stroke_text*(target: Image, arrangement: Arrangemen
except PixieError as e: except PixieError as e:
lastError = e lastError = e
proc pixie_image_font_stroke_text*(target: Image, font: Font, text: cstring, transform: Mat3, stroke_width: float32, bounds: Vec2, h_align: HorizontalAlignment, v_align: VerticalAlignment, line_cap: LineCap, line_join: LineJoin, miter_limit: float32, dashes: SeqFloat32) {.raises: [], cdecl, exportc, dynlib.} =
try:
strokeText(target, font, text.`$`, transform, stroke_width, bounds, h_align, v_align, line_cap, line_join, miter_limit, dashes.s)
except PixieError as e:
lastError = e
proc pixie_image_fill_path*(image: Image, path: Path, paint: Paint, transform: Mat3, winding_rule: WindingRule) {.raises: [], cdecl, exportc, dynlib.} = proc pixie_image_fill_path*(image: Image, path: Path, paint: Paint, transform: Mat3, winding_rule: WindingRule) {.raises: [], cdecl, exportc, dynlib.} =
try: try:
fillPath(image, path, paint, transform, winding_rule) fillPath(image, path, paint, transform, winding_rule)
@ -307,7 +307,7 @@ proc pixie_mask_blur*(mask: Mask, radius: float32, out_of_bounds: uint8) {.raise
except PixieError as e: except PixieError as e:
lastError = e lastError = e
proc pixie_mask_mask_draw*(a: Mask, b: Mask, transform: Mat3, blend_mode: BlendMode) {.raises: [], cdecl, exportc, dynlib.} = proc pixie_mask_draw*(a: Mask, b: Mask, transform: Mat3, blend_mode: BlendMode) {.raises: [], cdecl, exportc, dynlib.} =
try: try:
draw(a, b, transform, blend_mode) draw(a, b, transform, blend_mode)
except PixieError as e: except PixieError as e:
@ -319,15 +319,21 @@ proc pixie_mask_image_draw*(mask: Mask, image: Image, transform: Mat3, blend_mod
except PixieError as e: except PixieError as e:
lastError = e lastError = e
proc pixie_mask_fill_text*(target: Mask, font: Font, text: cstring, transform: Mat3, bounds: Vec2, h_align: HorizontalAlignment, v_align: VerticalAlignment) {.raises: [], cdecl, exportc, dynlib.} =
try:
fillText(target, font, text.`$`, transform, bounds, h_align, v_align)
except PixieError as e:
lastError = e
proc pixie_mask_arrangement_fill_text*(target: Mask, arrangement: Arrangement, transform: Mat3) {.raises: [], cdecl, exportc, dynlib.} = proc pixie_mask_arrangement_fill_text*(target: Mask, arrangement: Arrangement, transform: Mat3) {.raises: [], cdecl, exportc, dynlib.} =
try: try:
fillText(target, arrangement, transform) fillText(target, arrangement, transform)
except PixieError as e: except PixieError as e:
lastError = e lastError = e
proc pixie_mask_font_fill_text*(target: Mask, font: Font, text: cstring, transform: Mat3, bounds: Vec2, h_align: HorizontalAlignment, v_align: VerticalAlignment) {.raises: [], cdecl, exportc, dynlib.} = proc pixie_mask_stroke_text*(target: Mask, font: Font, text: cstring, transform: Mat3, stroke_width: float32, bounds: Vec2, h_align: HorizontalAlignment, v_align: VerticalAlignment, line_cap: LineCap, line_join: LineJoin, miter_limit: float32, dashes: SeqFloat32) {.raises: [], cdecl, exportc, dynlib.} =
try: try:
fillText(target, font, text.`$`, transform, bounds, h_align, v_align) strokeText(target, font, text.`$`, transform, stroke_width, bounds, h_align, v_align, line_cap, line_join, miter_limit, dashes.s)
except PixieError as e: except PixieError as e:
lastError = e lastError = e
@ -337,12 +343,6 @@ proc pixie_mask_arrangement_stroke_text*(target: Mask, arrangement: Arrangement,
except PixieError as e: except PixieError as e:
lastError = e lastError = e
proc pixie_mask_font_stroke_text*(target: Mask, font: Font, text: cstring, transform: Mat3, stroke_width: float32, bounds: Vec2, h_align: HorizontalAlignment, v_align: VerticalAlignment, line_cap: LineCap, line_join: LineJoin, miter_limit: float32, dashes: SeqFloat32) {.raises: [], cdecl, exportc, dynlib.} =
try:
strokeText(target, font, text.`$`, transform, stroke_width, bounds, h_align, v_align, line_cap, line_join, miter_limit, dashes.s)
except PixieError as e:
lastError = e
proc pixie_mask_fill_path*(mask: Mask, path: Path, transform: Mat3, winding_rule: WindingRule, blend_mode: BlendMode) {.raises: [], cdecl, exportc, dynlib.} = proc pixie_mask_fill_path*(mask: Mask, path: Path, transform: Mat3, winding_rule: WindingRule, blend_mode: BlendMode) {.raises: [], cdecl, exportc, dynlib.} =
try: try:
fillPath(mask, path, transform, winding_rule, blend_mode) fillPath(mask, path, transform, winding_rule, blend_mode)
@ -745,15 +745,21 @@ proc pixie_context_begin_path*(ctx: Context) {.raises: [], cdecl, exportc, dynli
proc pixie_context_close_path*(ctx: Context) {.raises: [], cdecl, exportc, dynlib.} = proc pixie_context_close_path*(ctx: Context) {.raises: [], cdecl, exportc, dynlib.} =
closePath(ctx) closePath(ctx)
proc pixie_context_fill*(ctx: Context, winding_rule: WindingRule) {.raises: [], cdecl, exportc, dynlib.} =
try:
fill(ctx, winding_rule)
except PixieError as e:
lastError = e
proc pixie_context_path_fill*(ctx: Context, path: Path, winding_rule: WindingRule) {.raises: [], cdecl, exportc, dynlib.} = proc pixie_context_path_fill*(ctx: Context, path: Path, winding_rule: WindingRule) {.raises: [], cdecl, exportc, dynlib.} =
try: try:
fill(ctx, path, winding_rule) fill(ctx, path, winding_rule)
except PixieError as e: except PixieError as e:
lastError = e lastError = e
proc pixie_context_winding_rule_fill*(ctx: Context, winding_rule: WindingRule) {.raises: [], cdecl, exportc, dynlib.} = proc pixie_context_clip*(ctx: Context, winding_rule: WindingRule) {.raises: [], cdecl, exportc, dynlib.} =
try: try:
fill(ctx, winding_rule) clip(ctx, winding_rule)
except PixieError as e: except PixieError as e:
lastError = e lastError = e
@ -763,9 +769,9 @@ proc pixie_context_path_clip*(ctx: Context, path: Path, winding_rule: WindingRul
except PixieError as e: except PixieError as e:
lastError = e lastError = e
proc pixie_context_winding_rule_clip*(ctx: Context, winding_rule: WindingRule) {.raises: [], cdecl, exportc, dynlib.} = proc pixie_context_stroke*(ctx: Context) {.raises: [], cdecl, exportc, dynlib.} =
try: try:
clip(ctx, winding_rule) stroke(ctx)
except PixieError as e: except PixieError as e:
lastError = e lastError = e
@ -775,12 +781,6 @@ proc pixie_context_path_stroke*(ctx: Context, path: Path) {.raises: [], cdecl, e
except PixieError as e: except PixieError as e:
lastError = e lastError = e
proc pixie_context_stroke*(ctx: Context) {.raises: [], cdecl, exportc, dynlib.} =
try:
stroke(ctx)
except PixieError as e:
lastError = e
proc pixie_context_measure_text*(ctx: Context, text: cstring): TextMetrics {.raises: [], cdecl, exportc, dynlib.} = proc pixie_context_measure_text*(ctx: Context, text: cstring): TextMetrics {.raises: [], cdecl, exportc, dynlib.} =
try: try:
result = measureText(ctx, text.`$`) result = measureText(ctx, text.`$`)
@ -901,12 +901,24 @@ proc pixie_context_is_point_in_path*(ctx: Context, x: float32, y: float32, windi
except PixieError as e: except PixieError as e:
lastError = e lastError = e
proc pixie_context_path_is_point_in_path*(ctx: Context, path: Path, x: float32, y: float32, winding_rule: WindingRule): bool {.raises: [], cdecl, exportc, dynlib.} =
try:
result = isPointInPath(ctx, path, x, y, winding_rule)
except PixieError as e:
lastError = e
proc pixie_context_is_point_in_stroke*(ctx: Context, x: float32, y: float32): bool {.raises: [], cdecl, exportc, dynlib.} = proc pixie_context_is_point_in_stroke*(ctx: Context, x: float32, y: float32): bool {.raises: [], cdecl, exportc, dynlib.} =
try: try:
result = isPointInStroke(ctx, x, y) result = isPointInStroke(ctx, x, y)
except PixieError as e: except PixieError as e:
lastError = e lastError = e
proc pixie_context_path_is_point_in_stroke*(ctx: Context, path: Path, x: float32, y: float32): bool {.raises: [], cdecl, exportc, dynlib.} =
try:
result = isPointInStroke(ctx, path, x, y)
except PixieError as e:
lastError = e
proc pixie_read_image*(file_path: cstring): Image {.raises: [], cdecl, exportc, dynlib.} = proc pixie_read_image*(file_path: cstring): Image {.raises: [], cdecl, exportc, dynlib.} =
try: try:
result = readImage(file_path.`$`) result = readImage(file_path.`$`)

View file

@ -401,7 +401,7 @@ proc invert*(target: Image) {.inline.} =
proc pixie_image_blur(image: Image, radius: float32, out_of_bounds: Color) {.importc: "pixie_image_blur", cdecl.} proc pixie_image_blur(image: Image, radius: float32, out_of_bounds: Color) {.importc: "pixie_image_blur", cdecl.}
proc blur*(image: Image, radius: float32, outOfBounds: Color) {.inline.} = proc blur*(image: Image, radius: float32, outOfBounds: Color = Color()) {.inline.} =
pixie_image_blur(image, radius, outOfBounds) pixie_image_blur(image, radius, outOfBounds)
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
@ -434,6 +434,13 @@ proc superImage*(image: Image, x: int, y: int, w: int, h: int): Image {.inline.}
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
proc pixie_image_draw(a: Image, b: Image, transform: Mat3, blend_mode: BlendMode) {.importc: "pixie_image_draw", cdecl.}
proc draw*(a: Image, b: Image, transform: Mat3 = mat3(), blendMode: BlendMode = bmNormal) {.inline.} =
pixie_image_draw(a, b, transform, blendMode)
if checkError():
raise newException(PixieError, $takeError())
proc pixie_image_mask_draw(image: Image, mask: Mask, transform: Mat3, blend_mode: BlendMode) {.importc: "pixie_image_mask_draw", cdecl.} proc pixie_image_mask_draw(image: Image, mask: Mask, transform: Mat3, blend_mode: BlendMode) {.importc: "pixie_image_mask_draw", cdecl.}
proc draw*(image: Image, mask: Mask, transform: Mat3 = mat3(), blendMode: BlendMode = bmMask) {.inline.} = proc draw*(image: Image, mask: Mask, transform: Mat3 = mat3(), blendMode: BlendMode = bmMask) {.inline.} =
@ -441,13 +448,6 @@ proc draw*(image: Image, mask: Mask, transform: Mat3 = mat3(), blendMode: BlendM
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
proc pixie_image_image_draw(a: Image, b: Image, transform: Mat3, blend_mode: BlendMode) {.importc: "pixie_image_image_draw", cdecl.}
proc draw*(a: Image, b: Image, transform: Mat3 = mat3(), blendMode: BlendMode = bmNormal) {.inline.} =
pixie_image_image_draw(a, b, transform, blendMode)
if checkError():
raise newException(PixieError, $takeError())
proc pixie_image_fill_gradient(image: Image, paint: Paint) {.importc: "pixie_image_fill_gradient", cdecl.} proc pixie_image_fill_gradient(image: Image, paint: Paint) {.importc: "pixie_image_fill_gradient", cdecl.}
proc fillGradient*(image: Image, paint: Paint) {.inline.} = proc fillGradient*(image: Image, paint: Paint) {.inline.} =
@ -455,6 +455,13 @@ proc fillGradient*(image: Image, paint: Paint) {.inline.} =
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
proc pixie_image_fill_text(target: Image, font: Font, text: cstring, transform: Mat3, bounds: Vec2, h_align: HorizontalAlignment, v_align: VerticalAlignment) {.importc: "pixie_image_fill_text", cdecl.}
proc fillText*(target: Image, font: Font, text: string, transform: Mat3 = mat3(), bounds: Vec2 = vec2(0, 0), hAlign: HorizontalAlignment = haLeft, vAlign: VerticalAlignment = vaTop) {.inline.} =
pixie_image_fill_text(target, font, text.cstring, transform, bounds, hAlign, vAlign)
if checkError():
raise newException(PixieError, $takeError())
proc pixie_image_arrangement_fill_text(target: Image, arrangement: Arrangement, transform: Mat3) {.importc: "pixie_image_arrangement_fill_text", cdecl.} proc pixie_image_arrangement_fill_text(target: Image, arrangement: Arrangement, transform: Mat3) {.importc: "pixie_image_arrangement_fill_text", cdecl.}
proc fillText*(target: Image, arrangement: Arrangement, transform: Mat3 = mat3()) {.inline.} = proc fillText*(target: Image, arrangement: Arrangement, transform: Mat3 = mat3()) {.inline.} =
@ -462,10 +469,10 @@ proc fillText*(target: Image, arrangement: Arrangement, transform: Mat3 = mat3()
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
proc pixie_image_font_fill_text(target: Image, font: Font, text: cstring, transform: Mat3, bounds: Vec2, h_align: HorizontalAlignment, v_align: VerticalAlignment) {.importc: "pixie_image_font_fill_text", cdecl.} proc pixie_image_stroke_text(target: Image, font: Font, text: cstring, transform: Mat3, stroke_width: float32, bounds: Vec2, h_align: HorizontalAlignment, v_align: VerticalAlignment, line_cap: LineCap, line_join: LineJoin, miter_limit: float32, dashes: SeqFloat32) {.importc: "pixie_image_stroke_text", cdecl.}
proc fillText*(target: Image, font: Font, text: string, transform: Mat3 = mat3(), bounds: Vec2 = vec2(0, 0), hAlign: HorizontalAlignment = haLeft, vAlign: VerticalAlignment = vaTop) {.inline.} = proc strokeText*(target: Image, font: Font, text: string, transform: Mat3 = mat3(), strokeWidth: float32 = 1.0, bounds: Vec2 = vec2(0, 0), hAlign: HorizontalAlignment = haLeft, vAlign: VerticalAlignment = vaTop, lineCap: LineCap = lcButt, lineJoin: LineJoin = ljMiter, miterLimit: float32 = defaultMiterLimit, dashes: SeqFloat32) {.inline.} =
pixie_image_font_fill_text(target, font, text.cstring, transform, bounds, hAlign, vAlign) pixie_image_stroke_text(target, font, text.cstring, transform, strokeWidth, bounds, hAlign, vAlign, lineCap, lineJoin, miterLimit, dashes)
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
@ -476,13 +483,6 @@ proc strokeText*(target: Image, arrangement: Arrangement, transform: Mat3 = mat3
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
proc pixie_image_font_stroke_text(target: Image, font: Font, text: cstring, transform: Mat3, stroke_width: float32, bounds: Vec2, h_align: HorizontalAlignment, v_align: VerticalAlignment, line_cap: LineCap, line_join: LineJoin, miter_limit: float32, dashes: SeqFloat32) {.importc: "pixie_image_font_stroke_text", cdecl.}
proc strokeText*(target: Image, font: Font, text: string, transform: Mat3 = mat3(), strokeWidth: float32 = 1.0, bounds: Vec2 = vec2(0, 0), hAlign: HorizontalAlignment = haLeft, vAlign: VerticalAlignment = vaTop, lineCap: LineCap = lcButt, lineJoin: LineJoin = ljMiter, miterLimit: float32 = defaultMiterLimit, dashes: SeqFloat32) {.inline.} =
pixie_image_font_stroke_text(target, font, text.cstring, transform, strokeWidth, bounds, hAlign, vAlign, lineCap, lineJoin, miterLimit, dashes)
if checkError():
raise newException(PixieError, $takeError())
proc pixie_image_fill_path(image: Image, path: Path, paint: Paint, transform: Mat3, winding_rule: WindingRule) {.importc: "pixie_image_fill_path", cdecl.} proc pixie_image_fill_path(image: Image, path: Path, paint: Paint, transform: Mat3, winding_rule: WindingRule) {.importc: "pixie_image_fill_path", cdecl.}
proc fillPath*(image: Image, path: Path, paint: Paint, transform: Mat3 = mat3(), windingRule: WindingRule = wrNonZero) {.inline.} = proc fillPath*(image: Image, path: Path, paint: Paint, transform: Mat3 = mat3(), windingRule: WindingRule = wrNonZero) {.inline.} =
@ -606,10 +606,10 @@ proc blur*(mask: Mask, radius: float32, outOfBounds: uint8 = 0) {.inline.} =
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
proc pixie_mask_mask_draw(a: Mask, b: Mask, transform: Mat3, blend_mode: BlendMode) {.importc: "pixie_mask_mask_draw", cdecl.} proc pixie_mask_draw(a: Mask, b: Mask, transform: Mat3, blend_mode: BlendMode) {.importc: "pixie_mask_draw", cdecl.}
proc draw*(a: Mask, b: Mask, transform: Mat3 = mat3(), blendMode: BlendMode = bmMask) {.inline.} = proc draw*(a: Mask, b: Mask, transform: Mat3 = mat3(), blendMode: BlendMode = bmMask) {.inline.} =
pixie_mask_mask_draw(a, b, transform, blendMode) pixie_mask_draw(a, b, transform, blendMode)
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
@ -620,6 +620,13 @@ proc draw*(mask: Mask, image: Image, transform: Mat3 = mat3(), blendMode: BlendM
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
proc pixie_mask_fill_text(target: Mask, font: Font, text: cstring, transform: Mat3, bounds: Vec2, h_align: HorizontalAlignment, v_align: VerticalAlignment) {.importc: "pixie_mask_fill_text", cdecl.}
proc fillText*(target: Mask, font: Font, text: string, transform: Mat3 = mat3(), bounds: Vec2 = vec2(0, 0), hAlign: HorizontalAlignment = haLeft, vAlign: VerticalAlignment = vaTop) {.inline.} =
pixie_mask_fill_text(target, font, text.cstring, transform, bounds, hAlign, vAlign)
if checkError():
raise newException(PixieError, $takeError())
proc pixie_mask_arrangement_fill_text(target: Mask, arrangement: Arrangement, transform: Mat3) {.importc: "pixie_mask_arrangement_fill_text", cdecl.} proc pixie_mask_arrangement_fill_text(target: Mask, arrangement: Arrangement, transform: Mat3) {.importc: "pixie_mask_arrangement_fill_text", cdecl.}
proc fillText*(target: Mask, arrangement: Arrangement, transform: Mat3 = mat3()) {.inline.} = proc fillText*(target: Mask, arrangement: Arrangement, transform: Mat3 = mat3()) {.inline.} =
@ -627,10 +634,10 @@ proc fillText*(target: Mask, arrangement: Arrangement, transform: Mat3 = mat3())
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
proc pixie_mask_font_fill_text(target: Mask, font: Font, text: cstring, transform: Mat3, bounds: Vec2, h_align: HorizontalAlignment, v_align: VerticalAlignment) {.importc: "pixie_mask_font_fill_text", cdecl.} proc pixie_mask_stroke_text(target: Mask, font: Font, text: cstring, transform: Mat3, stroke_width: float32, bounds: Vec2, h_align: HorizontalAlignment, v_align: VerticalAlignment, line_cap: LineCap, line_join: LineJoin, miter_limit: float32, dashes: SeqFloat32) {.importc: "pixie_mask_stroke_text", cdecl.}
proc fillText*(target: Mask, font: Font, text: string, transform: Mat3 = mat3(), bounds: Vec2 = vec2(0, 0), hAlign: HorizontalAlignment = haLeft, vAlign: VerticalAlignment = vaTop) {.inline.} = proc strokeText*(target: Mask, font: Font, text: string, transform: Mat3 = mat3(), strokeWidth: float32 = 1.0, bounds: Vec2 = vec2(0, 0), hAlign: HorizontalAlignment = haLeft, vAlign: VerticalAlignment = vaTop, lineCap: LineCap = lcButt, lineJoin: LineJoin = ljMiter, miterLimit: float32 = defaultMiterLimit, dashes: SeqFloat32) {.inline.} =
pixie_mask_font_fill_text(target, font, text.cstring, transform, bounds, hAlign, vAlign) pixie_mask_stroke_text(target, font, text.cstring, transform, strokeWidth, bounds, hAlign, vAlign, lineCap, lineJoin, miterLimit, dashes)
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
@ -641,13 +648,6 @@ proc strokeText*(target: Mask, arrangement: Arrangement, transform: Mat3 = mat3(
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
proc pixie_mask_font_stroke_text(target: Mask, font: Font, text: cstring, transform: Mat3, stroke_width: float32, bounds: Vec2, h_align: HorizontalAlignment, v_align: VerticalAlignment, line_cap: LineCap, line_join: LineJoin, miter_limit: float32, dashes: SeqFloat32) {.importc: "pixie_mask_font_stroke_text", cdecl.}
proc strokeText*(target: Mask, font: Font, text: string, transform: Mat3 = mat3(), strokeWidth: float32 = 1.0, bounds: Vec2 = vec2(0, 0), hAlign: HorizontalAlignment = haLeft, vAlign: VerticalAlignment = vaTop, lineCap: LineCap = lcButt, lineJoin: LineJoin = ljMiter, miterLimit: float32 = defaultMiterLimit, dashes: SeqFloat32) {.inline.} =
pixie_mask_font_stroke_text(target, font, text.cstring, transform, strokeWidth, bounds, hAlign, vAlign, lineCap, lineJoin, miterLimit, dashes)
if checkError():
raise newException(PixieError, $takeError())
proc pixie_mask_fill_path(mask: Mask, path: Path, transform: Mat3, winding_rule: WindingRule, blend_mode: BlendMode) {.importc: "pixie_mask_fill_path", cdecl.} proc pixie_mask_fill_path(mask: Mask, path: Path, transform: Mat3, winding_rule: WindingRule, blend_mode: BlendMode) {.importc: "pixie_mask_fill_path", cdecl.}
proc fillPath*(mask: Mask, path: Path, transform: Mat3 = mat3(), windingRule: WindingRule = wrNonZero, blendMode: BlendMode = bmNormal) {.inline.} = proc fillPath*(mask: Mask, path: Path, transform: Mat3 = mat3(), windingRule: WindingRule = wrNonZero, blendMode: BlendMode = bmNormal) {.inline.} =
@ -1265,6 +1265,13 @@ proc pixie_context_close_path(ctx: Context) {.importc: "pixie_context_close_path
proc closePath*(ctx: Context) {.inline.} = proc closePath*(ctx: Context) {.inline.} =
pixie_context_close_path(ctx) pixie_context_close_path(ctx)
proc pixie_context_fill(ctx: Context, winding_rule: WindingRule) {.importc: "pixie_context_fill", cdecl.}
proc fill*(ctx: Context, windingRule: WindingRule = wrNonZero) {.inline.} =
pixie_context_fill(ctx, windingRule)
if checkError():
raise newException(PixieError, $takeError())
proc pixie_context_path_fill(ctx: Context, path: Path, winding_rule: WindingRule) {.importc: "pixie_context_path_fill", cdecl.} proc pixie_context_path_fill(ctx: Context, path: Path, winding_rule: WindingRule) {.importc: "pixie_context_path_fill", cdecl.}
proc fill*(ctx: Context, path: Path, windingRule: WindingRule = wrNonZero) {.inline.} = proc fill*(ctx: Context, path: Path, windingRule: WindingRule = wrNonZero) {.inline.} =
@ -1272,10 +1279,10 @@ proc fill*(ctx: Context, path: Path, windingRule: WindingRule = wrNonZero) {.inl
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
proc pixie_context_winding_rule_fill(ctx: Context, winding_rule: WindingRule) {.importc: "pixie_context_winding_rule_fill", cdecl.} proc pixie_context_clip(ctx: Context, winding_rule: WindingRule) {.importc: "pixie_context_clip", cdecl.}
proc fill*(ctx: Context, windingRule: WindingRule = wrNonZero) {.inline.} = proc clip*(ctx: Context, windingRule: WindingRule = wrNonZero) {.inline.} =
pixie_context_winding_rule_fill(ctx, windingRule) pixie_context_clip(ctx, windingRule)
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
@ -1286,10 +1293,10 @@ proc clip*(ctx: Context, path: Path, windingRule: WindingRule = wrNonZero) {.inl
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
proc pixie_context_winding_rule_clip(ctx: Context, winding_rule: WindingRule) {.importc: "pixie_context_winding_rule_clip", cdecl.} proc pixie_context_stroke(ctx: Context) {.importc: "pixie_context_stroke", cdecl.}
proc clip*(ctx: Context, windingRule: WindingRule = wrNonZero) {.inline.} = proc stroke*(ctx: Context) {.inline.} =
pixie_context_winding_rule_clip(ctx, windingRule) pixie_context_stroke(ctx)
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
@ -1300,13 +1307,6 @@ proc stroke*(ctx: Context, path: Path) {.inline.} =
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
proc pixie_context_stroke(ctx: Context) {.importc: "pixie_context_stroke", cdecl.}
proc stroke*(ctx: Context) {.inline.} =
pixie_context_stroke(ctx)
if checkError():
raise newException(PixieError, $takeError())
proc pixie_context_measure_text(ctx: Context, text: cstring): TextMetrics {.importc: "pixie_context_measure_text", cdecl.} proc pixie_context_measure_text(ctx: Context, text: cstring): TextMetrics {.importc: "pixie_context_measure_text", cdecl.}
proc measureText*(ctx: Context, text: string): TextMetrics {.inline.} = proc measureText*(ctx: Context, text: string): TextMetrics {.inline.} =
@ -1471,6 +1471,13 @@ proc isPointInPath*(ctx: Context, x: float32, y: float32, windingRule: WindingRu
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
proc pixie_context_path_is_point_in_path(ctx: Context, path: Path, x: float32, y: float32, winding_rule: WindingRule): bool {.importc: "pixie_context_path_is_point_in_path", cdecl.}
proc isPointInPath*(ctx: Context, path: Path, x: float32, y: float32, windingRule: WindingRule = wrNonZero): bool {.inline.} =
result = pixie_context_path_is_point_in_path(ctx, path, x, y, windingRule)
if checkError():
raise newException(PixieError, $takeError())
proc pixie_context_is_point_in_stroke(ctx: Context, x: float32, y: float32): bool {.importc: "pixie_context_is_point_in_stroke", cdecl.} proc pixie_context_is_point_in_stroke(ctx: Context, x: float32, y: float32): bool {.importc: "pixie_context_is_point_in_stroke", cdecl.}
proc isPointInStroke*(ctx: Context, x: float32, y: float32): bool {.inline.} = proc isPointInStroke*(ctx: Context, x: float32, y: float32): bool {.inline.} =
@ -1478,6 +1485,13 @@ proc isPointInStroke*(ctx: Context, x: float32, y: float32): bool {.inline.} =
if checkError(): if checkError():
raise newException(PixieError, $takeError()) raise newException(PixieError, $takeError())
proc pixie_context_path_is_point_in_stroke(ctx: Context, path: Path, x: float32, y: float32): bool {.importc: "pixie_context_path_is_point_in_stroke", cdecl.}
proc isPointInStroke*(ctx: Context, path: Path, x: float32, y: float32): bool {.inline.} =
result = pixie_context_path_is_point_in_stroke(ctx, path, x, y)
if checkError():
raise newException(PixieError, $takeError())
proc pixie_read_image(file_path: cstring): Image {.importc: "pixie_read_image", cdecl.} proc pixie_read_image(file_path: cstring): Image {.importc: "pixie_read_image", cdecl.}
proc readImage*(filePath: string): Image {.inline.} = proc readImage*(filePath: string): Image {.inline.} =
@ -1522,4 +1536,3 @@ proc pixie_angle_to_miter_limit(angle: float32): float32 {.importc: "pixie_angle
proc angleToMiterLimit*(angle: float32): float32 {.inline.} = proc angleToMiterLimit*(angle: float32): float32 {.inline.} =
result = pixie_angle_to_miter_limit(angle) result = pixie_angle_to_miter_limit(angle)

View file

@ -389,6 +389,13 @@ class Image(Structure):
raise PixieError(take_error()) raise PixieError(take_error())
return result return result
def draw(self, b, transform = None, blend_mode = BM_NORMAL):
if transform is None:
transform = Matrix3()
dll.pixie_image_draw(self, b, transform, blend_mode)
if check_error():
raise PixieError(take_error())
def mask_draw(self, mask, transform = None, blend_mode = BM_MASK): def mask_draw(self, mask, transform = None, blend_mode = BM_MASK):
if transform is None: if transform is None:
transform = Matrix3() transform = Matrix3()
@ -396,15 +403,17 @@ class Image(Structure):
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
def image_draw(self, b, transform = None, blend_mode = BM_NORMAL): def fill_gradient(self, paint):
if transform is None: dll.pixie_image_fill_gradient(self, paint)
transform = Matrix3()
dll.pixie_image_image_draw(self, b, transform, blend_mode)
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
def fill_gradient(self, paint): def fill_text(self, font, text, transform = None, bounds = None, h_align = HA_LEFT, v_align = VA_TOP):
dll.pixie_image_fill_gradient(self, paint) if transform is None:
transform = Matrix3()
if bounds is None:
bounds = Vector2(0, 0)
dll.pixie_image_fill_text(self, font, text.encode("utf8"), transform, bounds, h_align, v_align)
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
@ -415,12 +424,12 @@ class Image(Structure):
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
def font_fill_text(self, font, text, transform = None, bounds = None, h_align = HA_LEFT, v_align = VA_TOP): def stroke_text(self, font, text, transform = None, stroke_width = 1.0, bounds = None, h_align = HA_LEFT, v_align = VA_TOP, line_cap = LC_BUTT, line_join = LJ_MITER, miter_limit = DEFAULT_MITER_LIMIT, dashes = None):
if transform is None: if transform is None:
transform = Matrix3() transform = Matrix3()
if bounds is None: if bounds is None:
bounds = Vector2(0, 0) bounds = Vector2(0, 0)
dll.pixie_image_font_fill_text(self, font, text.encode("utf8"), transform, bounds, h_align, v_align) dll.pixie_image_stroke_text(self, font, text.encode("utf8"), transform, stroke_width, bounds, h_align, v_align, line_cap, line_join, miter_limit, dashes)
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
@ -431,15 +440,6 @@ class Image(Structure):
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
def font_stroke_text(self, font, text, transform = None, stroke_width = 1.0, bounds = None, h_align = HA_LEFT, v_align = VA_TOP, line_cap = LC_BUTT, line_join = LJ_MITER, miter_limit = DEFAULT_MITER_LIMIT, dashes = None):
if transform is None:
transform = Matrix3()
if bounds is None:
bounds = Vector2(0, 0)
dll.pixie_image_font_stroke_text(self, font, text.encode("utf8"), transform, stroke_width, bounds, h_align, v_align, line_cap, line_join, miter_limit, dashes)
if check_error():
raise PixieError(take_error())
def fill_path(self, path, paint, transform = None, winding_rule = WR_NON_ZERO): def fill_path(self, path, paint, transform = None, winding_rule = WR_NON_ZERO):
if transform is None: if transform is None:
transform = Matrix3() transform = Matrix3()
@ -548,10 +548,10 @@ class Mask(Structure):
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
def mask_draw(self, b, transform = None, blend_mode = BM_MASK): def draw(self, b, transform = None, blend_mode = BM_MASK):
if transform is None: if transform is None:
transform = Matrix3() transform = Matrix3()
dll.pixie_mask_mask_draw(self, b, transform, blend_mode) dll.pixie_mask_draw(self, b, transform, blend_mode)
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
@ -562,6 +562,15 @@ class Mask(Structure):
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
def fill_text(self, font, text, transform = None, bounds = None, h_align = HA_LEFT, v_align = VA_TOP):
if transform is None:
transform = Matrix3()
if bounds is None:
bounds = Vector2(0, 0)
dll.pixie_mask_fill_text(self, font, text.encode("utf8"), transform, bounds, h_align, v_align)
if check_error():
raise PixieError(take_error())
def arrangement_fill_text(self, arrangement, transform = None): def arrangement_fill_text(self, arrangement, transform = None):
if transform is None: if transform is None:
transform = Matrix3() transform = Matrix3()
@ -569,12 +578,12 @@ class Mask(Structure):
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
def font_fill_text(self, font, text, transform = None, bounds = None, h_align = HA_LEFT, v_align = VA_TOP): def stroke_text(self, font, text, transform = None, stroke_width = 1.0, bounds = None, h_align = HA_LEFT, v_align = VA_TOP, line_cap = LC_BUTT, line_join = LJ_MITER, miter_limit = DEFAULT_MITER_LIMIT, dashes = None):
if transform is None: if transform is None:
transform = Matrix3() transform = Matrix3()
if bounds is None: if bounds is None:
bounds = Vector2(0, 0) bounds = Vector2(0, 0)
dll.pixie_mask_font_fill_text(self, font, text.encode("utf8"), transform, bounds, h_align, v_align) dll.pixie_mask_stroke_text(self, font, text.encode("utf8"), transform, stroke_width, bounds, h_align, v_align, line_cap, line_join, miter_limit, dashes)
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
@ -585,15 +594,6 @@ class Mask(Structure):
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
def font_stroke_text(self, font, text, transform = None, stroke_width = 1.0, bounds = None, h_align = HA_LEFT, v_align = VA_TOP, line_cap = LC_BUTT, line_join = LJ_MITER, miter_limit = DEFAULT_MITER_LIMIT, dashes = None):
if transform is None:
transform = Matrix3()
if bounds is None:
bounds = Vector2(0, 0)
dll.pixie_mask_font_stroke_text(self, font, text.encode("utf8"), transform, stroke_width, bounds, h_align, v_align, line_cap, line_join, miter_limit, dashes)
if check_error():
raise PixieError(take_error())
def fill_path(self, path, transform = None, winding_rule = WR_NON_ZERO, blend_mode = BM_NORMAL): def fill_path(self, path, transform = None, winding_rule = WR_NON_ZERO, blend_mode = BM_NORMAL):
if transform is None: if transform is None:
transform = Matrix3() transform = Matrix3()
@ -1161,13 +1161,18 @@ class Context(Structure):
def close_path(self): def close_path(self):
dll.pixie_context_close_path(self) dll.pixie_context_close_path(self)
def fill(self, winding_rule = WR_NON_ZERO):
dll.pixie_context_fill(self, winding_rule)
if check_error():
raise PixieError(take_error())
def path_fill(self, path, winding_rule = WR_NON_ZERO): def path_fill(self, path, winding_rule = WR_NON_ZERO):
dll.pixie_context_path_fill(self, path, winding_rule) dll.pixie_context_path_fill(self, path, winding_rule)
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
def fill(self, winding_rule = WR_NON_ZERO): def clip(self, winding_rule = WR_NON_ZERO):
dll.pixie_context_winding_rule_fill(self, winding_rule) dll.pixie_context_clip(self, winding_rule)
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
@ -1176,8 +1181,8 @@ class Context(Structure):
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
def clip(self, winding_rule = WR_NON_ZERO): def stroke(self):
dll.pixie_context_winding_rule_clip(self, winding_rule) dll.pixie_context_stroke(self)
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
@ -1186,11 +1191,6 @@ class Context(Structure):
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
def stroke(self):
dll.pixie_context_stroke(self)
if check_error():
raise PixieError(take_error())
def measure_text(self, text): def measure_text(self, text):
result = dll.pixie_context_measure_text(self, text.encode("utf8")) result = dll.pixie_context_measure_text(self, text.encode("utf8"))
if check_error(): if check_error():
@ -1302,12 +1302,24 @@ class Context(Structure):
raise PixieError(take_error()) raise PixieError(take_error())
return result return result
def path_is_point_in_path(self, path, x, y, winding_rule = WR_NON_ZERO):
result = dll.pixie_context_path_is_point_in_path(self, path, x, y, winding_rule)
if check_error():
raise PixieError(take_error())
return result
def is_point_in_stroke(self, x, y): def is_point_in_stroke(self, x, y):
result = dll.pixie_context_is_point_in_stroke(self, x, y) result = dll.pixie_context_is_point_in_stroke(self, x, y)
if check_error(): if check_error():
raise PixieError(take_error()) raise PixieError(take_error())
return result return result
def path_is_point_in_stroke(self, path, x, y):
result = dll.pixie_context_path_is_point_in_stroke(self, path, x, y)
if check_error():
raise PixieError(take_error())
return result
def read_image(file_path): def read_image(file_path):
result = dll.pixie_read_image(file_path.encode("utf8")) result = dll.pixie_read_image(file_path.encode("utf8"))
if check_error(): if check_error():
@ -1481,27 +1493,27 @@ dll.pixie_image_shadow.restype = Image
dll.pixie_image_super_image.argtypes = [Image, c_longlong, c_longlong, c_longlong, c_longlong] dll.pixie_image_super_image.argtypes = [Image, c_longlong, c_longlong, c_longlong, c_longlong]
dll.pixie_image_super_image.restype = Image dll.pixie_image_super_image.restype = Image
dll.pixie_image_draw.argtypes = [Image, Image, Matrix3, BlendMode]
dll.pixie_image_draw.restype = None
dll.pixie_image_mask_draw.argtypes = [Image, Mask, Matrix3, BlendMode] dll.pixie_image_mask_draw.argtypes = [Image, Mask, Matrix3, BlendMode]
dll.pixie_image_mask_draw.restype = None dll.pixie_image_mask_draw.restype = None
dll.pixie_image_image_draw.argtypes = [Image, Image, Matrix3, BlendMode]
dll.pixie_image_image_draw.restype = None
dll.pixie_image_fill_gradient.argtypes = [Image, Paint] dll.pixie_image_fill_gradient.argtypes = [Image, Paint]
dll.pixie_image_fill_gradient.restype = None dll.pixie_image_fill_gradient.restype = None
dll.pixie_image_fill_text.argtypes = [Image, Font, c_char_p, Matrix3, Vector2, HorizontalAlignment, VerticalAlignment]
dll.pixie_image_fill_text.restype = None
dll.pixie_image_arrangement_fill_text.argtypes = [Image, Arrangement, Matrix3] dll.pixie_image_arrangement_fill_text.argtypes = [Image, Arrangement, Matrix3]
dll.pixie_image_arrangement_fill_text.restype = None dll.pixie_image_arrangement_fill_text.restype = None
dll.pixie_image_font_fill_text.argtypes = [Image, Font, c_char_p, Matrix3, Vector2, HorizontalAlignment, VerticalAlignment] dll.pixie_image_stroke_text.argtypes = [Image, Font, c_char_p, Matrix3, c_float, Vector2, HorizontalAlignment, VerticalAlignment, LineCap, LineJoin, c_float, SeqFloat32]
dll.pixie_image_font_fill_text.restype = None dll.pixie_image_stroke_text.restype = None
dll.pixie_image_arrangement_stroke_text.argtypes = [Image, Arrangement, Matrix3, c_float, LineCap, LineJoin, c_float, SeqFloat32] dll.pixie_image_arrangement_stroke_text.argtypes = [Image, Arrangement, Matrix3, c_float, LineCap, LineJoin, c_float, SeqFloat32]
dll.pixie_image_arrangement_stroke_text.restype = None dll.pixie_image_arrangement_stroke_text.restype = None
dll.pixie_image_font_stroke_text.argtypes = [Image, Font, c_char_p, Matrix3, c_float, Vector2, HorizontalAlignment, VerticalAlignment, LineCap, LineJoin, c_float, SeqFloat32]
dll.pixie_image_font_stroke_text.restype = None
dll.pixie_image_fill_path.argtypes = [Image, Path, Paint, Matrix3, WindingRule] dll.pixie_image_fill_path.argtypes = [Image, Path, Paint, Matrix3, WindingRule]
dll.pixie_image_fill_path.restype = None dll.pixie_image_fill_path.restype = None
@ -1568,24 +1580,24 @@ dll.pixie_mask_invert.restype = None
dll.pixie_mask_blur.argtypes = [Mask, c_float, c_ubyte] dll.pixie_mask_blur.argtypes = [Mask, c_float, c_ubyte]
dll.pixie_mask_blur.restype = None dll.pixie_mask_blur.restype = None
dll.pixie_mask_mask_draw.argtypes = [Mask, Mask, Matrix3, BlendMode] dll.pixie_mask_draw.argtypes = [Mask, Mask, Matrix3, BlendMode]
dll.pixie_mask_mask_draw.restype = None dll.pixie_mask_draw.restype = None
dll.pixie_mask_image_draw.argtypes = [Mask, Image, Matrix3, BlendMode] dll.pixie_mask_image_draw.argtypes = [Mask, Image, Matrix3, BlendMode]
dll.pixie_mask_image_draw.restype = None dll.pixie_mask_image_draw.restype = None
dll.pixie_mask_fill_text.argtypes = [Mask, Font, c_char_p, Matrix3, Vector2, HorizontalAlignment, VerticalAlignment]
dll.pixie_mask_fill_text.restype = None
dll.pixie_mask_arrangement_fill_text.argtypes = [Mask, Arrangement, Matrix3] dll.pixie_mask_arrangement_fill_text.argtypes = [Mask, Arrangement, Matrix3]
dll.pixie_mask_arrangement_fill_text.restype = None dll.pixie_mask_arrangement_fill_text.restype = None
dll.pixie_mask_font_fill_text.argtypes = [Mask, Font, c_char_p, Matrix3, Vector2, HorizontalAlignment, VerticalAlignment] dll.pixie_mask_stroke_text.argtypes = [Mask, Font, c_char_p, Matrix3, c_float, Vector2, HorizontalAlignment, VerticalAlignment, LineCap, LineJoin, c_float, SeqFloat32]
dll.pixie_mask_font_fill_text.restype = None dll.pixie_mask_stroke_text.restype = None
dll.pixie_mask_arrangement_stroke_text.argtypes = [Mask, Arrangement, Matrix3, c_float, LineCap, LineJoin, c_float, SeqFloat32] dll.pixie_mask_arrangement_stroke_text.argtypes = [Mask, Arrangement, Matrix3, c_float, LineCap, LineJoin, c_float, SeqFloat32]
dll.pixie_mask_arrangement_stroke_text.restype = None dll.pixie_mask_arrangement_stroke_text.restype = None
dll.pixie_mask_font_stroke_text.argtypes = [Mask, Font, c_char_p, Matrix3, c_float, Vector2, HorizontalAlignment, VerticalAlignment, LineCap, LineJoin, c_float, SeqFloat32]
dll.pixie_mask_font_stroke_text.restype = None
dll.pixie_mask_fill_path.argtypes = [Mask, Path, Matrix3, WindingRule, BlendMode] dll.pixie_mask_fill_path.argtypes = [Mask, Path, Matrix3, WindingRule, BlendMode]
dll.pixie_mask_fill_path.restype = None dll.pixie_mask_fill_path.restype = None
@ -1952,24 +1964,24 @@ dll.pixie_context_begin_path.restype = None
dll.pixie_context_close_path.argtypes = [Context] dll.pixie_context_close_path.argtypes = [Context]
dll.pixie_context_close_path.restype = None dll.pixie_context_close_path.restype = None
dll.pixie_context_fill.argtypes = [Context, WindingRule]
dll.pixie_context_fill.restype = None
dll.pixie_context_path_fill.argtypes = [Context, Path, WindingRule] dll.pixie_context_path_fill.argtypes = [Context, Path, WindingRule]
dll.pixie_context_path_fill.restype = None dll.pixie_context_path_fill.restype = None
dll.pixie_context_winding_rule_fill.argtypes = [Context, WindingRule] dll.pixie_context_clip.argtypes = [Context, WindingRule]
dll.pixie_context_winding_rule_fill.restype = None dll.pixie_context_clip.restype = None
dll.pixie_context_path_clip.argtypes = [Context, Path, WindingRule] dll.pixie_context_path_clip.argtypes = [Context, Path, WindingRule]
dll.pixie_context_path_clip.restype = None dll.pixie_context_path_clip.restype = None
dll.pixie_context_winding_rule_clip.argtypes = [Context, WindingRule] dll.pixie_context_stroke.argtypes = [Context]
dll.pixie_context_winding_rule_clip.restype = None dll.pixie_context_stroke.restype = None
dll.pixie_context_path_stroke.argtypes = [Context, Path] dll.pixie_context_path_stroke.argtypes = [Context, Path]
dll.pixie_context_path_stroke.restype = None dll.pixie_context_path_stroke.restype = None
dll.pixie_context_stroke.argtypes = [Context]
dll.pixie_context_stroke.restype = None
dll.pixie_context_measure_text.argtypes = [Context, c_char_p] dll.pixie_context_measure_text.argtypes = [Context, c_char_p]
dll.pixie_context_measure_text.restype = TextMetrics dll.pixie_context_measure_text.restype = TextMetrics
@ -2054,9 +2066,15 @@ dll.pixie_context_rotate.restype = None
dll.pixie_context_is_point_in_path.argtypes = [Context, c_float, c_float, WindingRule] dll.pixie_context_is_point_in_path.argtypes = [Context, c_float, c_float, WindingRule]
dll.pixie_context_is_point_in_path.restype = c_bool dll.pixie_context_is_point_in_path.restype = c_bool
dll.pixie_context_path_is_point_in_path.argtypes = [Context, Path, c_float, c_float, WindingRule]
dll.pixie_context_path_is_point_in_path.restype = c_bool
dll.pixie_context_is_point_in_stroke.argtypes = [Context, c_float, c_float] dll.pixie_context_is_point_in_stroke.argtypes = [Context, c_float, c_float]
dll.pixie_context_is_point_in_stroke.restype = c_bool dll.pixie_context_is_point_in_stroke.restype = c_bool
dll.pixie_context_path_is_point_in_stroke.argtypes = [Context, Path, c_float, c_float]
dll.pixie_context_path_is_point_in_stroke.restype = c_bool
dll.pixie_read_image.argtypes = [c_char_p] dll.pixie_read_image.argtypes = [c_char_p]
dll.pixie_read_image.restype = Image dll.pixie_read_image.restype = Image

View file

@ -360,8 +360,6 @@ proc fill*(
## Fills the current path with the current fillStyle. ## Fills the current path with the current fillStyle.
ctx.fill(ctx.path, windingRule) ctx.fill(ctx.path, windingRule)
proc clip*(ctx: Context, windingRule = wrNonZero) {.inline, raises: [PixieError].}
proc clip*( proc clip*(
ctx: Context, path: Path, windingRule = wrNonZero ctx: Context, path: Path, windingRule = wrNonZero
) {.raises: [PixieError].} = ) {.raises: [PixieError].} =
@ -382,8 +380,6 @@ proc clip*(
## to create the new clipping region. ## to create the new clipping region.
ctx.clip(ctx.path, windingRule) ctx.clip(ctx.path, windingRule)
proc stroke*(ctx: Context) {.inline, raises: [PixieError].}
proc stroke*(ctx: Context, path: Path) {.raises: [PixieError].} = proc stroke*(ctx: Context, path: Path) {.raises: [PixieError].} =
## Strokes (outlines) the current or given path with the current strokeStyle. ## Strokes (outlines) the current or given path with the current strokeStyle.
if ctx.mask != nil and ctx.layer == nil: if ctx.mask != nil and ctx.layer == nil:

View file

@ -450,7 +450,7 @@ proc invert*(target: Image | Mask) {.raises: [].} =
target.data[j] = (255 - target.data[j]).uint8 target.data[j] = (255 - target.data[j]).uint8
proc blur*( proc blur*(
image: Image, radius: float32, outOfBounds: SomeColor = ColorRGBX() image: Image, radius: float32, outOfBounds: SomeColor = Color()
) {.raises: [PixieError].} = ) {.raises: [PixieError].} =
## Applies Gaussian blur to the image given a radius. ## Applies Gaussian blur to the image given a radius.
let radius = round(radius).int let radius = round(radius).int