gui: use mm in the svg
This commit is contained in:
parent
92fcfd12cc
commit
f5bafb7f73
|
@ -17,6 +17,7 @@ import xdg.BaseDirectory
|
||||||
import svgwrite
|
import svgwrite
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from svgwrite import mm
|
||||||
|
|
||||||
DATA_PATH = Path(xdg.BaseDirectory.xdg_cache_home, 'tuhi', 'svg')
|
DATA_PATH = Path(xdg.BaseDirectory.xdg_cache_home, 'tuhi', 'svg')
|
||||||
|
|
||||||
|
@ -43,9 +44,9 @@ class JsonSvg(GObject.Object):
|
||||||
width, height = dimensions[0] / 1000, dimensions[1] / 1000
|
width, height = dimensions[0] / 1000, dimensions[1] / 1000
|
||||||
|
|
||||||
if self.orientation in ['portrait', 'reverse-Portrait']:
|
if self.orientation in ['portrait', 'reverse-Portrait']:
|
||||||
size = (height, width)
|
size = (height * mm, width * mm)
|
||||||
else:
|
else:
|
||||||
size = (width, height)
|
size = (width * mm, height * mm)
|
||||||
svg = svgwrite.Drawing(filename=self.filename, size=size)
|
svg = svgwrite.Drawing(filename=self.filename, size=size)
|
||||||
g = svgwrite.container.Group(id='layer0')
|
g = svgwrite.container.Group(id='layer0')
|
||||||
for stroke_num, s in enumerate(js['strokes']):
|
for stroke_num, s in enumerate(js['strokes']):
|
||||||
|
@ -76,8 +77,8 @@ class JsonSvg(GObject.Object):
|
||||||
xp, yp, stroke_width_p = points_with_sk_width[i - 1]
|
xp, yp, stroke_width_p = points_with_sk_width[i - 1]
|
||||||
lines.add(
|
lines.add(
|
||||||
svg.line(
|
svg.line(
|
||||||
start=(xp, yp),
|
start=(xp * mm, yp * mm),
|
||||||
end=(x, y),
|
end=(x * mm, y * mm),
|
||||||
stroke_width=stroke_width,
|
stroke_width=stroke_width,
|
||||||
style='fill:none'
|
style='fill:none'
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue