Package: pixie-python
Pixie - A full-featured 2D graphics library for PythonPixieis a 2D graphics library similar toCairoandSkia.pip install pixie-pythonFeatures:Typesetting and rasterizing text, including styled rich text via spans.Drawing paths, shapes and curves with even-odd and non-zero windings.Pixel-perfect AA quality.Supported file formats are PNG, BMP, JPG, SVG + more in development.Strokes with joins and caps.Shadows, glows and blurs.Complex masking: Subtract, Intersect, Exclude.Complex blends: Darken, Multiply, Color Dodge, Hue, Luminosity... etc.Many operations are SIMD accelerated.Image file formatsFormatReadWritePNG✅✅JPEG✅BMP✅✅GIF✅SVG✅Font file formatsFormatReadTTF✅OTF✅SVG✅Joins and capsSupported Caps:ButtRoundSquareSupported Joins:Miter (with miter angle limit)BevelRoundBlending & maskingSupported Blend Modes:NormalDarkenMultiplyColorBurnLightenScreenColor DodgeOverlaySoft LightHard LightDifferenceExclusionHueSaturationColorLuminositySupported Mask Modes:MaskOverwriteSubtract MaskIntersect MaskExclude MaskSVG style paths:FormatSupportedDescriptionM m✅move toL l✅line toh h✅horizontal line toV v✅vertical line toC c S s✅cublic toQ q T t✅quadratic toA a✅arc toz✅close pathTestingpytestExamplesgit clone https://github.com/treeform/pixie-pythonto run examples.Textpythonexamples/text.pyfont=pixie.read_font("examples/data/Roboto-Regular_1.ttf")font.size=20text="Typesetting is the arrangement and composition of text in graphic design and publishing in both digital and traditional medias."image.fill_text(font,text,bounds=pixie.Vector2(180,180),transform=pixie.translate(10,10))Text spanspythonexamples/text_spans.pytypeface=pixie.read_typeface("examples/data/Ubuntu-Regular_1.ttf")defmake_font(typeface,size,color):font=typeface.new_font()font.size=sizefont.paint.color=colorreturnfontspans=pixie.SeqSpan()spans.append(pixie.Span("verb [with object] ",make_font(typeface,12,pixie.Color(0.78125,0.78125,0.78125,1))))spans.append(pixie.Span("strallow\n",make_font(typeface,36,pixie.Color(0,0,0,1))))spans.append(pixie.Span("\nstral·low\n",make_font(typeface,13,pixie.Color(0,0.5,0.953125,1))))spans.append(pixie.Span("\n1. free (something) from restrictive restrictions\"the regulations are intended to strallow changes in public policy\"",make_font(typeface,14,pixie.Color(0.3125,0.3125,0.3125,1))))image.arrangement_fill_text(spans.typeset(bounds=pixie.Vector2(180,180)),transform=pixie.translate(10,10))Squarepythonexamples/square.pypaint=pixie.Paint(pixie.PK_SOLID)paint.color=pixie.Color(1,0,0,1)ctx=image.new_context()ctx.fill_style=paintctx.fill_rect(50,50,100,100)Linepythonexamples/line.pypaint=pixie.Paint(pixie.PK_SOLID)paint.color=pixie.parse_color("#FF5C00")ctx=image.new_context()ctx.stroke_style=paintctx.line_width=10ctx.stroke_segment(25,25,175,175)Rounded rectanglepythonexamples/rounded_rectangle.pypaint=pixie.Paint(pixie.PK_SOLID)paint.color=pixie.Color(0,1,0,1)ctx=image.new_context()ctx.fill_style=paintctx.rounded_rect(50,50,100,100,25,25,25,25)ctx.fill()Heartpythonexamples/heart.pypath=pixie.parse_path("""M 20 60A 40 40 90 0 1 100 60A 40 40 90 0 1 180 60Q 180 120 100 180Q 20 120 20 60z""")paint=pixie.Paint(pixie.PK_SOLID)paint.color=pixie.parse_color("#FC427B")image.fill_path(path,paint)Maskingpythonexamples/masking.pylines=pixie.Image(200,200)lines.fill(pixie.parse_color("#FC427B"))paint=pixie.Paint(pixie.PK_SOLID)paint.color=pixie.parse_color("#F8D1DD")ctx=lines.new_context()ctx.stroke_style=paintctx.line_width=30ctx.stroke_segment(25,25,175,175)ctx.stroke_segment(25,175,175,25)path=pixie.parse_path("""M 20 60A 40 40 90 0 1 100 60A 40 40 90 0 1 180 60Q 180 120 100 180Q 20 120 20 60z""")mask=pixie.Mask(200,200)mask.fill_path(path)lines.mask_draw(mask)image.draw(lines)Gradientpythonexamples/gradient.pypaint=pixie.Paint(pixie.PK_GRADIENT_RADIAL)paint.gradient_handle_positions.append(pixie.Vector2(100,100))paint.gradient_handle_positions.append(pixie.Vector2(200,100))paint.gradient_handle_positions.append(pixie.Vector2(100,200))paint.gradient_stops.append(pixie.ColorStop(pixie.Color(1,0,0,1),0))paint.gradient_stops.append(pixie.ColorStop(pixie.Color(1,0,0,0.15625),1))path=pixie.parse_path("""M 20 60A 40 40 90 0 1 100 60A 40 40 90 0 1 180 60Q 180 120 100 180Q 20 120 20 60z""")image.fill_path(path,paint)Image tiledpythonexamples/image_tiled.pypath=pixie.Path()path.polygon(100,100,70,8)paint=pixie.Paint(pixie.PK_IMAGE_TILED)paint.image=pixie.read_image("examples/data/baboon.png")paint.image_mat=pixie.scale(0.08,0.08)image.fill_path(path,paint)Shadowpythonexamples/shadow.pypath=pixie.Path()path.polygon(100,100,70,sides=8)paint=pixie.Paint(pixie.PK_SOLID)paint.color=pixie.Color(1,1,1,1)polygon_image=pixie.Image(200,200)polygon_image.fill_path(path,paint)shadow=polygon_image.shadow(offset=pixie.Vector2(2,2),spread=2,blur=10,color=pixie.Color(0,0,0,0.78125))image.draw(shadow)image.draw(polygon_image)Blurpythonexamples/blur.pytrees=pixie.read_image("examples/data/trees.png")path=pixie.Path()path.polygon(100,100,70,6)mask=pixie.Mask(200,200)mask.fill_path(path)blur=trees.copy()blur.blur(20)blur.mask_draw(mask)image.draw(trees)image.draw(blur)Tigerpythonexamples/tiger.pytiger=pixie.read_image("examples/data/tiger.svg")image.draw(tiger,pixie.translate(100,100)*pixie.scale(0.2,0.2)*pixie.translate(-450,-450))