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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ nimcache
.*
dist
__pycache__
pixie_python.egg-info/
build/
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 = "4.0.1",
version = "4.3.0",
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.
44 changes: 30 additions & 14 deletions src/pixie/pixie.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __next__(self):
FileFormat = c_byte
PNG_FORMAT = 0
BMP_FORMAT = 1
JPG_FORMAT = 2
JPEG_FORMAT = 2
GIF_FORMAT = 3
QOI_FORMAT = 4
PPM_FORMAT = 5
Expand Down Expand Up @@ -280,11 +280,11 @@ def typeset(self, bounds = None, h_align = LEFT_ALIGN, v_align = TOP_ALIGN, wrap
result = dll.pixie_seq_span_typeset(self, bounds, h_align, v_align, wrap)
return result

def compute_bounds(self):
def layout_bounds(self):
"""
Computes the width and height of the spans in pixels.
"""
result = dll.pixie_seq_span_compute_bounds(self)
result = dll.pixie_seq_span_layout_bounds(self)
return result

class Image(Structure):
Expand Down Expand Up @@ -685,7 +685,7 @@ def apply_opacity(self, opacity):

def invert(self):
"""
Inverts all of the colors and alpha.
Inverts all of the values - creates a negative of the mask.
"""
dll.pixie_mask_invert(self)

Expand Down Expand Up @@ -1087,8 +1087,11 @@ def circle(self, cx, cy, r):
def polygon(self, x, y, size, sides):
"""
Adds an n-sided regular polygon at (x, y) with the parameter size.
Polygons "face" north.
"""
dll.pixie_path_polygon(self, x, y, size, sides)
if check_error():
raise PixieError(take_error())

class Typeface(Structure):
_fields_ = [("ref", c_ulonglong)]
Expand Down Expand Up @@ -1306,11 +1309,11 @@ def typeset(self, text, bounds = None, h_align = LEFT_ALIGN, v_align = TOP_ALIGN
result = dll.pixie_font_typeset(self, text.encode("utf8"), bounds, h_align, v_align, wrap)
return result

def compute_bounds(self, text):
def layout_bounds(self, text):
"""
Computes the width and height of the text in pixels.
"""
result = dll.pixie_font_compute_bounds(self, text.encode("utf8"))
result = dll.pixie_font_layout_bounds(self, text.encode("utf8"))
return result

class Span(Structure):
Expand Down Expand Up @@ -1357,11 +1360,19 @@ def __eq__(self, obj):
def __del__(self):
dll.pixie_arrangement_unref(self)

def compute_bounds(self):
def layout_bounds(self):
"""
Computes the width and height of the arrangement in pixels.
"""
result = dll.pixie_arrangement_compute_bounds(self)
result = dll.pixie_arrangement_layout_bounds(self)
return result

def compute_bounds(self, transform = None):
if transform is None:
transform = Matrix3()
result = dll.pixie_arrangement_compute_bounds(self, transform)
if check_error():
raise PixieError(take_error())
return result

class Context(Structure):
Expand Down Expand Up @@ -1703,6 +1714,8 @@ def polygon(self, x, y, size, sides):
Adds an n-sided regular polygon at (x, y) of size to the current path.
"""
dll.pixie_context_polygon(self, x, y, size, sides)
if check_error():
raise PixieError(take_error())

def clear_rect(self, x, y, width, height):
"""
Expand Down Expand Up @@ -1957,8 +1970,8 @@ def inverse(m):
dll.pixie_seq_span_typeset.argtypes = [SeqSpan, Vector2, HorizontalAlignment, VerticalAlignment, c_bool]
dll.pixie_seq_span_typeset.restype = Arrangement

dll.pixie_seq_span_compute_bounds.argtypes = [SeqSpan]
dll.pixie_seq_span_compute_bounds.restype = Vector2
dll.pixie_seq_span_layout_bounds.argtypes = [SeqSpan]
dll.pixie_seq_span_layout_bounds.restype = Vector2

dll.pixie_image_unref.argtypes = [Image]
dll.pixie_image_unref.restype = None
Expand Down Expand Up @@ -2395,8 +2408,8 @@ def inverse(m):
dll.pixie_font_typeset.argtypes = [Font, c_char_p, Vector2, HorizontalAlignment, VerticalAlignment, c_bool]
dll.pixie_font_typeset.restype = Arrangement

dll.pixie_font_compute_bounds.argtypes = [Font, c_char_p]
dll.pixie_font_compute_bounds.restype = Vector2
dll.pixie_font_layout_bounds.argtypes = [Font, c_char_p]
dll.pixie_font_layout_bounds.restype = Vector2

dll.pixie_span_unref.argtypes = [Span]
dll.pixie_span_unref.restype = None
Expand All @@ -2419,8 +2432,11 @@ def inverse(m):
dll.pixie_arrangement_unref.argtypes = [Arrangement]
dll.pixie_arrangement_unref.restype = None

dll.pixie_arrangement_compute_bounds.argtypes = [Arrangement]
dll.pixie_arrangement_compute_bounds.restype = Vector2
dll.pixie_arrangement_layout_bounds.argtypes = [Arrangement]
dll.pixie_arrangement_layout_bounds.restype = Vector2

dll.pixie_arrangement_compute_bounds.argtypes = [Arrangement, Matrix3]
dll.pixie_arrangement_compute_bounds.restype = Rect

dll.pixie_context_unref.argtypes = [Context]
dll.pixie_context_unref.restype = None
Expand Down
Binary file added tests/images/mandrill.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/images/mandrill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/test_arrangement.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ def test_procs():
spans = pixie.SeqSpan()
spans.append(span)
arrangement = spans.typeset()
assert arrangement.compute_bounds() == pixie.Vector2(39, 14)
assert arrangement.layout_bounds() == pixie.Vector2(39, 14)
2 changes: 1 addition & 1 deletion tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_paths():
context.rounded_rect(0, 0, 0, 0, 0, 0, 0, 0)
context.ellipse(0, 0, 0, 0)
context.circle(0, 0, 0)
context.polygon(0, 0, 0, 0)
context.polygon(0, 0, 0, 3)
context.close_path()
assert not context.is_point_in_path(1, 1)
assert not context.is_point_in_stroke(1, 1)
Expand Down
7 changes: 7 additions & 0 deletions tests/test_fileformats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pixie

def test_png():
image = pixie.read_image("tests/images/mandrill.png")

def test_jpeg():
image = pixie.read_image("tests/images/mandrill.jpg")
2 changes: 1 addition & 1 deletion tests/test_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ def test_procs():
assert font.default_line_height() == 14
arrangement = font.typeset("typeset")
assert arrangement is not None
assert font.compute_bounds("typeset") == pixie.Vector2(39, 14)
assert font.layout_bounds("typeset") == pixie.Vector2(39, 14)
2 changes: 1 addition & 1 deletion tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test():
path.rounded_rect(0, 0, 0, 0, 0, 0, 0, 0)
path.ellipse(0, 0, 0, 0)
path.circle(0, 0, 0)
path.polygon(0, 0, 0, 0)
path.polygon(0, 0, 0, 3)
path.transform(pixie.Matrix3())
path.add_path(pixie.Path())
path.close_path()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_span.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ def test_procs():
spans = pixie.SeqSpan()
spans.append(span)
assert spans.typeset() is not None
assert spans.compute_bounds() == pixie.Vector2(39, 14)
assert spans.layout_bounds() == pixie.Vector2(39, 14)