Fix line rendering

This commit is contained in:
jaseg 2023-07-20 16:56:20 +02:00
parent bdbdf7f586
commit 60674ab5b3
3 changed files with 8 additions and 9 deletions

View file

@ -96,7 +96,7 @@ class Stroke:
class Dasher:
def __init__(self, obj):
if obj.stroke:
w, t = obj.stroke.width, obj.stroke.type
w, t = obj.stroke.width or 0.254, obj.stroke.type
else:
w = obj.width or 0
t = Atom.solid
@ -150,7 +150,6 @@ class Dasher:
for length, stroked in cycle(zip(self.pattern, cycle([True, False]))):
length = max(1e-12, length)
import sys
while length > 0:
if segment_remaining == 0:
try:
@ -312,7 +311,7 @@ class TextMixin:
def to_svg(self, color='black'):
d = ' '.join(self.svg_path_data())
yield Tag('path', d=d, fill='none', stroke=color, stroke_width=f'{self.line_width:.3f}')
yield Tag('path', d=d, fill='none', stroke=color, stroke_width=f'{self.line_width:.3f}', stroke_linecap='round')
def render(self, variables={}):
if not self.effects or self.effects.hide or not self.effects.font:

View file

@ -110,10 +110,10 @@ def _polyline_svg(self, default_color):
if len(self.points.xy) < 2:
warnings.warn(f'Schematic {type(self)} with less than two points')
x0, y0, *rest = self.points.xy
da.move(x0, y0)
for xn, yn in rest:
da.line(xn, yn)
p0, *rest = self.points.xy
da.move(p0.x, p0.y)
for pn in rest:
da.line(pn.x, pn.y)
return da.svg(stroke=self.stroke.svg_color(default_color))

View file

@ -99,7 +99,7 @@ class Pin:
x1, y1 = self.at.x, self.at.y
x2, y2 = x1+self.length, y1
xform = {'transform': f'rotate({-self.at.rotation} {x1} {y1})'}
style = {'stroke_width': 0.254, 'stroke': colorscheme.lines}
style = {'stroke_width': 0.254, 'stroke': colorscheme.lines, 'stroke_linecap': 'round'}
yield Tag('path', **xform, **style, d=f'M {x1:.6f} {y1:.6f} L {x2:.6f} {y2:.6f}')
@ -171,7 +171,7 @@ class Pin:
x, y = x+self.at.x, y+self.at.y
points.append(f'{x:.3f} {y:.3f}')
d.append('M '+ ' L '.join(points) + ' ')
yield Tag('path', d=d, fill='none', stroke=colorscheme.text, stroke_width='0.254')
yield Tag('path', d=d, fill='none', stroke=colorscheme.text, stroke_width='0.254', stroke_linecap='round')
@sexp_type('fill')