A creative coding library...
Project description
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
Internal
To push to PyPI run:
python setup.py upload
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file LineDream-0.3.14.tar.gz
.
File metadata
- Download URL: LineDream-0.3.14.tar.gz
- Upload date:
- Size: 256.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.28.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97001f1ed3250c8916ea116c31263f18cf0df8528b27394848c1837692dab064 |
|
MD5 | df7a64bc7020345babe83b974db8133c |
|
BLAKE2b-256 | 0e6b596178d3b18223d4bfe7cca78bb0506d054ba0235af12ccdfc1c8e6587a3 |
File details
Details for the file LineDream-0.3.14-py2.py3-none-any.whl
.
File metadata
- Download URL: LineDream-0.3.14-py2.py3-none-any.whl
- Upload date:
- Size: 271.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.28.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef0008d5c8823734812d240d4cd8b3e9ca12ae8e88b06aa285808f2bc816dfd2 |
|
MD5 | ded20ab282301043a4d1b23dcdab8084 |
|
BLAKE2b-256 | 82ffb6598ba83f900b2ec31f030a3ebce45bccbd75816ae619941cbca0cd94ee |