diff --git a/setup.py b/setup.py index 2856f69..60a2b39 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name = "pixie-python", - version = "3.1.4", + version = "4.0.1", author = "Andre von Houck", author_email = "starplant@gmail.com", description = "Python bindings for Pixie, a full-featured 2D graphics library", diff --git a/src/pixie/libpixie.dylib b/src/pixie/libpixie.dylib index 1723e7d..ed054fd 100755 Binary files a/src/pixie/libpixie.dylib and b/src/pixie/libpixie.dylib differ diff --git a/src/pixie/libpixie.so b/src/pixie/libpixie.so index 3f9ac1b..47a5e30 100755 Binary files a/src/pixie/libpixie.so and b/src/pixie/libpixie.so differ diff --git a/src/pixie/pixie.dll b/src/pixie/pixie.dll index d61e2da..531e912 100644 Binary files a/src/pixie/pixie.dll and b/src/pixie/pixie.dll differ diff --git a/src/pixie/pixie.py b/src/pixie/pixie.py index cdce515..9f427a4 100644 --- a/src/pixie/pixie.py +++ b/src/pixie/pixie.py @@ -13,77 +13,91 @@ class PixieError(Exception): pass +class SeqIterator(object): + def __init__(self, seq): + self.idx = 0 + self.seq = seq + def __iter__(self): + return self + def __next__(self): + if self.idx < len(self.seq): + self.idx += 1 + return self.seq[self.idx - 1] + else: + self.idx = 0 + raise StopIteration + DEFAULT_MITER_LIMIT = 4.0 AUTO_LINE_HEIGHT = -1.0 FileFormat = c_byte -FF_PNG = 0 -FF_BMP = 1 -FF_JPG = 2 -FF_GIF = 3 -FF_QOI = 4 -FF_PPM = 5 +PNG_FORMAT = 0 +BMP_FORMAT = 1 +JPG_FORMAT = 2 +GIF_FORMAT = 3 +QOI_FORMAT = 4 +PPM_FORMAT = 5 BlendMode = c_byte -BM_NORMAL = 0 -BM_DARKEN = 1 -BM_MULTIPLY = 2 -BM_COLOR_BURN = 3 -BM_LIGHTEN = 4 -BM_SCREEN = 5 -BM_COLOR_DODGE = 6 -BM_OVERLAY = 7 -BM_SOFT_LIGHT = 8 -BM_HARD_LIGHT = 9 -BM_DIFFERENCE = 10 -BM_EXCLUSION = 11 -BM_HUE = 12 -BM_SATURATION = 13 -BM_COLOR = 14 -BM_LUMINOSITY = 15 -BM_MASK = 16 -BM_OVERWRITE = 17 -BM_SUBTRACT_MASK = 18 -BM_EXCLUDE_MASK = 19 +NORMAL_BLEND = 0 +DARKEN_BLEND = 1 +MULTIPLY_BLEND = 2 +COLOR_BURN_BLEND = 3 +LIGHTEN_BLEND = 4 +SCREEN_BLEND = 5 +COLOR_DODGE_BLEND = 6 +OVERLAY_BLEND = 7 +SOFT_LIGHT_BLEND = 8 +HARD_LIGHT_BLEND = 9 +DIFFERENCE_BLEND = 10 +EXCLUSION_BLEND = 11 +HUE_BLEND = 12 +SATURATION_BLEND = 13 +COLOR_BLEND = 14 +LUMINOSITY_BLEND = 15 +MASK_BLEND = 16 +OVERWRITE_BLEND = 17 +SUBTRACT_MASK_BLEND = 18 +EXCLUDE_MASK_BLEND = 19 PaintKind = c_byte -PK_SOLID = 0 -PK_IMAGE = 1 -PK_IMAGE_TILED = 2 -PK_GRADIENT_LINEAR = 3 -PK_GRADIENT_RADIAL = 4 -PK_GRADIENT_ANGULAR = 5 +SOLID_PAINT = 0 +IMAGE_PAINT = 1 +TILED_IMAGE_PAINT = 2 +LINEAR_GRADIENT_PAINT = 3 +RADIAL_GRADIENT_PAINT = 4 +ANGULAR_GRADIENT_PAINT = 5 WindingRule = c_byte -WR_NON_ZERO = 0 -WR_EVEN_ODD = 1 +NON_ZERO = 0 +EVEN_ODD = 1 LineCap = c_byte -LC_BUTT = 0 -LC_ROUND = 1 -LC_SQUARE = 2 +BUTT_CAP = 0 +ROUND_CAP = 1 +SQUARE_CAP = 2 LineJoin = c_byte -LJ_MITER = 0 -LJ_ROUND = 1 -LJ_BEVEL = 2 +MITER_JOIN = 0 +ROUND_JOIN = 1 +BEVEL_JOIN = 2 HorizontalAlignment = c_byte -HA_LEFT = 0 -HA_CENTER = 1 -HA_RIGHT = 2 +LEFT_ALIGN = 0 +CENTER_ALIGN = 1 +RIGHT_ALIGN = 2 VerticalAlignment = c_byte -VA_TOP = 0 -VA_MIDDLE = 1 -VA_BOTTOM = 2 +TOP_ALIGN = 0 +MIDDLE_ALIGN = 1 +BOTTOM_ALIGN = 2 TextCase = c_byte -TC_NORMAL = 0 -TC_UPPER = 1 -TC_LOWER = 2 -TC_TITLE = 3 +NORMAL_CASE = 0 +UPPER_CASE = 1 +LOWER_CASE = 2 +TITLE_CASE = 3 def check_error(): result = dll.pixie_check_error() @@ -213,6 +227,9 @@ def append(self, value): def clear(self): dll.pixie_seq_float32_clear(self) + def __iter__(self): + return SeqIterator(self) + class SeqSpan(Structure): _fields_ = [("ref", c_ulonglong)] @@ -246,7 +263,10 @@ def append(self, value): def clear(self): dll.pixie_seq_span_clear(self) - def typeset(self, bounds = None, h_align = HA_LEFT, v_align = VA_TOP, wrap = True): + def __iter__(self): + return SeqIterator(self) + + def typeset(self, bounds = None, h_align = LEFT_ALIGN, v_align = TOP_ALIGN, wrap = True): """ Lays out the character glyphs and returns the arrangement. Optional parameters: @@ -434,7 +454,7 @@ def super_image(self, x, y, w, h): raise PixieError(take_error()) return result - def draw(self, b, transform = None, blend_mode = BM_NORMAL): + def draw(self, b, transform = None, blend_mode = NORMAL_BLEND): """ Draws one image onto another using matrix with color blending. """ @@ -444,7 +464,7 @@ def draw(self, b, transform = None, blend_mode = BM_NORMAL): 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 = MASK_BLEND): """ Draws a mask onto an image using a matrix with color blending. """ @@ -462,7 +482,7 @@ def fill_gradient(self, paint): if check_error(): raise PixieError(take_error()) - def fill_text(self, font, text, transform = None, bounds = None, h_align = HA_LEFT, v_align = VA_TOP): + def fill_text(self, font, text, transform = None, bounds = None, h_align = LEFT_ALIGN, v_align = TOP_ALIGN): """ Typesets and fills the text. Optional parameters: transform: translation or matrix to apply @@ -488,7 +508,7 @@ def arrangement_fill_text(self, arrangement, transform = None): if check_error(): raise PixieError(take_error()) - 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): + def stroke_text(self, font, text, transform = None, stroke_width = 1.0, bounds = None, h_align = LEFT_ALIGN, v_align = TOP_ALIGN, line_cap = BUTT_CAP, line_join = MITER_JOIN, miter_limit = DEFAULT_MITER_LIMIT, dashes = None): """ Typesets and strokes the text. Optional parameters: transform: translation or matrix to apply @@ -508,7 +528,7 @@ def stroke_text(self, font, text, transform = None, stroke_width = 1.0, bounds = if check_error(): raise PixieError(take_error()) - def arrangement_stroke_text(self, arrangement, transform = None, stroke_width = 1.0, line_cap = LC_BUTT, line_join = LJ_MITER, miter_limit = DEFAULT_MITER_LIMIT, dashes = None): + def arrangement_stroke_text(self, arrangement, transform = None, stroke_width = 1.0, line_cap = BUTT_CAP, line_join = MITER_JOIN, miter_limit = DEFAULT_MITER_LIMIT, dashes = None): """ Strokes the text arrangement. """ @@ -520,7 +540,7 @@ def arrangement_stroke_text(self, arrangement, transform = None, stroke_width = 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 = NON_ZERO): """ Fills a path. """ @@ -530,7 +550,7 @@ def fill_path(self, path, paint, transform = None, winding_rule = WR_NON_ZERO): if check_error(): raise PixieError(take_error()) - def stroke_path(self, path, paint, transform = None, stroke_width = 1.0, line_cap = LC_BUTT, line_join = LJ_MITER, miter_limit = DEFAULT_MITER_LIMIT, dashes = None): + def stroke_path(self, path, paint, transform = None, stroke_width = 1.0, line_cap = BUTT_CAP, line_join = MITER_JOIN, miter_limit = DEFAULT_MITER_LIMIT, dashes = None): """ Strokes a path. """ @@ -677,7 +697,7 @@ def blur(self, radius, out_of_bounds = 0): if check_error(): raise PixieError(take_error()) - def draw(self, b, transform = None, blend_mode = BM_MASK): + def draw(self, b, transform = None, blend_mode = MASK_BLEND): """ Draws a mask onto a mask using a matrix with color blending. """ @@ -687,7 +707,7 @@ def draw(self, b, transform = None, blend_mode = BM_MASK): if check_error(): raise PixieError(take_error()) - def image_draw(self, image, transform = None, blend_mode = BM_MASK): + def image_draw(self, image, transform = None, blend_mode = MASK_BLEND): """ Draws a image onto a mask using a matrix with color blending. """ @@ -697,7 +717,7 @@ def image_draw(self, image, transform = None, blend_mode = BM_MASK): if check_error(): raise PixieError(take_error()) - def fill_text(self, font, text, transform = None, bounds = None, h_align = HA_LEFT, v_align = VA_TOP): + def fill_text(self, font, text, transform = None, bounds = None, h_align = LEFT_ALIGN, v_align = TOP_ALIGN): """ Typesets and fills the text. Optional parameters: transform: translation or matrix to apply @@ -723,7 +743,7 @@ def arrangement_fill_text(self, arrangement, transform = None): if check_error(): raise PixieError(take_error()) - 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): + def stroke_text(self, font, text, transform = None, stroke_width = 1.0, bounds = None, h_align = LEFT_ALIGN, v_align = TOP_ALIGN, line_cap = BUTT_CAP, line_join = MITER_JOIN, miter_limit = DEFAULT_MITER_LIMIT, dashes = None): """ Typesets and strokes the text. Optional parameters: transform: translation or matrix to apply @@ -743,7 +763,7 @@ def stroke_text(self, font, text, transform = None, stroke_width = 1.0, bounds = if check_error(): raise PixieError(take_error()) - def arrangement_stroke_text(self, arrangement, transform = None, stroke_width = 1.0, line_cap = LC_BUTT, line_join = LJ_MITER, miter_limit = DEFAULT_MITER_LIMIT, dashes = None): + def arrangement_stroke_text(self, arrangement, transform = None, stroke_width = 1.0, line_cap = BUTT_CAP, line_join = MITER_JOIN, miter_limit = DEFAULT_MITER_LIMIT, dashes = None): """ Strokes the text arrangement. """ @@ -755,7 +775,7 @@ def arrangement_stroke_text(self, arrangement, transform = None, stroke_width = 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 = NON_ZERO, blend_mode = NORMAL_BLEND): """ Fills a path. """ @@ -765,7 +785,7 @@ def fill_path(self, path, transform = None, winding_rule = WR_NON_ZERO, blend_mo if check_error(): raise PixieError(take_error()) - def stroke_path(self, path, transform = None, stroke_width = 1.0, line_cap = LC_BUTT, line_join = LJ_MITER, miter_limit = DEFAULT_MITER_LIMIT, dashes = None, blend_mode = BM_NORMAL): + def stroke_path(self, path, transform = None, stroke_width = 1.0, line_cap = BUTT_CAP, line_join = MITER_JOIN, miter_limit = DEFAULT_MITER_LIMIT, dashes = None, blend_mode = NORMAL_BLEND): """ Strokes a path. """ @@ -864,6 +884,9 @@ def append(self, value): def clear(self): dll.pixie_paint_gradient_handle_positions_clear(self.paint) + def __iter__(self): + return SeqIterator(self) + @property def gradient_handle_positions(self): return self.PaintGradientHandlePositions(self) @@ -891,6 +914,9 @@ def append(self, value): def clear(self): dll.pixie_paint_gradient_stops_clear(self.paint) + def __iter__(self): + return SeqIterator(self) + @property def gradient_stops(self): return self.PaintGradientStops(self) @@ -949,7 +975,7 @@ def compute_bounds(self, transform = None): raise PixieError(take_error()) return result - def fill_overlaps(self, test, transform = None, winding_rule = WR_NON_ZERO): + def fill_overlaps(self, test, transform = None, winding_rule = NON_ZERO): """ Returns whether or not the specified point is contained in the current path. """ @@ -960,7 +986,7 @@ def fill_overlaps(self, test, transform = None, winding_rule = WR_NON_ZERO): raise PixieError(take_error()) return result - def stroke_overlaps(self, test, transform = None, stroke_width = 1.0, line_cap = LC_BUTT, line_join = LJ_MITER, miter_limit = DEFAULT_MITER_LIMIT, dashes = None): + def stroke_overlaps(self, test, transform = None, stroke_width = 1.0, line_cap = BUTT_CAP, line_join = MITER_JOIN, miter_limit = DEFAULT_MITER_LIMIT, dashes = None): """ Returns whether or not the specified point is inside the area contained by the stroking of a path. @@ -1205,6 +1231,9 @@ def append(self, value): def clear(self): dll.pixie_font_paints_clear(self.font) + def __iter__(self): + return SeqIterator(self) + @property def paints(self): return self.FontPaints(self) @@ -1263,7 +1292,7 @@ def default_line_height(self): result = dll.pixie_font_default_line_height(self) return result - def typeset(self, text, bounds = None, h_align = HA_LEFT, v_align = VA_TOP, wrap = True): + def typeset(self, text, bounds = None, h_align = LEFT_ALIGN, v_align = TOP_ALIGN, wrap = True): """ Lays out the character glyphs and returns the arrangement. Optional parameters: @@ -1484,7 +1513,7 @@ def close_path(self): """ dll.pixie_context_close_path(self) - def fill(self, winding_rule = WR_NON_ZERO): + def fill(self, winding_rule = NON_ZERO): """ Fills the current path with the current fillStyle. """ @@ -1492,7 +1521,7 @@ def fill(self, winding_rule = WR_NON_ZERO): if check_error(): raise PixieError(take_error()) - def path_fill(self, path, winding_rule = WR_NON_ZERO): + def path_fill(self, path, winding_rule = NON_ZERO): """ Fills the path with the current fillStyle. """ @@ -1500,7 +1529,7 @@ def path_fill(self, path, winding_rule = WR_NON_ZERO): if check_error(): raise PixieError(take_error()) - def clip(self, winding_rule = WR_NON_ZERO): + def clip(self, winding_rule = NON_ZERO): """ Turns the current path into the current clipping region. The previous clipping region, if any, is intersected with the current or given path @@ -1510,7 +1539,7 @@ def clip(self, winding_rule = WR_NON_ZERO): if check_error(): raise PixieError(take_error()) - def path_clip(self, path, winding_rule = WR_NON_ZERO): + def path_clip(self, path, winding_rule = NON_ZERO): """ Turns the path into the current clipping region. The previous clipping region, if any, is intersected with the current or given path to create @@ -1746,7 +1775,7 @@ def rotate(self, angle): """ dll.pixie_context_rotate(self, angle) - def is_point_in_path(self, x, y, winding_rule = WR_NON_ZERO): + def is_point_in_path(self, x, y, winding_rule = NON_ZERO): """ Returns whether or not the specified point is contained in the current path. """ @@ -1755,7 +1784,7 @@ def is_point_in_path(self, x, y, winding_rule = WR_NON_ZERO): raise PixieError(take_error()) return result - def path_is_point_in_path(self, path, x, y, winding_rule = WR_NON_ZERO): + def path_is_point_in_path(self, path, x, y, winding_rule = NON_ZERO): """ Returns whether or not the specified point is contained in the current path. """ diff --git a/tests/test_context.py b/tests/test_context.py index 5d892c6..b10cae8 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -3,11 +3,11 @@ def test_fields(): context = pixie.Context(100, 100) assert context.image is not None - fill = pixie.Paint(pixie.PK_SOLID) + fill = pixie.Paint(pixie.SOLID_PAINT) fill.color = pixie.Color(1, 0, 0, 1) context.fill_style = fill assert context.fill_style == fill - stroke = pixie.Paint(pixie.PK_SOLID) + stroke = pixie.Paint(pixie.SOLID_PAINT) stroke.color = pixie.Color(0, 1, 1, 1) context.stroke = stroke assert context.stroke == stroke @@ -17,24 +17,24 @@ def test_fields(): assert context.line_width == 2 context.miter_limit = 2 assert context.miter_limit == 2 - context.line_cap = pixie.LC_ROUND - assert context.line_cap == pixie.LC_ROUND - context.line_join = pixie.LJ_BEVEL - assert context.line_join == pixie.LJ_BEVEL + context.line_cap = pixie.ROUND_CAP + assert context.line_cap == pixie.ROUND_CAP + context.line_join = pixie.BEVEL_JOIN + assert context.line_join == pixie.BEVEL_JOIN context.font = "tests/fonts/Roboto-Regular_1.ttf" assert context.font == "tests/fonts/Roboto-Regular_1.ttf" context.font_size = 18 assert context.font_size == 18 - context.text_align = pixie.HA_CENTER - assert context.text_align == pixie.HA_CENTER + context.text_align = pixie.CENTER_ALIGN + assert context.text_align == pixie.CENTER_ALIGN def test_save_restore(): context = pixie.Context(100, 100) - paint1 = pixie.Paint(pixie.PK_SOLID) + paint1 = pixie.Paint(pixie.SOLID_PAINT) paint1.color = pixie.Color(1, 0, 0, 1) context.fill_style = paint1 context.save() - paint2 = pixie.Paint(pixie.PK_SOLID) + paint2 = pixie.Paint(pixie.SOLID_PAINT) paint2.color = pixie.Color(1, 1, 0, 1) context.fill_style = paint2 context.restore() @@ -66,7 +66,7 @@ def test_transform(): def test_fill(): context = pixie.Context(100, 100) - paint = pixie.Paint(pixie.PK_SOLID) + paint = pixie.Paint(pixie.SOLID_PAINT) paint.color = pixie.Color(1, 0, 0, 1) context.fill_style = paint context.begin_path() @@ -76,7 +76,7 @@ def test_fill(): def test_stroke(): context = pixie.Context(100, 100) - paint = pixie.Paint(pixie.PK_SOLID) + paint = pixie.Paint(pixie.SOLID_PAINT) paint.color = pixie.Color(1, 0, 0, 1) context.stroke_style = paint context.line_width = 10 @@ -88,7 +88,7 @@ def test_stroke(): def test_clip(): context = pixie.Context(100, 100) - paint = pixie.Paint(pixie.PK_SOLID) + paint = pixie.Paint(pixie.SOLID_PAINT) paint.color = pixie.Color(1, 0, 0, 1) context.fill_style = paint context.begin_path() diff --git a/tests/test_font.py b/tests/test_font.py index 5862c8e..696a096 100644 --- a/tests/test_font.py +++ b/tests/test_font.py @@ -7,23 +7,23 @@ def test_fields(): assert font.size == 24 font.line_height = 100 assert font.line_height == 100 - font.text_case = pixie.TC_UPPER - assert font.text_case == pixie.TC_UPPER + font.text_case = pixie.UPPER_CASE + assert font.text_case == pixie.UPPER_CASE font.underline = True assert font.underline font.strikethrough = True assert font.strikethrough font.no_kerning_adjustment = True assert font.no_kerning_adjustment - paint = pixie.Paint(pixie.PK_SOLID) + paint = pixie.Paint(pixie.SOLID_PAINT) paint.color = pixie.Color(1, 1, 0, 1) font.paint = paint assert font.paint.color == paint.color def test_paints(): font = pixie.read_font("tests/fonts/Roboto-Regular_1.ttf") - paint1 = pixie.Paint(pixie.PK_SOLID) - paint2 = pixie.Paint(pixie.PK_GRADIENT_LINEAR) + paint1 = pixie.Paint(pixie.SOLID_PAINT) + paint2 = pixie.Paint(pixie.LINEAR_GRADIENT_PAINT) font.paints[0] = paint1 font.paints.append(paint2) assert len(font.paints) == 2 diff --git a/tests/test_image.py b/tests/test_image.py index ad557c2..1267a96 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -24,7 +24,7 @@ def test_flips(): image = pixie.Image(100, 100) path = pixie.parse_path("M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z") path.polygon(50, 50, 20, 5) - paint = pixie.Paint(pixie.PK_SOLID) + paint = pixie.Paint(pixie.SOLID_PAINT) paint.color = pixie.Color(1, 0, 0, 1) image.fill_path(path, paint) image.flip_vertical() @@ -39,7 +39,7 @@ def test_subsuper(): image = pixie.Image(100, 100) path = pixie.Path() path.rounded_rect(10, 10, 80, 80, 10, 10, 10, 10) - paint = pixie.Paint(pixie.PK_SOLID) + paint = pixie.Paint(pixie.SOLID_PAINT) paint.color = pixie.Color(1, 1, 1, 1) image.fill_path(path, paint) image.sub_image(0, 0, 20, 20).write_file("tests/images/sub_image.png") @@ -61,7 +61,7 @@ def test_paths(): path = pixie.Path() path.rect(25, 25, 50, 50) - paint = pixie.Paint(pixie.PK_SOLID) + paint = pixie.Paint(pixie.SOLID_PAINT) paint.color = pixie.Color(1, 0, 1, 1) fill = pixie.Image(100, 100) @@ -98,7 +98,7 @@ def test_blur(): path = pixie.Path() path.rect(25, 25, 50, 50) - paint = pixie.Paint(pixie.PK_SOLID) + paint = pixie.Paint(pixie.SOLID_PAINT) paint.color = pixie.Color(1, 1, 0, 1) image = pixie.Image(100, 100) @@ -111,14 +111,14 @@ def test_draw(): a = pixie.Image(100, 100) a_path = pixie.Path() a_path.rect(25, 25, 50, 50) - a_paint = pixie.Paint(pixie.PK_SOLID) + a_paint = pixie.Paint(pixie.SOLID_PAINT) a_paint.color = pixie.Color(1, 1, 0, 0.5) a.fill_path(a_path, a_paint) b = pixie.Image(100, 100) b_path = pixie.Path() b_path.rect(0, 0, 100, 50) - b_paint = pixie.Paint(pixie.PK_SOLID) + b_paint = pixie.Paint(pixie.SOLID_PAINT) b_paint.color = pixie.Color(1, 0, 1, 0.5) b.fill_path(b_path, b_paint) @@ -129,7 +129,7 @@ def test_draw_mask(): image = pixie.Image(100, 100) image_path = pixie.Path() image_path.rect(0, 0, 100, 30) - image_paint = pixie.Paint(pixie.PK_SOLID) + image_paint = pixie.Paint(pixie.SOLID_PAINT) image_paint.color = pixie.Color(1, 1, 1, 1) image.fill_path(image_path, image_paint) @@ -145,7 +145,7 @@ def test_shadow(): image = pixie.Image(100, 100) path = pixie.Path() path.rounded_rect(20, 20, 60, 60, 10, 10, 10, 10) - paint = pixie.Paint(pixie.PK_SOLID) + paint = pixie.Paint(pixie.SOLID_PAINT) paint.color = pixie.Color(1, 1, 1, 1) image.fill_path(path, paint) shadow = image.shadow(pixie.Vector2(0, 0), 2, 4, pixie.Color(0, 0, 0, 1)) @@ -166,7 +166,7 @@ def test_text(): stroke.write_file("tests/images/stroke_text.png") def test_fill_gradient(): - paint = pixie.Paint(pixie.PK_GRADIENT_LINEAR) + paint = pixie.Paint(pixie.LINEAR_GRADIENT_PAINT) paint.gradient_handle_positions.append(pixie.Vector2(0, 50)) paint.gradient_handle_positions.append(pixie.Vector2(100, 50)) paint.gradient_stops.append(pixie.ColorStop(pixie.Color(1, 0, 0, 1), 0)) diff --git a/tests/test_mask.py b/tests/test_mask.py index 4685dc1..0626d8d 100644 --- a/tests/test_mask.py +++ b/tests/test_mask.py @@ -109,7 +109,7 @@ def test_draw_image(): image = pixie.Image(100, 100) image_path = pixie.Path() image_path.rect(0, 0, 100, 30) - image_paint = pixie.Paint(pixie.PK_SOLID) + image_paint = pixie.Paint(pixie.SOLID_PAINT) image_paint.color = pixie.Color(1, 1, 1, 1) image.fill_path(image_path, image_paint) diff --git a/tests/test_paint.py b/tests/test_paint.py index 867f1ac..0b59b3d 100644 --- a/tests/test_paint.py +++ b/tests/test_paint.py @@ -1,12 +1,12 @@ import pixie def test_basic_fields(): - paint = pixie.Paint(pixie.PK_SOLID) - assert paint.kind == pixie.PK_SOLID - paint.kind = pixie.PK_IMAGE - assert paint.kind == pixie.PK_IMAGE - paint.blend_mode = pixie.BM_MULTIPLY - assert paint.blend_mode == pixie.BM_MULTIPLY + paint = pixie.Paint(pixie.SOLID_PAINT) + assert paint.kind == pixie.SOLID_PAINT + paint.kind = pixie.IMAGE_PAINT + assert paint.kind == pixie.IMAGE_PAINT + paint.blend_mode = pixie.MULTIPLY_BLEND + assert paint.blend_mode == pixie.MULTIPLY_BLEND paint.opacity = 0.5 assert paint.opacity == 0.5 paint.color = pixie.Color(1, 0, 0, 1) @@ -21,7 +21,7 @@ def test_basic_fields(): assert paint2 != paint def test_seq_fields(): - paint = pixie.Paint(pixie.PK_GRADIENT_LINEAR) + paint = pixie.Paint(pixie.LINEAR_GRADIENT_PAINT) paint.gradient_handle_positions.append(pixie.Vector2(100, 100)) paint.gradient_handle_positions.append(pixie.Vector2(200, 200))