preserve aspect ratio (#646)

pull/659/head
Kaalleen 2020-04-01 18:52:39 +02:00 zatwierdzone przez GitHub
rodzic facf181792
commit 7dcd04cc91
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 0 dodań i 6 usunięć

Wyświetl plik

@ -3,7 +3,6 @@ import simpletransform
from ..i18n import _
from ..utils import cache
# modern versions of Inkscape use 96 pixels per inch as per the CSS standard
PIXELS_PER_MM = 96 / 25.4
@ -131,11 +130,6 @@ def get_viewbox_transform(node):
# preserve aspect ratio
aspect_ratio = node.get('preserveAspectRatio', 'xMidYMid meet')
if aspect_ratio != 'none':
unit = parse_length_with_units(node.get('width'))[1]
if float(viewbox[2]) > parse_length_with_units(node.get('width'))[0]:
sx = convert_length(viewbox[2] + unit) / float(viewbox[2]) if 'slice' in aspect_ratio else 1.0
if float(viewbox[3]) > parse_length_with_units(node.get('height'))[0]:
sy = convert_length(viewbox[3] + unit) / float(viewbox[3]) if 'slice' in aspect_ratio else 1.0
sx = sy = max(sx, sy) if 'slice' in aspect_ratio else min(sx, sy)
scale_transform = simpletransform.parseTransform("scale(%f, %f)" % (sx, sy))