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) {
|
||||
writer.apply {
|
||||
write("<svg width=\"")
|
||||
write(width.toString())
|
||||
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("\"/>")
|
||||
write("<svg width=\"$width\" height=\"$height\" xmlns=\"http://www.w3.org/2000/svg\">")
|
||||
write("<rect width=\"$width\" height=\"$height\" fill=\"#${Integer.toHexString(backgroundColor).substring(2)}\"/>")
|
||||
|
||||
for ((key, value) in paths) {
|
||||
writePath(this, key, value)
|
||||
|
|
|
@ -32,11 +32,6 @@ class Line : Action {
|
|||
}
|
||||
|
||||
override fun perform(writer: Writer) {
|
||||
writer.apply {
|
||||
write("L")
|
||||
write(x.toString())
|
||||
write(",")
|
||||
write(y.toString())
|
||||
}
|
||||
writer.write("L$x,$y")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,11 +32,6 @@ class Move : Action {
|
|||
}
|
||||
|
||||
override fun perform(writer: Writer) {
|
||||
writer.apply {
|
||||
write("M")
|
||||
write(x.toString())
|
||||
write(",")
|
||||
write(y.toString())
|
||||
}
|
||||
writer.write("M$x,$y")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,15 +41,6 @@ class Quad : Action {
|
|||
}
|
||||
|
||||
override fun perform(writer: Writer) {
|
||||
writer.apply {
|
||||
write("Q")
|
||||
write(x1.toString())
|
||||
write(",")
|
||||
write(y1.toString())
|
||||
write(" ")
|
||||
write(x2.toString())
|
||||
write(",")
|
||||
write(y2.toString())
|
||||
}
|
||||
writer.write("Q$x1,$y1 $x2,$y2")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue