Skip to main content

LineDream is a generative art library for Python. It is heavily influenced by P5 and Processing. However, it takes a more object oriented approach, with less global state in regards to styling and transformations.

The current output target is SVG. As this provides a robust output set for vector graphics. There is not yet support for a draw loop - it is single frame output, but you could use a loop to simulate this. There are future plans to implement an OpenGL render window.

LineDream library was originally created to make art for a pen plotter, however, the inner object structure could be applied to many different rendering platforms.

Installation

pip install LineDream

Documentation

https://linedream.marcrleonard.com/documentation/

Example

import random
from LineDream import Line, Canvas, Rectangle, Square, Ellipse, Point, Circle, CircleMath, TextLine

Canvas.width=900
Canvas.height=500
Canvas.background_color='black'

for pp in range(100):
	x = random.randint(0, Canvas.width)
	y = random.randint(0, 400)

	coords = (x,y)
	p = Point(*coords)

	p.stroke_color= 'white'

c_size = 180

circle_center = Canvas.width/2, Canvas.height+c_size/2
c = Circle(*circle_center, 180)
c.stroke_color='white'

c = Circle(*circle_center, 200)
c.stroke_color='white'

c = Circle(*circle_center, 220)
c.stroke_color='white'

long=True
for degrees in range(360,180,-10):

	dist_from_circle = 250

	line_len = 40
	if long:
		line_len = 100
		long=False
	else:
		long=True

	d_x_s, d_y_s = CircleMath.distance_to_coords(degrees, dist_from_circle)
	x1 = circle_center[0] + d_x_s
	y1 = circle_center[1] + d_y_s

	d_x, d_y = CircleMath.distance_to_coords(degrees, dist_from_circle + line_len)
	x2 = circle_center[0] + d_x
	y2 = circle_center[1] + d_y

	Line([(x1,y1), (x2,y2)], stroke_color='white')

# EXPERIMENTAL
tt = TextLine('LineDream', kerning=10, stroke_color='white', stroke_width=2)
tt.transform(100, 100)
tt.scale(1.4)

Canvas.save(f'example.svg')

Custom LineDream Shapes

import math
from LineDream.primitives.BaseShape import BaseShape

class Hexagon(BaseShape):

    def __init__(self, c_x, c_y, radius, **kwargs):
        super().__init__(_close_path=True, **kwargs)

        num_points = 6

        # Calculate the angle between each point
        angle_step = 2 * math.pi / num_points

        for i in range(num_points):
            angle = i * angle_step
            x = c_x + radius * math.cos(angle)
            y = c_y + radius * math.sin(angle)
            self.add_vertex(x, y)


if __name__ == "__main__":
    from LineDream import Canvas

    Canvas.width=356
    Canvas.height=276
    Canvas.units = "mm"
    Canvas.background_color = "beige"

    # Add a Hexagon in the middle of canvas with a radius of 50
    Hexagon(Canvas.width/2, Canvas.height/2, 50, )

    Canvas.save('', open_viewer=True)

Todos:

  • Better document colors/opacity/styles for the SVG
  • Add 'tag' notion for lines
  • Add Group to the example

Development

Installation for Development

# Clone the repository
git clone https://github.com/marcrleonard/LineDream.git
cd LineDream

# Install in editable mode with dev dependencies
pip install -e ".[dev]"

Running Tests

# Run tests locally
pytest

# Run tests with verbose output
pytest tests/ -v

# Run tests across multiple Python versions (3.9, 3.10, 3.11, 3.12)
tox

# Run tests with coverage report
tox -e coverage

Building and Publishing

# Build the package
python -m build

# Upload to PyPI (requires twine and PyPI credentials)
twine upload dist/*

# Or upload to TestPyPI first
twine upload --repository testpypi dist/*

Project Structure

All package metadata and dependencies are defined in pyproject.toml following modern Python packaging standards (PEP 517/518).

Release files for LineDream 0.3.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for LineDream 0.3.15
File Size Uploaded
linedream-0.3.15.tar.gz 256.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for LineDream 0.3.15
File Interpreter ABI Platform
linedream-0.3.15-py3-none-any.whl Python 3 none any Details

Total release size: 527.6 kB

Release files / linedream-0.3.15.tar.gz

Download URL linedream-0.3.15.tar.gz
Size 256.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f9e539472107a337d154add25c4e5cb16e2102a640d7f168ab68280cb6b13ac0
BLAKE2b-256 checksum
How to use checksums
a3a49ab29bd9d92554a8e7c7ec40b18f35a9daaf1c0b690aa846f7fe0028145a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release files / linedream-0.3.15-py3-none-any.whl

Download URL linedream-0.3.15-py3-none-any.whl
Size 271.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a37f01d47ab879df9d095807325e917a1923a1dd2a7802935b8d346bc87b208
BLAKE2b-256 checksum
How to use checksums
06c26f796459c3e6784b032595efc139590c9bb177978129ac90973993b5fcb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

0.3.15 This release

2 release files

0.3.10

2 release files

0.3.0

2 release files

0.2.12

2 release files

0.2.11

2 release files

0.2.10

2 release files

0.2.0

2 release files

0.1.12

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page