summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml20
-rw-r--r--gerbonara/cad/kicad/base_types.py45
-rw-r--r--setup.py5
3 files changed, 40 insertions, 30 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7a35f14..c47d156 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -58,26 +58,6 @@ test:ubuntu2204:
paths:
- gerbonara_test_failures/*
-test:ubuntu2004:
- stage: test
- image: "registry.gitlab.com/gerbolyze/build-containers/ubuntu:20.04"
- script:
- - python3 -m pip install pytest beautifulsoup4 pillow numpy slugify lxml click scipy
- - python3 -m pytest -o 'testpaths=gerbonara/tests' -o 'norecursedirs=*'
- dependencies:
- - build:archlinux
- cache:
- key: test-image-cache
- paths:
- - gerbonara/tests/image_cache/*.svg
- - gerbonara/tests/image_cache/*.png
- artifacts:
- name: "gerbolyze-$CI_COMMIT_REF_NAME-gerbonara"
- when: on_failure
- paths:
- - gerbonara_test_failures/*
-
-
docs:archlinux:
stage: test
image: "registry.gitlab.com/gerbolyze/build-containers/archlinux:latest"
diff --git a/gerbonara/cad/kicad/base_types.py b/gerbonara/cad/kicad/base_types.py
index 840b9d5..54437f5 100644
--- a/gerbonara/cad/kicad/base_types.py
+++ b/gerbonara/cad/kicad/base_types.py
@@ -5,6 +5,8 @@ import time
from dataclasses import field
import math
import uuid
+from contextlib import contextmanager
+from itertools import cycle
@sexp_type('color')
@@ -20,14 +22,43 @@ class Stroke:
width: Named(float) = 0.254
type: Named(AtomChoice(Atom.dash, Atom.dot, Atom.dash_dot_dot, Atom.dash_dot, Atom.default, Atom.solid)) = Atom.default
color: Color = None
+
+
+class Dasher:
+ def __init__(self, stroke):
+ self.width = stroke.width
+ gap = 4*stroke.width
+ dot = 0
+ gap = 11*stroke.width
+ self.pattern = {
+ Atom.dash: [dash, gap],
+ Atom.dot: [dot, gap],
+ Atom.dash_dot_dot: [dash, gap, dot, gap, dot, gap],
+ Atom.dash_dot: [dash, gap, dot, gap],
+ Atom.default: [1e99],
+ Atom.solid: [1e99]}[stroke.type]
+ self.start_x, self.start_y = None, None
+ self.cur_x, self.cur_y = None, None
+ self.segments = []
+
+ def move(self, x, y):
+ self.start_x, self.start_y = x, y
+
+ def line(x, y):
+ if x is None or y is None:
+ raise ValueError('line() called before move()')
+ self.segments.append((self.cur_x, self.cur_y, x, y))
+ cur_x, cur_y = x, y
+
+ def close():
+ self.segments.append((self.cur_x, self.cur_y, start_x, start_y))
+
+ def __iter__(self):
+ offset = 0
+ for length, stroked in cycle(zip(self.pattern, cycle([True, False]))):
+ for x1, y1, x2, y2 in segments:
+ segment_length = math.dist((x1, y1), (x2, y2))
- @property
- def width_mil(self):
- return mm_to_mil(self.width)
-
- @width_mil.setter
- def width_mil(self, value):
- self.width = mil_to_mm(value)
@sexp_type('xy')
diff --git a/setup.py b/setup.py
index b6e2172..8af6447 100644
--- a/setup.py
+++ b/setup.py
@@ -49,9 +49,8 @@ setup(
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
- 'Programming Language :: Python :: 3.8',
- 'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
+ 'Programming Language :: Python :: 3.11',
'Topic :: Artistic Software',
'Topic :: Multimedia :: Graphics',
'Topic :: Printing',
@@ -62,5 +61,5 @@ setup(
'Typing :: Typed',
],
keywords='gerber excellon pcb',
- python_requires='>=3.8',
+ python_requires='>=3.10',
)