Skip to main content

Python bindings to the Vexy Lines MCP API and style engine

Project description

vexy-lines-apy

Python bindings to the Vexy Lines MCP API and style engine.

Connect to the Vexy Lines app over TCP, drive it programmatically — open documents, tweak fill parameters, render, export — and transfer or blend artistic styles between images without touching the GUI.

Requires the Vexy Lines app (macOS or Windows) for all MCP operations. The app auto-launches if it isn't running.

Install

pip install vexy-lines-apy

For SVG object manipulation (svg_parsed()), install svglab separately:

pip install svglab

Quick start

from vexy_lines_api import MCPClient

with MCPClient() as vl:
    vl.open_document("photo.lines")

    info = vl.get_document_info()
    print(f"{info.width_mm:.0f} x {info.height_mm:.0f} mm @ {info.resolution} dpi")

    tree = vl.get_layer_tree()          # LayerNode tree
    vl.render()                          # render all layers, wait for completion
    vl.export_svg("output.svg")

MCPClient() connects to localhost:47384. If the app isn't open, it launches it and waits up to 30 seconds.

Export formats

with MCPClient() as vl:
    vl.open_document("art.lines")
    vl.render()

    vl.export_svg("out.svg")
    vl.export_pdf("out.pdf")
    vl.export_png("out.png", dpi=150)
    vl.export_jpeg("out.jpg")
    vl.export_eps("out.eps")

    # SVG as a string (useful for embedding or piping)
    svg_text = vl.svg()

    # SVG as a parsed svglab object (requires svglab)
    svg_obj = vl.svg_parsed()

Edit fill parameters

with MCPClient() as vl:
    vl.open_document("art.lines")
    tree = vl.get_layer_tree()

    # Find a fill node and change its colour
    fill_id = tree.children[0].children[0].children[0].id
    vl.set_fill_params(fill_id, color="#3a7bd5", opacity=0.9)

    vl.render()
    vl.export_png("result.png")

Style engine

Extract the complete fill structure from a .lines file and apply it to any source image — no GUI required.

from vexy_lines_api import MCPClient, extract_style, apply_style

style = extract_style("reference.lines")   # parse fill tree from file

with MCPClient() as vl:
    svg = apply_style(vl, style, "photo.jpg", dpi=72)

with open("result.svg", "w") as f:
    f.write(svg)

Style interpolation

Blend two compatible styles at any mix ratio. Numeric fill parameters and colours interpolate smoothly.

from vexy_lines_api import MCPClient, extract_style, interpolate_style, apply_style

painterly = extract_style("painterly.lines")
technical = extract_style("technical.lines")

mid = interpolate_style(painterly, technical, t=0.5)   # halfway blend

with MCPClient() as vl:
    svg = apply_style(vl, mid, "photo.jpg")

Two styles are compatible for interpolation when they share the same group/layer/fill structure with matching fill types. Check with styles_compatible(a, b) before blending.

API reference

Document

Method Description
new_document(width, height, dpi, source_image) Create a new document
open_document(path) Open a .lines file
save_document(path) Save (or Save As)
export_document(path, format, dpi) Export to svg/pdf/png/jpg/eps
get_document_info() Returns DocumentInfo

Structure

Method Description
get_layer_tree() Returns root LayerNode
add_group(parent_id, caption) Add a group
add_layer(group_id) Add a layer to a group
add_fill(layer_id, fill_type, color, params) Add a fill to a layer
delete_object(object_id) Delete any object

Fill parameters

Method Description
get_fill_params(fill_id) Get all params as a dict
set_fill_params(fill_id, **params) Set params by keyword

Visual

Method Description
set_source_image(image_path, group_id) Set source image for a group
set_caption(object_id, caption) Rename an object
set_visible(object_id, visible) Toggle visibility
set_layer_mask(layer_id, paths, mode) Set SVG vector mask
get_layer_mask(layer_id) Get layer mask data
transform_layer(layer_id, ...) Translate, rotate, scale
set_layer_warp(layer_id, ...) Perspective warp corners

Control

Method Description
render() Render all layers and wait
render_all() Trigger render (no wait)
wait_for_render(timeout) Poll until render completes
get_render_status() Returns RenderStatus
undo() / redo() Undo/redo last action
get_selection() Get selected objects
select_object(object_id) Select by ID

Export shortcuts

Method Returns
export_svg(path, dpi) Resolved Path
export_pdf(path, dpi) Resolved Path
export_png(path, dpi) Resolved Path
export_jpeg(path, dpi) Resolved Path
export_eps(path, dpi) Resolved Path
svg() SVG content as str
svg_parsed() svglab.Svg object (requires svglab)

Style engine

Function Description
extract_style(path) Parse a .lines file into a Style
apply_style(client, style, source_image, dpi) Apply style to an image, return SVG string
interpolate_style(a, b, t) Blend two styles at ratio t in [0, 1]
styles_compatible(a, b) Check if two styles can be interpolated

Types

DocumentInfo, LayerNode, NewDocumentResult, RenderStatus, Style

Dependencies

Full documentation

Read the docs for the complete API reference, style engine guide, MCP protocol specification, and more examples.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vexy_lines_apy-1.0.23.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vexy_lines_apy-1.0.23-py3-none-any.whl (43.0 kB view details)

Uploaded Python 3

File details

Details for the file vexy_lines_apy-1.0.23.tar.gz.

File metadata

  • Download URL: vexy_lines_apy-1.0.23.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for vexy_lines_apy-1.0.23.tar.gz
Algorithm Hash digest
SHA256 d8fc813deaab826f551475f9aca39de714087e294db86bdbbb74da2aae23a788
MD5 8610ad918ed5fbb028ec4ddbe2bf2d23
BLAKE2b-256 8b18e4a61e4429b512ccf3d0de9f0425211665765ea2347bf494e6663ada660f

See more details on using hashes here.

File details

Details for the file vexy_lines_apy-1.0.23-py3-none-any.whl.

File metadata

  • Download URL: vexy_lines_apy-1.0.23-py3-none-any.whl
  • Upload date:
  • Size: 43.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for vexy_lines_apy-1.0.23-py3-none-any.whl
Algorithm Hash digest
SHA256 3bbb21d09680b783a039cac08c4fb86d3a416b14831c7b8564d1a32f47e40f12
MD5 7f7e224fda8d1f96992b3a109203ade8
BLAKE2b-256 ff3d2ed12f5d2ac10beb7dbd79f258c9081a2e36d2942a6b8c83a6b5968fa1a5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page