Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name = "pixie-python",
version = "3.0.2",
version = "3.1.4",
author = "Andre von Houck",
author_email = "starplant@gmail.com",
description = "Python bindings for Pixie, a full-featured 2D graphics library",
Expand Down
Binary file modified src/pixie/libpixie.dylib
Binary file not shown.
Binary file modified src/pixie/libpixie.so
Binary file not shown.
Binary file modified src/pixie/pixie.dll
Binary file not shown.
157 changes: 86 additions & 71 deletions src/pixie/pixie.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class PixieError(Exception):
FF_BMP = 1
FF_JPG = 2
FF_GIF = 3
FF_QOI = 4
FF_PPM = 5

BlendMode = c_byte
BM_NORMAL = 0
Expand Down Expand Up @@ -110,14 +112,14 @@ class Matrix3(Structure):
]

def __init__(self):
tmp = dll.pixie_matrix_3()
tmp = dll.pixie_matrix3()
self.values = tmp.values

def __eq__(self, obj):
return self.values[0] == obj.values[0] and self.values[1] == obj.values[1] and self.values[2] == obj.values[2] and self.values[3] == obj.values[3] and self.values[4] == obj.values[4] and self.values[5] == obj.values[5] and self.values[6] == obj.values[6] and self.values[7] == obj.values[7] and self.values[8] == obj.values[8]

def __mul__(self, b):
result = dll.pixie_matrix_3_mul(self, b)
result = dll.pixie_matrix3_mul(self, b)
return result

class Rect(Structure):
Expand Down Expand Up @@ -188,28 +190,28 @@ def __eq__(self, obj):
return self.ref == obj.ref

def __del__(self):
dll.pixie_seq_float_32_unref(self)
dll.pixie_seq_float32_unref(self)

def __init__(self):
self.ref = dll.pixie_new_seq_float_32()
self.ref = dll.pixie_new_seq_float32()

def __len__(self):
return dll.pixie_seq_float_32_len(self)
return dll.pixie_seq_float32_len(self)

def __getitem__(self, index):
return dll.pixie_seq_float_32_get(self, index)
return dll.pixie_seq_float32_get(self, index)

def __setitem__(self, index, value):
dll.pixie_seq_float_32_set(self, index, value)
dll.pixie_seq_float32_set(self, index, value)

def __delitem__(self, index):
dll.pixie_seq_float_32_delete(self, index)
dll.pixie_seq_float32_delete(self, index)

def append(self, value):
dll.pixie_seq_float_32_add(self, value)
dll.pixie_seq_float32_add(self, value)

def clear(self):
dll.pixie_seq_float_32_clear(self)
dll.pixie_seq_float32_clear(self)

class SeqSpan(Structure):
_fields_ = [("ref", c_ulonglong)]
Expand Down Expand Up @@ -331,7 +333,7 @@ def set_color(self, x, y, color):

def fill(self, color):
"""
Fills the image with the parameter color.
Fills the image with the color.
"""
dll.pixie_image_fill(self, color)

Expand All @@ -356,20 +358,20 @@ def sub_image(self, x, y, w, h):
raise PixieError(take_error())
return result

def minify_by_2(self, power = 1):
def minify_by2(self, power = 1):
"""
Scales the image down by an integer scale.
"""
result = dll.pixie_image_minify_by_2(self, power)
result = dll.pixie_image_minify_by2(self, power)
if check_error():
raise PixieError(take_error())
return result

def magnify_by_2(self, power = 1):
def magnify_by2(self, power = 1):
"""
Scales image up by 2 ^ power.
"""
result = dll.pixie_image_magnify_by_2(self, power)
result = dll.pixie_image_magnify_by2(self, power)
if check_error():
raise PixieError(take_error())
return result
Expand Down Expand Up @@ -398,7 +400,7 @@ def blur(self, radius, out_of_bounds = None):

def new_mask(self):
"""
Returns a new mask using the alpha values of the parameter image.
Returns a new mask using the alpha values of the image.
"""
result = dll.pixie_image_new_mask(self)
if check_error():
Expand Down Expand Up @@ -613,24 +615,24 @@ def set_value(self, x, y, value):

def fill(self, value):
"""
Fills the mask with the parameter value.
Fills the mask with the value.
"""
dll.pixie_mask_fill(self, value)

def minify_by_2(self, power = 1):
def minify_by2(self, power = 1):
"""
Scales the mask down by an integer scale.
"""
result = dll.pixie_mask_minify_by_2(self, power)
result = dll.pixie_mask_minify_by2(self, power)
if check_error():
raise PixieError(take_error())
return result

def magnify_by_2(self, power = 1):
def magnify_by2(self, power = 1):
"""
Scales mask up by 2 ^ power.
"""
result = dll.pixie_mask_magnify_by_2(self, power)
result = dll.pixie_mask_magnify_by2(self, power)
if check_error():
raise PixieError(take_error())
return result
Expand Down Expand Up @@ -985,24 +987,24 @@ def line_to(self, x, y):
"""
dll.pixie_path_line_to(self, x, y)

def bezier_curve_to(self, x_1, y_1, x_2, y_2, x_3, y_3):
def bezier_curve_to(self, x1, y1, x2, y2, x3, y3):
"""
Adds a cubic Bézier curve to the current sub-path. It requires three
points: the first two are control points and the third one is the end
point. The starting point is the latest point in the current path,
which can be changed using moveTo() before creating the Bézier curve.
"""
dll.pixie_path_bezier_curve_to(self, x_1, y_1, x_2, y_2, x_3, y_3)
dll.pixie_path_bezier_curve_to(self, x1, y1, x2, y2, x3, y3)

def quadratic_curve_to(self, x_1, y_1, x_2, y_2):
def quadratic_curve_to(self, x1, y1, x2, y2):
"""
Adds a quadratic Bézier curve to the current sub-path. It requires two
points: the first one is a control point and the second one is the end
point. The starting point is the latest point in the current path,
which can be changed using moveTo() before creating the quadratic
Bézier curve.
"""
dll.pixie_path_quadratic_curve_to(self, x_1, y_1, x_2, y_2)
dll.pixie_path_quadratic_curve_to(self, x1, y1, x2, y2)

def elliptical_arc_to(self, rx, ry, x_axis_rotation, large_arc_flag, sweep_flag, x, y):
"""
Expand All @@ -1011,20 +1013,20 @@ def elliptical_arc_to(self, rx, ry, x_axis_rotation, large_arc_flag, sweep_flag,
"""
dll.pixie_path_elliptical_arc_to(self, rx, ry, x_axis_rotation, large_arc_flag, sweep_flag, x, y)

def arc(self, x, y, r, a_0, a_1, ccw = False):
def arc(self, x, y, r, a0, a1, ccw = False):
"""
Adds a circular arc to the current sub-path.
"""
dll.pixie_path_arc(self, x, y, r, a_0, a_1, ccw)
dll.pixie_path_arc(self, x, y, r, a0, a1, ccw)
if check_error():
raise PixieError(take_error())

def arc_to(self, x_1, y_1, x_2, y_2, r):
def arc_to(self, x1, y1, x2, y2, r):
"""
Adds a circular arc using the given control points and radius.
Commonly used for making rounded corners.
"""
dll.pixie_path_arc_to(self, x_1, y_1, x_2, y_2, r)
dll.pixie_path_arc_to(self, x1, y1, x2, y2, r)
if check_error():
raise PixieError(take_error())

Expand Down Expand Up @@ -1570,6 +1572,13 @@ def reset_transform(self):
"""
dll.pixie_context_reset_transform(self)

def get_line_dash(self):
result = dll.pixie_context_get_line_dash(self)
return result

def set_line_dash(self, line_dash):
dll.pixie_context_set_line_dash(self, line_dash)

def draw_image(self, image, dx, dy):
"""
Draws a source image onto the destination image.
Expand All @@ -1578,13 +1587,13 @@ def draw_image(self, image, dx, dy):
if check_error():
raise PixieError(take_error())

def draw_image_2(self, image, dx, dy, d_width, d_height):
dll.pixie_context_draw_image_2(self, image, dx, dy, d_width, d_height)
def draw_image2(self, image, dx, dy, d_width, d_height):
dll.pixie_context_draw_image2(self, image, dx, dy, d_width, d_height)
if check_error():
raise PixieError(take_error())

def draw_image_3(self, image, sx, sy, s_width, s_height, dx, dy, d_width, d_height):
dll.pixie_context_draw_image_3(self, image, sx, sy, s_width, s_height, dx, dy, d_width, d_height)
def draw_image3(self, image, sx, sy, s_width, s_height, dx, dy, d_width, d_height):
dll.pixie_context_draw_image3(self, image, sx, sy, s_width, s_height, dx, dy, d_width, d_height)
if check_error():
raise PixieError(take_error())

Expand All @@ -1601,14 +1610,14 @@ def line_to(self, x, y):
"""
dll.pixie_context_line_to(self, x, y)

def bezier_curve_to(self, cp_1x, cp_1y, cp_2x, cp_2y, x, y):
def bezier_curve_to(self, cp1x, cp1y, cp2x, cp2y, x, y):
"""
Adds a cubic Bézier curve to the current sub-path. It requires three
points: the first two are control points and the third one is the end
point. The starting point is the latest point in the current path,
which can be changed using moveTo() before creating the Bézier curve.
"""
dll.pixie_context_bezier_curve_to(self, cp_1x, cp_1y, cp_2x, cp_2y, x, y)
dll.pixie_context_bezier_curve_to(self, cp1x, cp1y, cp2x, cp2y, x, y)

def quadratic_curve_to(self, cpx, cpy, x, y):
"""
Expand All @@ -1620,19 +1629,19 @@ def quadratic_curve_to(self, cpx, cpy, x, y):
"""
dll.pixie_context_quadratic_curve_to(self, cpx, cpy, x, y)

def arc(self, x, y, r, a_0, a_1, ccw = False):
def arc(self, x, y, r, a0, a1, ccw = False):
"""
Draws a circular arc.
"""
dll.pixie_context_arc(self, x, y, r, a_0, a_1, ccw)
dll.pixie_context_arc(self, x, y, r, a0, a1, ccw)
if check_error():
raise PixieError(take_error())

def arc_to(self, x_1, y_1, x_2, y_2, radius):
def arc_to(self, x1, y1, x2, y2, radius):
"""
Draws a circular arc using the given control points and radius.
"""
dll.pixie_context_arc_to(self, x_1, y_1, x_2, y_2, radius)
dll.pixie_context_arc_to(self, x1, y1, x2, y2, radius)
if check_error():
raise PixieError(take_error())

Expand Down Expand Up @@ -1862,35 +1871,35 @@ def inverse(m):
dll.pixie_take_error.argtypes = []
dll.pixie_take_error.restype = c_char_p

dll.pixie_matrix_3.argtypes = []
dll.pixie_matrix_3.restype = Matrix3
dll.pixie_matrix3.argtypes = []
dll.pixie_matrix3.restype = Matrix3

dll.pixie_matrix_3_mul.argtypes = [Matrix3, Matrix3]
dll.pixie_matrix_3_mul.restype = Matrix3
dll.pixie_matrix3_mul.argtypes = [Matrix3, Matrix3]
dll.pixie_matrix3_mul.restype = Matrix3

dll.pixie_seq_float_32_unref.argtypes = [SeqFloat32]
dll.pixie_seq_float_32_unref.restype = None
dll.pixie_seq_float32_unref.argtypes = [SeqFloat32]
dll.pixie_seq_float32_unref.restype = None

dll.pixie_new_seq_float_32.argtypes = []
dll.pixie_new_seq_float_32.restype = c_ulonglong
dll.pixie_new_seq_float32.argtypes = []
dll.pixie_new_seq_float32.restype = c_ulonglong

dll.pixie_seq_float_32_len.argtypes = [SeqFloat32]
dll.pixie_seq_float_32_len.restype = c_longlong
dll.pixie_seq_float32_len.argtypes = [SeqFloat32]
dll.pixie_seq_float32_len.restype = c_longlong

dll.pixie_seq_float_32_get.argtypes = [SeqFloat32, c_longlong]
dll.pixie_seq_float_32_get.restype = c_float
dll.pixie_seq_float32_get.argtypes = [SeqFloat32, c_longlong]
dll.pixie_seq_float32_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_float32_set.argtypes = [SeqFloat32, c_longlong, c_float]
dll.pixie_seq_float32_set.restype = None

dll.pixie_seq_float_32_delete.argtypes = [SeqFloat32, c_longlong]
dll.pixie_seq_float_32_delete.restype = None
dll.pixie_seq_float32_delete.argtypes = [SeqFloat32, c_longlong]
dll.pixie_seq_float32_delete.restype = None

dll.pixie_seq_float_32_add.argtypes = [SeqFloat32, c_float]
dll.pixie_seq_float_32_add.restype = None
dll.pixie_seq_float32_add.argtypes = [SeqFloat32, c_float]
dll.pixie_seq_float32_add.restype = None

dll.pixie_seq_float_32_clear.argtypes = [SeqFloat32]
dll.pixie_seq_float_32_clear.restype = None
dll.pixie_seq_float32_clear.argtypes = [SeqFloat32]
dll.pixie_seq_float32_clear.restype = None

dll.pixie_seq_span_unref.argtypes = [SeqSpan]
dll.pixie_seq_span_unref.restype = None
Expand Down Expand Up @@ -1964,11 +1973,11 @@ def inverse(m):
dll.pixie_image_sub_image.argtypes = [Image, c_longlong, c_longlong, c_longlong, c_longlong]
dll.pixie_image_sub_image.restype = Image

dll.pixie_image_minify_by_2.argtypes = [Image, c_longlong]
dll.pixie_image_minify_by_2.restype = Image
dll.pixie_image_minify_by2.argtypes = [Image, c_longlong]
dll.pixie_image_minify_by2.restype = Image

dll.pixie_image_magnify_by_2.argtypes = [Image, c_longlong]
dll.pixie_image_magnify_by_2.restype = Image
dll.pixie_image_magnify_by2.argtypes = [Image, c_longlong]
dll.pixie_image_magnify_by2.restype = Image

dll.pixie_image_apply_opacity.argtypes = [Image, c_float]
dll.pixie_image_apply_opacity.restype = None
Expand Down Expand Up @@ -2054,11 +2063,11 @@ def inverse(m):
dll.pixie_mask_fill.argtypes = [Mask, c_ubyte]
dll.pixie_mask_fill.restype = None

dll.pixie_mask_minify_by_2.argtypes = [Mask, c_longlong]
dll.pixie_mask_minify_by_2.restype = Mask
dll.pixie_mask_minify_by2.argtypes = [Mask, c_longlong]
dll.pixie_mask_minify_by2.restype = Mask

dll.pixie_mask_magnify_by_2.argtypes = [Mask, c_longlong]
dll.pixie_mask_magnify_by_2.restype = Mask
dll.pixie_mask_magnify_by2.argtypes = [Mask, c_longlong]
dll.pixie_mask_magnify_by2.restype = Mask

dll.pixie_mask_spread.argtypes = [Mask, c_float]
dll.pixie_mask_spread.restype = None
Expand Down Expand Up @@ -2504,14 +2513,20 @@ def inverse(m):
dll.pixie_context_reset_transform.argtypes = [Context]
dll.pixie_context_reset_transform.restype = None

dll.pixie_context_get_line_dash.argtypes = [Context]
dll.pixie_context_get_line_dash.restype = SeqFloat32

dll.pixie_context_set_line_dash.argtypes = [Context, SeqFloat32]
dll.pixie_context_set_line_dash.restype = None

dll.pixie_context_draw_image.argtypes = [Context, Image, c_float, c_float]
dll.pixie_context_draw_image.restype = None

dll.pixie_context_draw_image_2.argtypes = [Context, Image, c_float, c_float, c_float, c_float]
dll.pixie_context_draw_image_2.restype = None
dll.pixie_context_draw_image2.argtypes = [Context, Image, c_float, c_float, c_float, c_float]
dll.pixie_context_draw_image2.restype = None

dll.pixie_context_draw_image_3.argtypes = [Context, Image, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_float]
dll.pixie_context_draw_image_3.restype = None
dll.pixie_context_draw_image3.argtypes = [Context, Image, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_float]
dll.pixie_context_draw_image3.restype = None

dll.pixie_context_move_to.argtypes = [Context, c_float, c_float]
dll.pixie_context_move_to.restype = None
Expand Down
Binary file modified tests/images/blur.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/images/draw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/images/fill1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/images/fill_gradient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/images/fill_text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/images/flip_horizontal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/images/flip_vertical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/images/mask_draw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/images/red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/images/shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/images/stroke1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/images/stroke_text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/images/sub_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/images/super_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/masks/127.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/masks/255.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/masks/blur.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/masks/draw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/masks/fill1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/masks/fill_text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/masks/image_draw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/masks/minified.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/masks/spread.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/masks/stroke1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/masks/stroke_text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading