|
@@ -1,6 +1,5 @@
|
|
|
package com.ys.imageProcess.ui.work
|
|
|
|
|
|
-import android.graphics.Point
|
|
|
import android.graphics.PointF
|
|
|
import androidx.compose.foundation.Canvas
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
@@ -11,11 +10,9 @@ import androidx.compose.ui.geometry.Rect
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
import androidx.compose.ui.graphics.Path
|
|
|
import androidx.compose.ui.graphics.drawscope.DrawScope
|
|
|
-import androidx.compose.ui.graphics.drawscope.Fill
|
|
|
import androidx.compose.ui.graphics.drawscope.Stroke
|
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
|
import com.ys.imageProcess.ui.theme.ImageProcTheme
|
|
|
-import kotlin.math.abs
|
|
|
|
|
|
@Composable
|
|
|
fun CanvasView(
|
|
@@ -30,7 +27,7 @@ fun CanvasView(
|
|
|
Canvas(modifier.fillMaxSize()) {
|
|
|
val strokeWidth = 5 / scale
|
|
|
if (state.showContour) {
|
|
|
- drawPolygon(contour, fillColor, Color.Green, strokeWidth, state.editMode)
|
|
|
+ drawPolygon(contour, fillColor, Color.Green, strokeWidth, state.editMode,true)
|
|
|
}
|
|
|
if (state.showWidth) {
|
|
|
drawPolygon(width, fillColor, Color.Blue, strokeWidth, state.editMode)
|
|
@@ -38,7 +35,6 @@ fun CanvasView(
|
|
|
if (state.showLength) {
|
|
|
drawPolygon(length, fillColor, Color.Red, strokeWidth, state.editMode)
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -66,7 +62,6 @@ private fun DrawScope.drawPolygon(
|
|
|
close()
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if (showAnchors) {
|
|
|
val l = strokeWidth * 5
|
|
|
|
|
@@ -77,47 +72,11 @@ private fun DrawScope.drawPolygon(
|
|
|
moveTo(x, y)
|
|
|
val rect = Rect(Offset(x - l, y - l), Offset(x + l, y + l))
|
|
|
addRect(rect)
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // var showRect = true
|
|
|
- // var lastRectIndex = -1
|
|
|
- // val l = strokeWidth * 5
|
|
|
- //
|
|
|
- // for (i in points.indices) {
|
|
|
- // val x = points[i].x * d
|
|
|
- // val y = points[i].y * d
|
|
|
- // if (i > 0) {
|
|
|
- // if (lastRectIndex >= 0) {
|
|
|
- // val lastRectX = points[lastRectIndex].x * d
|
|
|
- // val lastRectY = points[lastRectIndex].y * d
|
|
|
- // showRect =
|
|
|
- // abs(lastRectX - x) > l * 4 || abs(lastRectY - y) > l * 4
|
|
|
- // showRect = true
|
|
|
- // }
|
|
|
- // if (showRect) {
|
|
|
- // lastRectIndex = i
|
|
|
- // }
|
|
|
- // }
|
|
|
- //
|
|
|
- //
|
|
|
- // if (showRect) {
|
|
|
- // moveTo(x, y)
|
|
|
- // val rect = Rect(Offset(x - l, y - l), Offset(x + l, y + l))
|
|
|
- // addRect(rect)
|
|
|
- // }
|
|
|
-
|
|
|
- // }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// drawPath(
|
|
|
-// path = path,
|
|
|
-// color = fillColor,
|
|
|
-// style = Fill
|
|
|
-// )
|
|
|
-
|
|
|
drawPath(
|
|
|
path = path,
|
|
|
color = strokeColor,
|