minor styling update to MyPath
This commit is contained in:
parent
2e089feb29
commit
c9a3e97f02
|
@ -15,7 +15,7 @@ import java.util.*
|
||||||
// https://stackoverflow.com/a/8127953
|
// https://stackoverflow.com/a/8127953
|
||||||
class MyPath : Path(), Serializable {
|
class MyPath : Path(), Serializable {
|
||||||
|
|
||||||
private val actions = LinkedList<Action>()
|
val actions = LinkedList<Action>()
|
||||||
|
|
||||||
private fun readObject(inputStream: ObjectInputStream) {
|
private fun readObject(inputStream: ObjectInputStream) {
|
||||||
inputStream.defaultReadObject()
|
inputStream.defaultReadObject()
|
||||||
|
@ -57,13 +57,10 @@ class MyPath : Path(), Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addAction(action: Action) {
|
private fun addAction(action: Action) {
|
||||||
if (action is Move) {
|
when (action) {
|
||||||
moveTo(action.x, action.y)
|
is Move -> moveTo(action.x, action.y)
|
||||||
} else if (action is Line) {
|
is Line -> lineTo(action.x, action.y)
|
||||||
lineTo(action.x, action.y)
|
is Quad -> quadTo(action.x1, action.y1, action.x2, action.y2)
|
||||||
} else if (action is Quad) {
|
|
||||||
val q = action
|
|
||||||
quadTo(q.x1, q.y1, q.x2, q.y2)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +78,4 @@ class MyPath : Path(), Serializable {
|
||||||
actions.add(Quad(x1, y1, x2, y2))
|
actions.add(Quad(x1, y1, x2, y2))
|
||||||
super.quadTo(x1, y1, x2, y2)
|
super.quadTo(x1, y1, x2, y2)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getActions() = actions
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ object Svg {
|
||||||
private fun writePath(writer: Writer, path: MyPath, options: PaintOptions) {
|
private fun writePath(writer: Writer, path: MyPath, options: PaintOptions) {
|
||||||
writer.apply {
|
writer.apply {
|
||||||
write("<path d=\"")
|
write("<path d=\"")
|
||||||
path.getActions().forEach {
|
path.actions.forEach {
|
||||||
it.perform(this)
|
it.perform(this)
|
||||||
write(" ")
|
write(" ")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue