Add string export

This commit is contained in:
Alexander Nozik 2022-10-09 13:48:19 +03:00
parent 28663a010d
commit 77e27c7eb6
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357

View File

@ -26,13 +26,12 @@ fun SchemeFeaturesState.snapshot(): FeatureStateSnapshot =
features(),
features().values.filterIsInstance<PainterFeature>().associateWith { it.painter() })
fun FeatureStateSnapshot.exportToSvg(
fun FeatureStateSnapshot.generateSvg(
viewPoint: SchemeViewPoint,
width: Double,
height: Double,
path: java.nio.file.Path,
) {
id: String? = null
): String{
fun SchemeCoordinates.toOffset(): Offset = Offset(
(width / 2 + (x - viewPoint.focus.x) * viewPoint.scale).toFloat(),
@ -132,6 +131,17 @@ fun FeatureStateSnapshot.exportToSvg(
drawFeature(viewPoint.scale, feature)
}
}
SVGUtils.writeToSVG(path.toFile(), svgGraphics2D.svgElement)
return svgGraphics2D.getSVGElement(id)
}
fun FeatureStateSnapshot.exportToSvg(
viewPoint: SchemeViewPoint,
width: Double,
height: Double,
path: java.nio.file.Path,
) {
val svgString = generateSvg(viewPoint, width, height)
SVGUtils.writeToSVG(path.toFile(), svgString)
}