package com.pixelized.desktop.lwa.ui.composable.scene.fogOfWar

import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.neverEqualPolicy
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.CompositingStrategy
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.StrokeJoin
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.graphics.drawscope.scale
import androidx.compose.ui.graphics.drawscope.translate
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.pointer.PointerEvent
import androidx.compose.ui.input.pointer.PointerEventType
import androidx.compose.ui.input.pointer.isPrimaryPressed
import androidx.compose.ui.input.pointer.onPointerEvent
import com.pixelized.desktop.lwa.ui.composable.scene.camera.Camera
import com.pixelized.desktop.lwa.ui.composable.scene.utils.global
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

@Stable
class FogOfWar(
    val color: Color = Color.Black.copy(alpha = 0.5f),
) {
    val path = mutableStateOf(value = Path(), policy = neverEqualPolicy())

    fun moveTo(position: Offset) {
        path.value = path.value.also { it.moveTo(x = position.x, y = position.y) }
    }

    fun lineTo(position: Offset) {
        path.value = path.value.also { it.lineTo(x = position.x, y = position.y) }
    }

    companion object {
        val NONE = FogOfWar(color = Color.Transparent)
    }
}