shorten some svg file writes
This commit is contained in:
parent
2176664c39
commit
9ff5876a19
|
@ -19,20 +19,8 @@ object Svg {
|
||||||
|
|
||||||
private fun writeSvg(writer: Writer, backgroundColor: Int, paths: Map<MyPath, PaintOptions>, width: Int, height: Int) {
|
private fun writeSvg(writer: Writer, backgroundColor: Int, paths: Map<MyPath, PaintOptions>, width: Int, height: Int) {
|
||||||
writer.apply {
|
writer.apply {
|
||||||
write("<svg width=\"")
|
write("<svg width=\"$width\" height=\"$height\" xmlns=\"http://www.w3.org/2000/svg\">")
|
||||||
write(width.toString())
|
write("<rect width=\"$width\" height=\"$height\" fill=\"#${Integer.toHexString(backgroundColor).substring(2)}\"/>")
|
||||||
write("\" height=\"")
|
|
||||||
write(height.toString())
|
|
||||||
write("\" xmlns=\"http://www.w3.org/2000/svg\">")
|
|
||||||
|
|
||||||
// background rect
|
|
||||||
write("<rect width=\"")
|
|
||||||
write(width.toString())
|
|
||||||
write("\" height=\"")
|
|
||||||
write(height.toString())
|
|
||||||
write("\" fill=\"#")
|
|
||||||
write(Integer.toHexString(backgroundColor).substring(2))
|
|
||||||
write("\"/>")
|
|
||||||
|
|
||||||
for ((key, value) in paths) {
|
for ((key, value) in paths) {
|
||||||
writePath(this, key, value)
|
writePath(this, key, value)
|
||||||
|
|
|
@ -32,11 +32,6 @@ class Line : Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun perform(writer: Writer) {
|
override fun perform(writer: Writer) {
|
||||||
writer.apply {
|
writer.write("L$x,$y")
|
||||||
write("L")
|
|
||||||
write(x.toString())
|
|
||||||
write(",")
|
|
||||||
write(y.toString())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,11 +32,6 @@ class Move : Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun perform(writer: Writer) {
|
override fun perform(writer: Writer) {
|
||||||
writer.apply {
|
writer.write("M$x,$y")
|
||||||
write("M")
|
|
||||||
write(x.toString())
|
|
||||||
write(",")
|
|
||||||
write(y.toString())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,15 +41,6 @@ class Quad : Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun perform(writer: Writer) {
|
override fun perform(writer: Writer) {
|
||||||
writer.apply {
|
writer.write("Q$x1,$y1 $x2,$y2")
|
||||||
write("Q")
|
|
||||||
write(x1.toString())
|
|
||||||
write(",")
|
|
||||||
write(y1.toString())
|
|
||||||
write(" ")
|
|
||||||
write(x2.toString())
|
|
||||||
write(",")
|
|
||||||
write(y2.toString())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue