WIP
This commit is contained in:
parent
91b99a0452
commit
8cb91dabdb
2 changed files with 28 additions and 37 deletions
|
|
@ -104,8 +104,6 @@ class Pin:
|
|||
if self.hide:
|
||||
return
|
||||
|
||||
if self.name.value in ('PA3', 'QA'):
|
||||
print(self.name.value, self.at, p_rotation)
|
||||
psx, psy = (-1 if p_mirror.x else 1), (-1 if p_mirror.y else 1)
|
||||
x1, y1 = self.at.x, self.at.y
|
||||
x2, y2 = self.at.x+self.length, self.at.y
|
||||
|
|
@ -113,7 +111,6 @@ class Pin:
|
|||
style = {'stroke_width': 0.254, 'stroke': colorscheme.lines, 'stroke_linecap': 'round'}
|
||||
|
||||
yield Tag('path', **xform, **style, d=f'M 0 0 L {self.length:.3f} 0')
|
||||
return
|
||||
|
||||
eps = 1
|
||||
for tag in {
|
||||
|
|
@ -142,17 +139,23 @@ class Pin:
|
|||
}.get(self.style, []):
|
||||
yield tag
|
||||
|
||||
rot = self.at.rotation + p_rotation
|
||||
trot = self.at.rotation
|
||||
h_align = 'left'
|
||||
|
||||
font = Newstroke.load()
|
||||
if self.name.value != '~' and not self.unit.symbol.pin_names.hide:
|
||||
yield font.render_svg(self.name.value,
|
||||
size=self.name.effects.font.size.y or 1.27,
|
||||
x0=self.length + 0.2,
|
||||
y0=0,
|
||||
h_align='left',
|
||||
h_align=h_align,
|
||||
v_align='middle',
|
||||
rotation=self.at.rotation,
|
||||
rotation=trot,
|
||||
stroke=colorscheme.text,
|
||||
transform=f'translate({self.at.x:.3f} {self.at.y:.3f})',
|
||||
scale = (1, -1) if p_mirror.x or p_mirror.y else (1, -1),
|
||||
mirror=(p_mirror.x, p_mirror.y),
|
||||
)
|
||||
|
||||
if self.number.value != '~' and not self.unit.symbol.pin_numbers.hide:
|
||||
|
|
@ -162,7 +165,7 @@ class Pin:
|
|||
y0=0.4,
|
||||
h_align='right',
|
||||
v_align='bottom',
|
||||
rotation=self.at.rotation,
|
||||
rotation=trot,
|
||||
stroke=colorscheme.text,
|
||||
transform=f'translate({self.at.x:.3f} {self.at.y:.3f})',
|
||||
)
|
||||
|
|
|
|||
|
|
@ -45,31 +45,27 @@ class Newstroke:
|
|||
h_align = {'left': 'right', 'right': 'left'}.get(h_align, h_align)
|
||||
x0, y0 = -x0, y0
|
||||
|
||||
if scale == (1, 1) and rotation == 90:
|
||||
rotation = 270
|
||||
h_align = {'left': 'right', 'right': 'left'}.get(h_align, h_align)
|
||||
v_align = {'top': 'bottom', 'bottom': 'top'}.get(v_align, v_align)
|
||||
|
||||
#if mx:
|
||||
# x0 = -x0
|
||||
# if rotation == 90:
|
||||
# v_align = {'top': 'bottom', 'bottom': 'top'}.get(v_align, v_align)
|
||||
# else:
|
||||
# h_align = {'left': 'right', 'right': 'left'}.get(h_align, h_align)
|
||||
|
||||
if my:
|
||||
y0 = -y0
|
||||
if rotation == 0:
|
||||
v_align = {'top': 'bottom', 'bottom': 'top'}.get(v_align, v_align)
|
||||
else:
|
||||
h_align = {'left': 'right', 'right': 'left'}.get(h_align, h_align)
|
||||
# if mx:
|
||||
# y0 = -y0
|
||||
# if rotation == 0:
|
||||
# v_align = {'top': 'bottom', 'bottom': 'top'}.get(v_align, v_align)
|
||||
# else:
|
||||
# h_align = {'left': 'right', 'right': 'left'}.get(h_align, h_align)
|
||||
|
||||
x0, y0 = rotate_point(x0, y0, math.radians(-rotation))
|
||||
|
||||
alx, aly = 0, 0
|
||||
(minx, miny), (maxx, maxy) = bbox = self.bounding_box(text, size, space_width, char_gap)
|
||||
w = maxx - minx
|
||||
|
||||
if my:
|
||||
if rotation == 0:
|
||||
sx = -1
|
||||
h_align = {'left': 'right', 'right': 'left'}.get(h_align, h_align)
|
||||
else:
|
||||
sy = -sy
|
||||
|
||||
if h_align != 'left':
|
||||
(minx, miny), (maxx, maxy) = bbox = self.bounding_box(text, size, space_width, char_gap)
|
||||
w = maxx - minx
|
||||
if h_align == 'right':
|
||||
alx = -w
|
||||
elif h_align == 'center':
|
||||
|
|
@ -86,16 +82,16 @@ class Newstroke:
|
|||
|
||||
for c in text:
|
||||
if c == ' ':
|
||||
x += space_width*size
|
||||
x += space_width
|
||||
continue
|
||||
|
||||
width, strokes = self.glyphs.get(c, missing_glyph)
|
||||
glyph_w = max(width, max(x for st in strokes for x, _y in st))
|
||||
|
||||
for st in strokes:
|
||||
yield self.transform_stroke(st, translate=(x0, y0), offset=(x+alx, aly), rotation=math.radians(-rotation), scale=(sx*size, sy*size))
|
||||
yield [rotate_point((px+x)*sx*size+alx+x0, py*sy*size+aly+y0, math.radians(-rotation), x0, y0) for px, py in st]
|
||||
|
||||
x += glyph_w*size
|
||||
x += glyph_w
|
||||
|
||||
def render_svg(self, text, size=1.0, x0=0, y0=0, rotation=0, h_align='left', v_align='bottom', space_width=DEFAULT_SPACE_WIDTH, char_gap=DEFAULT_CHAR_GAP, scale=(1, -1), mirror=(False, False), **svg_attrs):
|
||||
if 'stroke_linecap' not in svg_attrs:
|
||||
|
|
@ -127,14 +123,6 @@ class Newstroke:
|
|||
|
||||
return (0, -0.2*size), (x, 1.2*size)
|
||||
|
||||
@classmethod
|
||||
def transform_stroke(kls, stroke, translate, offset, scale, rotation=0):
|
||||
x0, y0 = translate
|
||||
sx, sy = scale
|
||||
dx, dy = offset
|
||||
return [rotate_point(x*sx+dx+x0, y*sy+dy+y0, rotation, x0, y0) for x, y in stroke]
|
||||
|
||||
|
||||
def load_font(self, newstroke_cpp):
|
||||
e = []
|
||||
for char, (width, strokes) in self.load_glyphs(newstroke_cpp):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue