Browse Source

Set correct dimensions on HPGL export

master
Gijs 8 months ago
parent
commit
64839e50bd
  1. 12
      app.py

12
app.py

@ -290,6 +290,16 @@ def catalogue():
#
# FIGLET 2 SVGBOB INTERACTIVE CATALOGUE
def resizeSVG (m):
width = int(m.group(1))
height = int(m.group(2))
viewbox = f'0 0 {width} {height}'
newHeight = 420
newWidth = (width/height) * newHeight
return f'<svg xmlns="http://www.w3.org/2000/svg" viewbox="{viewbox}" width="{newWidth}mm" height="{newHeight}mm" class="svgbob">'
@app.route('/hpgl/<id>')
def hpgl (id):
@ -309,6 +319,8 @@ def hpgl (id):
svg = re.sub(r'\<rect class="backdrop" x="\d+" y="\d+" width="\d+" height="\d+">\<\/rect\>', '', svg, flags=re.M)
svg = re.sub(r'<svg xmlns="http://www.w3.org/2000/svg" width="(\d+)" height="(\d+)" class="svgbob">', resizeSVG,svg)
#print(svg)
# store as a temporary file

Loading…
Cancel
Save