From 67a0da13bd3fb81ab3d088612f16143fa4e23569 Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Tue, 27 Dec 2022 09:57:34 +0100 Subject: [PATCH] Improve SVG layout --- .../Generators/HTMLElementsGenerator.swift | 15 ++++++--------- .../Generators/PageContentGenerator.swift | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Sources/Generator/Generators/HTMLElementsGenerator.swift b/Sources/Generator/Generators/HTMLElementsGenerator.swift index 8c1b87f..942bfbc 100644 --- a/Sources/Generator/Generators/HTMLElementsGenerator.swift +++ b/Sources/Generator/Generators/HTMLElementsGenerator.swift @@ -4,10 +4,6 @@ typealias SVGSelection = (x: Int, y: Int, width: Int, height: Int) struct HTMLElementsGenerator { - init() { - - } - func make(title: String, suffix: String) -> String { "\(title)\(suffix)" } @@ -40,16 +36,17 @@ struct HTMLElementsGenerator { } func image(file: String, width: Int, height: Int, altText: String) -> String { - """ + let ratio = Float(width) / Float(height) + return """ - \(altText) + \(altText) """ } - func svgImage(file: String, part: SVGSelection, width: Int, height: Int, altText: String) -> String { - let path = "\(file)#svgView(viewBox(\(part.x),\(part.y),\(part.width),\(part.height))" - return image(file: path, width: width, height: height, altText: altText) + func svgImage(file: String, part: SVGSelection, altText: String) -> String { + let path = "\(file)#svgView(viewBox(\(part.x), \(part.y), \(part.width), \(part.height)))" + return image(file: path, width: part.width, height: part.height, altText: altText) } func downloadButtons(_ buttons: [(file: String, text: String, downloadName: String?)]) -> String { diff --git a/Sources/Generator/Generators/PageContentGenerator.swift b/Sources/Generator/Generators/PageContentGenerator.swift index d18d552..6f7fc8b 100644 --- a/Sources/Generator/Generators/PageContentGenerator.swift +++ b/Sources/Generator/Generators/PageContentGenerator.swift @@ -236,7 +236,7 @@ struct PageContentGenerator { return factory.html.image(file: file, width: width, height: height, altText: altText) } let part = SVGSelection(x, y, partWidth, partHeight) - return factory.html.svgImage(file: file, part: part, width: width, height: height, altText: altText) + return factory.html.svgImage(file: file, part: part, altText: altText) } private func handleFile(page: Element, file: String, fileExtension: String) -> String {