From 2d63e781c6580c3009e43f3e01f6a984db25cbf4 Mon Sep 17 00:00:00 2001 From: Hieu Vu Date: Wed, 27 Nov 2024 23:00:22 +0700 Subject: [PATCH] Improve edit current svg --- .../arkbuilders/canvas/presentation/drawing/EditCanvas.kt | 1 - .../presentation/resourceloader/SvgResourceManager.kt | 1 + .../java/dev/arkbuilders/canvas/presentation/utils/SVG.kt | 8 ++++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/canvas/src/main/java/dev/arkbuilders/canvas/presentation/drawing/EditCanvas.kt b/canvas/src/main/java/dev/arkbuilders/canvas/presentation/drawing/EditCanvas.kt index 78bf699..a886649 100644 --- a/canvas/src/main/java/dev/arkbuilders/canvas/presentation/drawing/EditCanvas.kt +++ b/canvas/src/main/java/dev/arkbuilders/canvas/presentation/drawing/EditCanvas.kt @@ -184,7 +184,6 @@ fun DrawCanvas(modifier: Modifier, viewModel: EditViewModel) { svg.apply { val svgCommand = SVGCommand.MoveTo(eventX, eventY).apply { - //TODO Add color for paint paintColor = editManager.currentPaint.color.value brushSizeId = Size.MEDIUM.id } diff --git a/canvas/src/main/java/dev/arkbuilders/canvas/presentation/resourceloader/SvgResourceManager.kt b/canvas/src/main/java/dev/arkbuilders/canvas/presentation/resourceloader/SvgResourceManager.kt index 00428b1..5b11448 100644 --- a/canvas/src/main/java/dev/arkbuilders/canvas/presentation/resourceloader/SvgResourceManager.kt +++ b/canvas/src/main/java/dev/arkbuilders/canvas/presentation/resourceloader/SvgResourceManager.kt @@ -14,6 +14,7 @@ class SvgResourceManager( editManager.addDrawPath(draw.path) editManager.setPaintColor(draw.paint.color) } + editManager.svg.addAll(svgPaths.getCommands()) } override suspend fun saveResource(path: Path) { diff --git a/canvas/src/main/java/dev/arkbuilders/canvas/presentation/utils/SVG.kt b/canvas/src/main/java/dev/arkbuilders/canvas/presentation/utils/SVG.kt index 9e2f1d8..6b4e670 100644 --- a/canvas/src/main/java/dev/arkbuilders/canvas/presentation/utils/SVG.kt +++ b/canvas/src/main/java/dev/arkbuilders/canvas/presentation/utils/SVG.kt @@ -38,6 +38,10 @@ class SVG { commands.addLast(command) } + fun getCommands(): ArrayDeque { + return commands + } + fun addPath(path: DrawPath) { paths.addLast(path) } @@ -110,6 +114,10 @@ class SVG { } } + fun addAll(commands: ArrayDeque) { + commands.addAll(commands) + } + companion object { fun parse(path: Path): SVG = SVG().apply { val xmlParser = Xml.newPullParser()