Skip to main content

SVG Domain Specific Language Compiler - Core Engine

Project description

SVGLang Core

A domain-specific language (DSL) for generating SVG graphics with a focus on simplicity and expressiveness.

Installation

pip install svglang-core

Quick Start

from svglang import compile_svgl

# Compile SVGLang code to SVG
code = """
canvas width 400 height 300 background "lightblue"

let radius = 50
let center_x = 200
let center_y = 150

circle radius radius at (center_x, center_y) fill "red"
"""

svg_output = compile_svgl(code)
print(svg_output)

Command Line Usage

After installation, you can use the svglang command:

# Compile a .svgl file to SVG
svglang my_drawing.svgl

# Output to specific file
svglang input.svgl --output output.svg

Language Features

  • Simple Syntax: Clean, declarative syntax for SVG creation
  • String Interpolation: Use variables with {variable} syntax
  • Canvas Properties: Set dimensions, viewBox, and styling
  • Shapes: Rectangles, circles, ellipses, lines, polygons
  • Animations: Built-in animation support
  • Gradients: Linear and radial gradients
  • Control Flow: Loops, conditionals, and functions

Example

canvas width 400 height 300 background "lightblue"

let radius = 50
let center_x = 200
let center_y = 150

circle radius radius at (center_x, center_y) fill "red"

# Animation
circle radius radius at (center_x, center_y) fill "red" animate {
    x from 0 to 100 duration 2s repeat once direction normal
}

Documentation

For complete language documentation and examples, visit: https://github.com/SVGLang/svglang

License

MIT License - see LICENSE file for details.

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

svglang_core-0.1.0.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

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

svglang_core-0.1.0-py3-none-any.whl (32.4 kB view details)

Uploaded Python 3

File details

Details for the file svglang_core-0.1.0.tar.gz.

File metadata

  • Download URL: svglang_core-0.1.0.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.16

File hashes

Hashes for svglang_core-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e7b74c06906c91eabc6ba3fb47f210df6878483e1f22f508e1417a0482457382
MD5 fd9ef289d09f4a020d3df18839207270
BLAKE2b-256 443ba35abee33eb6706c538f845af6ee03eb5fea54e6efdb96a440510510d8b2

See more details on using hashes here.

File details

Details for the file svglang_core-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: svglang_core-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.16

File hashes

Hashes for svglang_core-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3389f78b9e7e79e83314c17748ac3e858df334c22d5f812a02524e53775e93a4
MD5 acc408d8c355f988c373ed0d1fcdb002
BLAKE2b-256 7426d54e69bbd5a4b8e2e9ac4873e4d906abf01f8f1bd0329ec8cb05c90826de

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