Add string export
This commit is contained in:
parent
28663a010d
commit
77e27c7eb6
@ -26,13 +26,12 @@ fun SchemeFeaturesState.snapshot(): FeatureStateSnapshot =
|
|||||||
features(),
|
features(),
|
||||||
features().values.filterIsInstance<PainterFeature>().associateWith { it.painter() })
|
features().values.filterIsInstance<PainterFeature>().associateWith { it.painter() })
|
||||||
|
|
||||||
|
fun FeatureStateSnapshot.generateSvg(
|
||||||
fun FeatureStateSnapshot.exportToSvg(
|
|
||||||
viewPoint: SchemeViewPoint,
|
viewPoint: SchemeViewPoint,
|
||||||
width: Double,
|
width: Double,
|
||||||
height: Double,
|
height: Double,
|
||||||
path: java.nio.file.Path,
|
id: String? = null
|
||||||
) {
|
): String{
|
||||||
|
|
||||||
fun SchemeCoordinates.toOffset(): Offset = Offset(
|
fun SchemeCoordinates.toOffset(): Offset = Offset(
|
||||||
(width / 2 + (x - viewPoint.focus.x) * viewPoint.scale).toFloat(),
|
(width / 2 + (x - viewPoint.focus.x) * viewPoint.scale).toFloat(),
|
||||||
@ -132,6 +131,17 @@ fun FeatureStateSnapshot.exportToSvg(
|
|||||||
drawFeature(viewPoint.scale, feature)
|
drawFeature(viewPoint.scale, feature)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return svgGraphics2D.getSVGElement(id)
|
||||||
|
}
|
||||||
|
|
||||||
SVGUtils.writeToSVG(path.toFile(), svgGraphics2D.svgElement)
|
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)
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user