rectangularTriangle: Fix placement

Resolves: #308
This commit is contained in:
Florian Festi 2021-04-17 11:44:34 +02:00
parent 8030faadd6
commit eb84f0e0ac
1 changed files with 10 additions and 17 deletions

View File

@ -1936,33 +1936,28 @@ class Boxes:
raise ValueError("two or three edges required") raise ValueError("two or three edges required")
r = min(r, x, y) r = min(r, x, y)
alpha = math.degrees(math.atan2(y-r, float(x-r))) a = math.atan2(y-r, float(x-r))
alpha = math.degrees(a)
width = x + edges[-1].spacing() + edges[1].spacing() width = x + edges[-1].spacing()/math.sin(a) + edges[1].spacing()
height = y + edges[0].spacing() + edges[2].spacing() height = y + edges[0].spacing() + edges[2].spacing() * math.cos(a) + 2* self.spacing
if num > 1: if num > 1:
width += edges[-1].spacing() + edges[1].spacing() + 2*self.spacing width = 2*width - x + r
height += 0.7*r + edges[0].spacing() + edges[2].spacing() + self.spacing dx = width - x - edges[1].spacing() - self.spacing
dy = edges[0].spacing() + self.spacing
overallwidth = width * (num // 2 + num % 2) overallwidth = width * (num // 2 + num % 2)
overallheight = height overallheight = height
if self.move(overallwidth, overallheight, move, before=True): if self.move(overallwidth, overallheight, move, before=True):
return return
if self.debug: if self.debug:
self.rectangularHole(width/2., height/2., width, height) self.rectangularHole(width/2., height/2., width, height)
if num > 1: self.moveTo(dx, dy)
self.moveTo(self.spacing + edges[-1].spacing())
for n in range(num): for n in range(num):
self.moveTo(edges[-1].spacing()+self.spacing, edges[0].margin())
if n % 2 == 1:
self.moveTo(2*edges[1].spacing()+self.spacing, 0)
if num > 1:
self.moveTo(edges[1].spacing(), 0)
for i, l in enumerate((x, y)): for i, l in enumerate((x, y)):
self.cc(callback, i, y=edges[i].startwidth() + self.burn) self.cc(callback, i, y=edges[i].startwidth() + self.burn)
edges[i](l, edges[i](l,
@ -1981,11 +1976,9 @@ class Boxes:
self.corner(90) self.corner(90)
self.ctx.stroke() self.ctx.stroke()
self.moveTo(width-2*dx, height - 2*dy, 180)
if n % 2: if n % 2:
self.moveTo(-edges[1].spacing()-2*self.spacing-edges[-1].spacing(), height-edges[0].spacing(), 180) self.moveTo(width)
else:
self.moveTo(width+1*edges[1].spacing()-self.spacing-2*edges[-1].spacing(), height-edges[0].spacing(), 180)
self.move(overallwidth, overallheight, move, label=label) self.move(overallwidth, overallheight, move, label=label)