diff --git a/bindings/bindings.nim b/bindings/bindings.nim index d52f717..d18add0 100644 --- a/bindings/bindings.nim +++ b/bindings/bindings.nim @@ -34,6 +34,11 @@ proc drawImage3*( ) {.raises: [PixieError].} = ctx.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) +exportConsts: + export + defaultMiterLimit, + autoLineHeight + exportEnums: export FileFormat, diff --git a/bindings/generated/internal.nim b/bindings/generated/internal.nim index 304bfec..bd6a43f 100644 --- a/bindings/generated/internal.nim +++ b/bindings/generated/internal.nim @@ -22,7 +22,7 @@ proc pixie_seq_float_32_get*(s: SeqFloat32, i: int): float32 {.raises: [], cdecl proc pixie_seq_float_32_set*(s: SeqFloat32, i: int, v: float32) {.raises: [], cdecl, exportc, dynlib.} = s.s[i] = v -proc pixie_seq_float_32_remove*(s: SeqFloat32, i: int) {.raises: [], cdecl, exportc, dynlib.} = +proc pixie_seq_float_32_delete*(s: SeqFloat32, i: int) {.raises: [], cdecl, exportc, dynlib.} = s.s.delete(i) proc pixie_seq_float_32_clear*(s: SeqFloat32) {.raises: [], cdecl, exportc, dynlib.} = @@ -49,7 +49,7 @@ proc pixie_seq_span_get*(s: SeqSpan, i: int): Span {.raises: [], cdecl, exportc, proc pixie_seq_span_set*(s: SeqSpan, i: int, v: Span) {.raises: [], cdecl, exportc, dynlib.} = s.s[i] = v -proc pixie_seq_span_remove*(s: SeqSpan, i: int) {.raises: [], cdecl, exportc, dynlib.} = +proc pixie_seq_span_delete*(s: SeqSpan, i: int) {.raises: [], cdecl, exportc, dynlib.} = s.s.delete(i) proc pixie_seq_span_clear*(s: SeqSpan) {.raises: [], cdecl, exportc, dynlib.} = @@ -406,7 +406,7 @@ proc pixie_paint_gradient_handle_positions_get*(paint: Paint, i: int): Vec2 {.ra proc pixie_paint_gradient_handle_positions_set*(paint: Paint, i: int, v: Vec2) {.raises: [], cdecl, exportc, dynlib.} = paint.gradientHandlePositions[i] = v -proc pixie_paint_gradient_handle_positions_remove*(paint: Paint, i: int) {.raises: [], cdecl, exportc, dynlib.} = +proc pixie_paint_gradient_handle_positions_delete*(paint: Paint, i: int) {.raises: [], cdecl, exportc, dynlib.} = paint.gradientHandlePositions.delete(i) proc pixie_paint_gradient_handle_positions_clear*(paint: Paint) {.raises: [], cdecl, exportc, dynlib.} = @@ -424,7 +424,7 @@ proc pixie_paint_gradient_stops_get*(paint: Paint, i: int): ColorStop {.raises: proc pixie_paint_gradient_stops_set*(paint: Paint, i: int, v: ColorStop) {.raises: [], cdecl, exportc, dynlib.} = paint.gradientStops[i] = v -proc pixie_paint_gradient_stops_remove*(paint: Paint, i: int) {.raises: [], cdecl, exportc, dynlib.} = +proc pixie_paint_gradient_stops_delete*(paint: Paint, i: int) {.raises: [], cdecl, exportc, dynlib.} = paint.gradientStops.delete(i) proc pixie_paint_gradient_stops_clear*(paint: Paint) {.raises: [], cdecl, exportc, dynlib.} = @@ -577,7 +577,7 @@ proc pixie_font_paints_get*(font: Font, i: int): Paint {.raises: [], cdecl, expo proc pixie_font_paints_set*(font: Font, i: int, v: Paint) {.raises: [], cdecl, exportc, dynlib.} = font.paints[i] = v -proc pixie_font_paints_remove*(font: Font, i: int) {.raises: [], cdecl, exportc, dynlib.} = +proc pixie_font_paints_delete*(font: Font, i: int) {.raises: [], cdecl, exportc, dynlib.} = font.paints.delete(i) proc pixie_font_paints_clear*(font: Font) {.raises: [], cdecl, exportc, dynlib.} = diff --git a/bindings/generated/pixie.nim b/bindings/generated/pixie.nim index fa12da2..7ecc73e 100644 --- a/bindings/generated/pixie.nim +++ b/bindings/generated/pixie.nim @@ -3,16 +3,20 @@ import bumpy, chroma, unicode, vmath export bumpy, chroma, unicode, vmath when defined(windows): - const dllPath = "pixie.dll" + const libPath = "pixie.dll" elif defined(macosx): - const dllPath = "libpixie.dll" + const libPath = "libpixie.dylib" else: - const dllPath = "libpixie.so" + const libPath = "libpixie.so" -{.push dynlib: dllPath.} +{.push dynlib: libPath.} type PixieError = object of ValueError +const defaultMiterLimit* = 4.0 + +const autoLineHeight* = -1.0 + type FileFormat* = enum ffPng ffBmp @@ -92,7 +96,7 @@ type ColorStop* = object type TextMetrics* = object width*: float32 -type SeqFloat32Obj* = object +type SeqFloat32Obj = object reference: pointer type SeqFloat32* = ref SeqFloat32Obj @@ -102,7 +106,7 @@ proc pixie_seq_float_32_unref(x: SeqFloat32Obj) {.importc: "pixie_seq_float_32_u proc `=destroy`(x: var SeqFloat32Obj) = pixie_seq_float_32_unref(x) -type SeqSpanObj* = object +type SeqSpanObj = object reference: pointer type SeqSpan* = ref SeqSpanObj @@ -112,7 +116,7 @@ proc pixie_seq_span_unref(x: SeqSpanObj) {.importc: "pixie_seq_span_unref", cdec proc `=destroy`(x: var SeqSpanObj) = pixie_seq_span_unref(x) -type ImageObj* = object +type ImageObj = object reference: pointer type Image* = ref ImageObj @@ -122,7 +126,7 @@ proc pixie_image_unref(x: ImageObj) {.importc: "pixie_image_unref", cdecl.} proc `=destroy`(x: var ImageObj) = pixie_image_unref(x) -type MaskObj* = object +type MaskObj = object reference: pointer type Mask* = ref MaskObj @@ -132,7 +136,7 @@ proc pixie_mask_unref(x: MaskObj) {.importc: "pixie_mask_unref", cdecl.} proc `=destroy`(x: var MaskObj) = pixie_mask_unref(x) -type PaintObj* = object +type PaintObj = object reference: pointer type Paint* = ref PaintObj @@ -142,7 +146,7 @@ proc pixie_paint_unref(x: PaintObj) {.importc: "pixie_paint_unref", cdecl.} proc `=destroy`(x: var PaintObj) = pixie_paint_unref(x) -type PathObj* = object +type PathObj = object reference: pointer type Path* = ref PathObj @@ -152,7 +156,7 @@ proc pixie_path_unref(x: PathObj) {.importc: "pixie_path_unref", cdecl.} proc `=destroy`(x: var PathObj) = pixie_path_unref(x) -type TypefaceObj* = object +type TypefaceObj = object reference: pointer type Typeface* = ref TypefaceObj @@ -162,7 +166,7 @@ proc pixie_typeface_unref(x: TypefaceObj) {.importc: "pixie_typeface_unref", cde proc `=destroy`(x: var TypefaceObj) = pixie_typeface_unref(x) -type FontObj* = object +type FontObj = object reference: pointer type Font* = ref FontObj @@ -172,7 +176,7 @@ proc pixie_font_unref(x: FontObj) {.importc: "pixie_font_unref", cdecl.} proc `=destroy`(x: var FontObj) = pixie_font_unref(x) -type SpanObj* = object +type SpanObj = object reference: pointer type Span* = ref SpanObj @@ -182,7 +186,7 @@ proc pixie_span_unref(x: SpanObj) {.importc: "pixie_span_unref", cdecl.} proc `=destroy`(x: var SpanObj) = pixie_span_unref(x) -type ArrangementObj* = object +type ArrangementObj = object reference: pointer type Arrangement* = ref ArrangementObj @@ -192,7 +196,7 @@ proc pixie_arrangement_unref(x: ArrangementObj) {.importc: "pixie_arrangement_un proc `=destroy`(x: var ArrangementObj) = pixie_arrangement_unref(x) -type ContextObj* = object +type ContextObj = object reference: pointer type Context* = ref ContextObj @@ -232,10 +236,10 @@ proc pixie_seq_float_32_set(s: SeqFloat32, i: int, v: float32) {.importc: "pixie proc `[]=`*(s: SeqFloat32, i: int, v: float32) = pixie_seq_float_32_set(s, i, v) -proc pixie_seq_float_32_remove(s: SeqFloat32, i: int) {.importc: "pixie_seq_float_32_remove", cdecl.} +proc pixie_seq_float_32_delete(s: SeqFloat32, i: int) {.importc: "pixie_seq_float_32_delete", cdecl.} -proc remove*(s: SeqFloat32, i: int) = - pixie_seq_float_32_remove(s, i) +proc delete*(s: SeqFloat32, i: int) = + pixie_seq_float_32_delete(s, i) proc pixie_seq_float_32_clear(s: SeqFloat32) {.importc: "pixie_seq_float_32_clear", cdecl.} @@ -267,10 +271,10 @@ proc pixie_seq_span_set(s: SeqSpan, i: int, v: Span) {.importc: "pixie_seq_span_ proc `[]=`*(s: SeqSpan, i: int, v: Span) = pixie_seq_span_set(s, i, v) -proc pixie_seq_span_remove(s: SeqSpan, i: int) {.importc: "pixie_seq_span_remove", cdecl.} +proc pixie_seq_span_delete(s: SeqSpan, i: int) {.importc: "pixie_seq_span_delete", cdecl.} -proc remove*(s: SeqSpan, i: int) = - pixie_seq_span_remove(s, i) +proc delete*(s: SeqSpan, i: int) = + pixie_seq_span_delete(s, i) proc pixie_seq_span_clear(s: SeqSpan) {.importc: "pixie_seq_span_clear", cdecl.} @@ -748,10 +752,10 @@ proc pixie_paint_gradient_handle_positions_set(s: Paint, i: int, v: Vec2) {.impo proc `[]=`*(s: PaintGradientHandlePositions, i: int, v: Vec2) = pixie_paint_gradient_handle_positions_set(s.paint, i, v) -proc pixie_paint_gradient_handle_positions_remove(s: Paint, i: int) {.importc: "pixie_paint_gradient_handle_positions_remove", cdecl.} +proc pixie_paint_gradient_handle_positions_delete(s: Paint, i: int) {.importc: "pixie_paint_gradient_handle_positions_delete", cdecl.} -proc remove*(s: PaintGradientHandlePositions, i: int) = - pixie_paint_gradient_handle_positions_remove(s.paint, i) +proc delete*(s: PaintGradientHandlePositions, i: int) = + pixie_paint_gradient_handle_positions_delete(s.paint, i) proc pixie_paint_gradient_handle_positions_clear(s: Paint) {.importc: "pixie_paint_gradient_handle_positions_clear", cdecl.} @@ -784,10 +788,10 @@ proc pixie_paint_gradient_stops_set(s: Paint, i: int, v: ColorStop) {.importc: " proc `[]=`*(s: PaintGradientStops, i: int, v: ColorStop) = pixie_paint_gradient_stops_set(s.paint, i, v) -proc pixie_paint_gradient_stops_remove(s: Paint, i: int) {.importc: "pixie_paint_gradient_stops_remove", cdecl.} +proc pixie_paint_gradient_stops_delete(s: Paint, i: int) {.importc: "pixie_paint_gradient_stops_delete", cdecl.} -proc remove*(s: PaintGradientStops, i: int) = - pixie_paint_gradient_stops_remove(s.paint, i) +proc delete*(s: PaintGradientStops, i: int) = + pixie_paint_gradient_stops_delete(s.paint, i) proc pixie_paint_gradient_stops_clear(s: Paint) {.importc: "pixie_paint_gradient_stops_clear", cdecl.} @@ -1012,10 +1016,10 @@ proc pixie_font_paints_set(s: Font, i: int, v: Paint) {.importc: "pixie_font_pai proc `[]=`*(s: FontPaints, i: int, v: Paint) = pixie_font_paints_set(s.font, i, v) -proc pixie_font_paints_remove(s: Font, i: int) {.importc: "pixie_font_paints_remove", cdecl.} +proc pixie_font_paints_delete(s: Font, i: int) {.importc: "pixie_font_paints_delete", cdecl.} -proc remove*(s: FontPaints, i: int) = - pixie_font_paints_remove(s.font, i) +proc delete*(s: FontPaints, i: int) = + pixie_font_paints_delete(s.font, i) proc pixie_font_paints_clear(s: Font) {.importc: "pixie_font_paints_clear", cdecl.} diff --git a/bindings/generated/pixie.py b/bindings/generated/pixie.py index 6c7dacc..2adaa05 100644 --- a/bindings/generated/pixie.py +++ b/bindings/generated/pixie.py @@ -6,16 +6,20 @@ src_path = Path(__file__).resolve() src_dir = str(src_path.parent) if sys.platform == "win32": - dllPath = "pixie.dll" + libPath = "pixie.dll" elif sys.platform == "darwin": - dllPath = "libpixie.dylib" + libPath = "libpixie.dylib" else: - dllPath = "libpixie.so" -dll = cdll.LoadLibrary(src_dir + "/" + dllPath) + libPath = "libpixie.so" +dll = cdll.LoadLibrary(src_dir + "/" + libPath) class PixieError(Exception): pass +DEFAULT_MITER_LIMIT = 4.0 + +AUTO_LINE_HEIGHT = -1.0 + FileFormat = c_byte FF_PNG = 0 FF_BMP = 1 @@ -213,7 +217,7 @@ class SeqFloat32(Structure): dll.pixie_seq_float_32_set(self, index, value) def __delitem__(self, index): - dll.pixie_seq_float_32_remove(self, index) + dll.pixie_seq_float_32_delete(self, index) def append(self, value): dll.pixie_seq_float_32_add(self, value) @@ -246,7 +250,7 @@ class SeqSpan(Structure): dll.pixie_seq_span_set(self, index, value) def __delitem__(self, index): - dll.pixie_seq_span_remove(self, index) + dll.pixie_seq_span_delete(self, index) def append(self, value): dll.pixie_seq_span_add(self, value) @@ -638,7 +642,7 @@ class Paint(Structure): dll.pixie_paint_gradient_handle_positions_set(self.paint, index, value) def __delitem__(self, index): - dll.pixie_paint_gradient_handle_positions_remove(self.paint, index) + dll.pixie_paint_gradient_handle_positions_delete(self.paint, index) def append(self, value): dll.pixie_paint_gradient_handle_positions_add(self.paint, value) @@ -665,7 +669,7 @@ class Paint(Structure): dll.pixie_paint_gradient_stops_set(self.paint, index, value) def __delitem__(self, index): - dll.pixie_paint_gradient_stops_remove(self.paint, index) + dll.pixie_paint_gradient_stops_delete(self.paint, index) def append(self, value): dll.pixie_paint_gradient_stops_add(self.paint, value) @@ -869,7 +873,7 @@ class Font(Structure): dll.pixie_font_paints_set(self.font, index, value) def __delitem__(self, index): - dll.pixie_font_paints_remove(self.font, index) + dll.pixie_font_paints_delete(self.font, index) def append(self, value): dll.pixie_font_paints_add(self.font, value) @@ -1310,8 +1314,8 @@ dll.pixie_seq_float_32_get.restype = c_float dll.pixie_seq_float_32_set.argtypes = [SeqFloat32, c_longlong, c_float] dll.pixie_seq_float_32_set.restype = None -dll.pixie_seq_float_32_remove.argtypes = [SeqFloat32, c_longlong] -dll.pixie_seq_float_32_remove.restype = None +dll.pixie_seq_float_32_delete.argtypes = [SeqFloat32, c_longlong] +dll.pixie_seq_float_32_delete.restype = None dll.pixie_seq_float_32_add.argtypes = [SeqFloat32, c_float] dll.pixie_seq_float_32_add.restype = None @@ -1334,8 +1338,8 @@ dll.pixie_seq_span_get.restype = Span dll.pixie_seq_span_set.argtypes = [SeqSpan, c_longlong, Span] dll.pixie_seq_span_set.restype = None -dll.pixie_seq_span_remove.argtypes = [SeqSpan, c_longlong] -dll.pixie_seq_span_remove.restype = None +dll.pixie_seq_span_delete.argtypes = [SeqSpan, c_longlong] +dll.pixie_seq_span_delete.restype = None dll.pixie_seq_span_add.argtypes = [SeqSpan, Span] dll.pixie_seq_span_add.restype = None @@ -1583,8 +1587,8 @@ dll.pixie_paint_gradient_handle_positions_get.restype = Vector2 dll.pixie_paint_gradient_handle_positions_set.argtypes = [Paint, c_longlong, Vector2] dll.pixie_paint_gradient_handle_positions_set.restype = None -dll.pixie_paint_gradient_handle_positions_remove.argtypes = [Paint, c_longlong] -dll.pixie_paint_gradient_handle_positions_remove.restype = None +dll.pixie_paint_gradient_handle_positions_delete.argtypes = [Paint, c_longlong] +dll.pixie_paint_gradient_handle_positions_delete.restype = None dll.pixie_paint_gradient_handle_positions_add.argtypes = [Paint, Vector2] dll.pixie_paint_gradient_handle_positions_add.restype = None @@ -1601,8 +1605,8 @@ dll.pixie_paint_gradient_stops_get.restype = ColorStop dll.pixie_paint_gradient_stops_set.argtypes = [Paint, c_longlong, ColorStop] dll.pixie_paint_gradient_stops_set.restype = None -dll.pixie_paint_gradient_stops_remove.argtypes = [Paint, c_longlong] -dll.pixie_paint_gradient_stops_remove.restype = None +dll.pixie_paint_gradient_stops_delete.argtypes = [Paint, c_longlong] +dll.pixie_paint_gradient_stops_delete.restype = None dll.pixie_paint_gradient_stops_add.argtypes = [Paint, ColorStop] dll.pixie_paint_gradient_stops_add.restype = None @@ -1736,8 +1740,8 @@ dll.pixie_font_paints_get.restype = Paint dll.pixie_font_paints_set.argtypes = [Font, c_longlong, Paint] dll.pixie_font_paints_set.restype = None -dll.pixie_font_paints_remove.argtypes = [Font, c_longlong] -dll.pixie_font_paints_remove.restype = None +dll.pixie_font_paints_delete.argtypes = [Font, c_longlong] +dll.pixie_font_paints_delete.restype = None dll.pixie_font_paints_add.argtypes = [Font, Paint] dll.pixie_font_paints_add.restype = None @@ -2017,4 +2021,3 @@ dll.pixie_miter_limit_to_angle.restype = c_float dll.pixie_angle_to_miter_limit.argtypes = [c_float] dll.pixie_angle_to_miter_limit.restype = c_float - diff --git a/src/pixie/fonts.nim b/src/pixie/fonts.nim index 5857d36..f80667d 100644 --- a/src/pixie/fonts.nim +++ b/src/pixie/fonts.nim @@ -3,7 +3,7 @@ import bumpy, chroma, common, os, pixie/fontformats/opentype, pixie/paths, strutils, unicode, vmath const - AutoLineHeight* = -1.float32 ## Use default line height for the font size + autoLineHeight*: float32 = -1 ## Use default line height for the font size LF = Rune(10) SP = Rune(32) @@ -16,7 +16,7 @@ type Font* = ref object typeface*: Typeface size*: float32 ## Font size in pixels. - lineHeight*: float32 ## The line height in pixels or AutoLineHeight for the font's default line height. + lineHeight*: float32 ## The line height in pixels or autoLineHeight for the font's default line height. paints*: seq[Paint] textCase*: TextCase underline*: bool ## Apply an underline. @@ -142,7 +142,7 @@ proc newFont*(typeface: Typeface): Font {.raises: [].} = result = Font() result.typeface = typeface result.size = 12 - result.lineHeight = AutoLineHeight + result.lineHeight = autoLineHeight result.paint = newPaint(pkSolid) result.paint.color = color(0, 0, 0, 1)