feat: implement Color Walk feature and color-based LUT recommendations
This commit is contained in:
1 parent
98ec3f2fce
commit
b50ced4bf5
9 files changed
+613
-22
No files matched your search
@@ -66,6 +66,7 @@ import com.hinnka.mycamera.lut.creator.LutCreatorScreen
|
||||
import com.hinnka.mycamera.lut.creator.LutCreatorViewModel
|
||||
import com.hinnka.mycamera.screencapture.ScreenCaptureRenderConfigStore
|
||||
import com.hinnka.mycamera.ui.camera.CameraScreen
|
||||
import com.hinnka.mycamera.ui.camera.ColorWalkScreen
|
||||
import com.hinnka.mycamera.ui.camera.ToolboxScreen
|
||||
import com.hinnka.mycamera.ui.gallery.BurstDetailScreen
|
||||
import com.hinnka.mycamera.ui.gallery.GalleryDetailScreen
|
||||
@@ -103,6 +104,7 @@ object Routes {
|
||||
const val LUT_CREATOR = "lut_creator"
|
||||
const val TOOLBOX = "toolbox"
|
||||
const val PHANTOM_PIP_CROP = "phantom_pip_crop"
|
||||
const val COLOR_WALK = "color_walk"
|
||||
|
||||
fun photoDetail(tab: GalleryTab = GalleryTab.PHOTON, index: Int = 0, photoId: String? = null) =
|
||||
"photo_detail/$tab/$index" + (if (photoId != null) "?photoId=$photoId" else "")
|
||||
@@ -680,9 +682,15 @@ fun NavigationHost(
|
||||
composable(Routes.TOOLBOX) {
|
||||
ToolboxScreen(
|
||||
onBack = { navController.popBackStack() },
|
||||
onLutCreatorClick = {
|
||||
navController.navigate(Routes.LUT_CREATOR)
|
||||
}
|
||||
onLutCreatorClick = { navController.navigate(Routes.LUT_CREATOR) },
|
||||
onColorWalkClick = { navController.navigate(Routes.COLOR_WALK) }
|
||||
)
|
||||
}
|
||||
|
||||
composable(Routes.COLOR_WALK) {
|
||||
ColorWalkScreen(
|
||||
viewModel = cameraViewModel,
|
||||
onBack = { navController.popBackStack() }
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -59,23 +59,6 @@ data class FrameEditorDraft(
|
||||
fontWeight = FontWeight.BOLD,
|
||||
line = -1
|
||||
),
|
||||
FrameElementDraft.Divider(
|
||||
orientation = DividerOrientation.VERTICAL,
|
||||
alignment = ElementAlignment.START,
|
||||
lengthDp = 36,
|
||||
thicknessDp = 1,
|
||||
color = 0xFFE0E0E0.toInt(),
|
||||
marginDp = 8,
|
||||
line = -1
|
||||
),
|
||||
FrameElementDraft.Logo(
|
||||
logoType = LogoType.BRAND,
|
||||
alignment = ElementAlignment.START,
|
||||
sizeDp = 32,
|
||||
maxWidth = 128,
|
||||
marginDp = 8,
|
||||
line = -1
|
||||
),
|
||||
FrameElementDraft.Text(
|
||||
textType = TextType.APERTURE,
|
||||
alignment = ElementAlignment.END,
|
||||
@@ -128,10 +111,11 @@ data class FrameEditorDraft(
|
||||
)
|
||||
} else {
|
||||
FrameLayoutDraft(
|
||||
position = FramePosition.BOTTOM,
|
||||
position = FramePosition.BORDER,
|
||||
heightDp = 80,
|
||||
backgroundColor = Color.WHITE,
|
||||
paddingDp = 20
|
||||
paddingDp = 20,
|
||||
borderWidthDp = 4
|
||||
)
|
||||
},
|
||||
elements = defaultElements,
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.hinnka.mycamera.lut
|
||||
|
||||
import android.graphics.Color
|
||||
import androidx.core.graphics.ColorUtils
|
||||
|
||||
/**
|
||||
* LUT 色彩倾向分析器
|
||||
*/
|
||||
object LutColorAnalyzer {
|
||||
|
||||
/**
|
||||
* 分析 LUT 的色彩倾向性
|
||||
* @return 平均 RGB 偏移向量 [dR, dG, dB]
|
||||
*/
|
||||
fun analyzeTendency(lutConfig: LutConfig): FloatArray {
|
||||
val buffer = lutConfig.toFloatBuffer()
|
||||
val size = lutConfig.size
|
||||
val count = size * size * size
|
||||
|
||||
var rSum = 0f
|
||||
var gSum = 0f
|
||||
var bSum = 0f
|
||||
|
||||
buffer.position(0)
|
||||
for (i in 0 until count) {
|
||||
rSum += buffer.get()
|
||||
gSum += buffer.get()
|
||||
bSum += buffer.get()
|
||||
}
|
||||
|
||||
// 计算平均输出颜色
|
||||
val avgR = rSum / count
|
||||
val avgG = gSum / count
|
||||
val avgB = bSum / count
|
||||
|
||||
// 返回平均输出颜色作为倾向性
|
||||
return floatArrayOf(avgR, avgG, avgB)
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算目标颜色与 LUT 倾向性的匹配度 (0.0 ~ 1.0)
|
||||
*/
|
||||
fun calculateSuitability(targetColor: Int, tendency: FloatArray): Float {
|
||||
val targetHsl = FloatArray(3)
|
||||
ColorUtils.colorToHSL(targetColor, targetHsl)
|
||||
|
||||
val tendencyRgb = IntArray(3) { i -> (tendency[i] * 255f).toInt().coerceIn(0, 255) }
|
||||
val tendencyHsl = FloatArray(3)
|
||||
ColorUtils.RGBToHSL(tendencyRgb[0], tendencyRgb[1], tendencyRgb[2], tendencyHsl)
|
||||
|
||||
// 1. 色相匹配度 (Hue)
|
||||
val hueDiff = Math.abs(targetHsl[0] - tendencyHsl[0])
|
||||
val hueScore = 1.0f - (Math.min(hueDiff, 360f - hueDiff) / 180f)
|
||||
|
||||
// 2. 饱和度贡献 (如果倾向色饱和度高且方向一致,加分)
|
||||
val saturationScore = tendencyHsl[1]
|
||||
|
||||
// 综合得分 (色相权重 80%,饱和度权重 20%)
|
||||
return hueScore * 0.8f + saturationScore * 0.2f
|
||||
}
|
||||
}
|
||||
@@ -131,6 +131,9 @@ class LutManager(private val context: Context) {
|
||||
// LUT 缓存
|
||||
private val lutCache = LruCache<String, LutConfig>(CACHE_SIZE)
|
||||
|
||||
// LUT 色彩倾向缓存 (ID -> [R, G, B])
|
||||
private val tendencyCache = mutableMapOf<String, FloatArray>()
|
||||
|
||||
// 可用 LUT 列表
|
||||
private var availableLuts: List<LutInfo> = emptyList()
|
||||
|
||||
@@ -261,6 +264,36 @@ class LutManager(private val context: Context) {
|
||||
return "LUT Cache: ${lutCache.size()}/${CACHE_SIZE}, hits=${lutCache.hitCount()}, misses=${lutCache.missCount()}"
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定 LUT 的色彩倾向性(带缓存)
|
||||
*/
|
||||
fun getLutTendency(id: String): FloatArray? {
|
||||
tendencyCache[id]?.let { return it }
|
||||
|
||||
val lutConfig = loadLut(id) ?: return null
|
||||
val tendency = LutColorAnalyzer.analyzeTendency(lutConfig)
|
||||
tendencyCache[id] = tendency
|
||||
return tendency
|
||||
}
|
||||
|
||||
/**
|
||||
* 为指定颜色推荐最合适的 LUT 列表
|
||||
* @param targetColor 目标颜色 (Color Int)
|
||||
* @param limit 推荐数量
|
||||
* @return 按匹配度排序的 LUT 列表
|
||||
*/
|
||||
fun recommendLutsForColor(targetColor: Int, limit: Int = 5): List<LutInfo> {
|
||||
return availableLuts
|
||||
.mapNotNull { info ->
|
||||
val tendency = getLutTendency(info.id) ?: return@mapNotNull null
|
||||
val score = LutColorAnalyzer.calculateSuitability(targetColor, tendency)
|
||||
info to score
|
||||
}
|
||||
.sortedByDescending { it.second }
|
||||
.take(limit)
|
||||
.map { it.first }
|
||||
}
|
||||
|
||||
// ========== 色彩配方持久化方法 ==========
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,474 @@
|
||||
package com.hinnka.mycamera.ui.camera
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.SweepGradient
|
||||
import androidx.compose.animation.core.*
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.gestures.*
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyRow
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Check
|
||||
import androidx.compose.material.icons.filled.Shuffle
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.*
|
||||
import androidx.compose.ui.input.pointer.*
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.hinnka.mycamera.R
|
||||
import com.hinnka.mycamera.frame.*
|
||||
import com.hinnka.mycamera.lut.LutInfo
|
||||
import com.hinnka.mycamera.viewmodel.CameraViewModel
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.math.*
|
||||
import kotlin.random.Random
|
||||
import androidx.compose.runtime.collectAsState
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ColorWalkScreen(
|
||||
viewModel: CameraViewModel,
|
||||
onBack: () -> Unit
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val animatableHue = remember { Animatable(Random.nextFloat() * 360f) }
|
||||
val currentHue = animatableHue.value % 360f
|
||||
|
||||
val selectedColor = remember(currentHue) {
|
||||
Color.hsv(if (currentHue < 0) currentHue + 360f else currentHue, 1f, 1f)
|
||||
}
|
||||
|
||||
// Dopamine color logic: Triadic offset for a vibrant contrast
|
||||
val dopamineHue = remember(currentHue) { currentHue % 360f }
|
||||
val dopamineColor = remember(dopamineHue) { Color.hsv(dopamineHue, 0.85f, 0.98f) }
|
||||
|
||||
// Prepare Frame Draft for rendering
|
||||
val frameDraft = remember(dopamineColor) {
|
||||
FrameEditorDraft.createNew().let { base ->
|
||||
base.copy(
|
||||
name = "Color Walk",
|
||||
layout = base.layout.copy(
|
||||
backgroundColor = dopamineColor.toArgb(),
|
||||
borderColor = dopamineColor.toArgb(),
|
||||
),
|
||||
elements = base.elements.map { element ->
|
||||
when (element) {
|
||||
is FrameElementDraft.Text -> element.copy(color = Color.hsv(dopamineHue, 0.95f, 0.5f).toArgb())
|
||||
is FrameElementDraft.Divider -> element.copy(color = if (dopamineColor.isDark()) 0x40FFFFFF else 0x40000000)
|
||||
is FrameElementDraft.Logo -> element.copy(light = dopamineColor.isDark())
|
||||
else -> element
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Real Rendering of the Frame
|
||||
val framePreviewBitmap by produceState<Bitmap?>(null, frameDraft) {
|
||||
delay(200) // Debounce rendering to avoid stutter during drag
|
||||
value = viewModel.renderFrameEditorPreview(frameDraft, portrait = false)
|
||||
}
|
||||
|
||||
val recommendedLuts by produceState(emptyList(), currentHue) {
|
||||
value = viewModel.recommendLutsForColor(selectedColor.toArgb())
|
||||
}
|
||||
|
||||
val currentLutId by viewModel.currentLutId.collectAsState()
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
CenterAlignedTopAppBar(
|
||||
title = {
|
||||
Text(
|
||||
stringResource(R.string.color_walk_title),
|
||||
fontSize = 18.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
},
|
||||
navigationIcon = {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
|
||||
}
|
||||
},
|
||||
actions = {},
|
||||
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
|
||||
containerColor = Color.Black,
|
||||
titleContentColor = Color.White,
|
||||
navigationIconContentColor = Color.White
|
||||
)
|
||||
)
|
||||
},
|
||||
containerColor = Color.Black
|
||||
) { padding ->
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(padding)
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(horizontal = 24.dp)
|
||||
) {
|
||||
// Detailed Introduction
|
||||
Column(modifier = Modifier.padding(vertical = 16.dp)) {
|
||||
Text(
|
||||
text = "THE PHILOSOPHY",
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
fontSize = 11.sp,
|
||||
fontWeight = FontWeight.ExtraBold,
|
||||
letterSpacing = 2.sp
|
||||
)
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.color_walk_desc),
|
||||
color = Color.White.copy(alpha = 0.85f),
|
||||
fontSize = 12.sp,
|
||||
lineHeight = 18.sp,
|
||||
fontWeight = FontWeight.Light
|
||||
)
|
||||
}
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 16.dp, bottom = 12.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.color_walk_select_color),
|
||||
color = Color.White,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 18.sp
|
||||
)
|
||||
|
||||
TextButton(
|
||||
onClick = {
|
||||
scope.launch {
|
||||
val target = animatableHue.value + 1080f + Random.nextFloat() * 360f
|
||||
animatableHue.animateTo(
|
||||
targetValue = target,
|
||||
animationSpec = tween(
|
||||
durationMillis = 5000,
|
||||
easing = CubicBezierEasing(0.2f, 0.4f, 0.1f, 1f)
|
||||
)
|
||||
)
|
||||
}
|
||||
},
|
||||
colors = ButtonDefaults.textButtonColors(contentColor = MaterialTheme.colorScheme.primary)
|
||||
) {
|
||||
Icon(Icons.Default.Shuffle, contentDescription = null, modifier = Modifier.size(16.dp))
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Text(stringResource(R.string.color_walk_random), fontSize = 14.sp)
|
||||
}
|
||||
}
|
||||
|
||||
// Color Wheel
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.aspectRatio(1f),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
ColorWheel(
|
||||
selectedHue = currentHue,
|
||||
onHueChanged = { hue ->
|
||||
scope.launch {
|
||||
animatableHue.snapTo(hue)
|
||||
}
|
||||
},
|
||||
modifier = Modifier.fillMaxSize()
|
||||
.padding(16.dp)
|
||||
)
|
||||
|
||||
// Current Selected Color Preview in the center
|
||||
Surface(
|
||||
onClick = {
|
||||
scope.launch {
|
||||
val target = animatableHue.value + 1080f + Random.nextFloat() * 360f
|
||||
animatableHue.animateTo(
|
||||
targetValue = target,
|
||||
animationSpec = tween(
|
||||
durationMillis = 5000,
|
||||
easing = CubicBezierEasing(0.2f, 0.4f, 0.1f, 1f)
|
||||
)
|
||||
)
|
||||
}
|
||||
},
|
||||
shape = CircleShape,
|
||||
color = selectedColor,
|
||||
modifier = Modifier.size(90.dp),
|
||||
border = BorderStroke(4.dp, Color.Black.copy(alpha = 0.5f)),
|
||||
shadowElevation = 12.dp
|
||||
) {
|
||||
Box(contentAlignment = Alignment.Center) {
|
||||
Icon(
|
||||
Icons.Default.Shuffle,
|
||||
contentDescription = null,
|
||||
tint = if (selectedColor.isDark()) Color.White.copy(alpha = 0.3f) else Color.Black.copy(alpha = 0.3f),
|
||||
modifier = Modifier.size(32.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
// Recommended Filters Label
|
||||
Text(
|
||||
text = stringResource(R.string.color_walk_recommendations),
|
||||
color = Color.White,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 18.sp,
|
||||
modifier = Modifier.padding(bottom = 16.dp)
|
||||
)
|
||||
|
||||
// Smaller Recommended Filters Horizontal List
|
||||
LazyRow(
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
contentPadding = PaddingValues(bottom = 16.dp),
|
||||
modifier = Modifier.height(90.dp)
|
||||
) {
|
||||
items(recommendedLuts) { lut ->
|
||||
CompactLutRecommendationItem(
|
||||
lut = lut,
|
||||
color = selectedColor,
|
||||
isCurrent = currentLutId == lut.id,
|
||||
onClick = {
|
||||
viewModel.setLut(lut.id)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
RecommendedFrameSection(
|
||||
previewBitmap = framePreviewBitmap
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ColorWheel(
|
||||
selectedHue: Float,
|
||||
onHueChanged: (Float) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Canvas(
|
||||
modifier = modifier
|
||||
.pointerInput(Unit) {
|
||||
awaitEachGesture {
|
||||
val down = awaitFirstDown()
|
||||
val center = Offset(size.width / 2f, size.height / 2f)
|
||||
val radius = min(size.width, size.height) / 2f - 24.dp.toPx()
|
||||
val strokeWidth = 32.dp.toPx()
|
||||
val tolerance = 8.dp.toPx() // Small tolerance for easier touching
|
||||
val innerRadius = radius - strokeWidth / 2 - tolerance
|
||||
val outerRadius = radius + strokeWidth / 2 + tolerance
|
||||
|
||||
val dist = (down.position - center).getDistance()
|
||||
if (dist in innerRadius..outerRadius) {
|
||||
fun handlePointer(pos: Offset) {
|
||||
val dx = pos.x - center.x
|
||||
val dy = pos.y - center.y
|
||||
var angle = atan2(dy, dx) * (180f / PI.toFloat())
|
||||
if (angle < 0) angle += 360f
|
||||
onHueChanged(angle)
|
||||
}
|
||||
|
||||
handlePointer(down.position)
|
||||
down.consume()
|
||||
|
||||
while (true) {
|
||||
val event = awaitPointerEvent()
|
||||
val change = event.changes.find { it.id == down.id } ?: break
|
||||
if (change.pressed) {
|
||||
handlePointer(change.position)
|
||||
change.consume()
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
val center = Offset(size.width / 2, size.height / 2)
|
||||
val radius = size.minDimension / 2 - 24.dp.toPx()
|
||||
val strokeWidth = 32.dp.toPx()
|
||||
|
||||
// Draw Hue Ring using SweepGradient
|
||||
val colors = IntArray(361) { h -> android.graphics.Color.HSVToColor(floatArrayOf(h.toFloat(), 1f, 1f)) }
|
||||
drawContext.canvas.nativeCanvas.apply {
|
||||
val paint = android.graphics.Paint().apply {
|
||||
isAntiAlias = true
|
||||
style = android.graphics.Paint.Style.STROKE
|
||||
this.strokeWidth = strokeWidth
|
||||
shader = SweepGradient(center.x, center.y, colors, null)
|
||||
}
|
||||
drawCircle(center.x, center.y, radius, paint)
|
||||
}
|
||||
|
||||
// Draw Selector
|
||||
val angleRad = selectedHue * (PI.toFloat() / 180f)
|
||||
val selectorPos = Offset(
|
||||
center.x + radius * cos(angleRad),
|
||||
center.y + radius * sin(angleRad)
|
||||
)
|
||||
|
||||
drawCircle(
|
||||
color = Color.Black.copy(alpha = 0.5f),
|
||||
radius = (strokeWidth / 2) + 6.dp.toPx(),
|
||||
center = selectorPos
|
||||
)
|
||||
drawCircle(
|
||||
color = Color.White,
|
||||
radius = (strokeWidth / 2) + 2.dp.toPx(),
|
||||
center = selectorPos
|
||||
)
|
||||
drawCircle(
|
||||
color = Color.hsv(selectedHue, 1f, 1f),
|
||||
radius = (strokeWidth / 2) - 2.dp.toPx(),
|
||||
center = selectorPos
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RecommendedFrameSection(
|
||||
previewBitmap: Bitmap?
|
||||
) {
|
||||
Column(modifier = Modifier) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.color_walk_recommended_frame),
|
||||
color = Color.White,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 16.sp
|
||||
)
|
||||
|
||||
Surface(
|
||||
color = MaterialTheme.colorScheme.primary.copy(alpha = 0.1f),
|
||||
shape = RoundedCornerShape(8.dp)
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.color_walk_apply_frame),
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
fontSize = 11.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
// Frame Style Real Rendering Preview
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(160.dp)
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.background(Color.White.copy(alpha = 0.05f)),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
if (previewBitmap != null) {
|
||||
Image(
|
||||
bitmap = previewBitmap.asImageBitmap(),
|
||||
contentDescription = null,
|
||||
contentScale = ContentScale.Fit,
|
||||
modifier = Modifier.fillMaxSize()
|
||||
)
|
||||
} else {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier.size(24.dp),
|
||||
strokeWidth = 2.dp,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CompactLutRecommendationItem(
|
||||
lut: LutInfo,
|
||||
color: Color,
|
||||
isCurrent: Boolean,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
Surface(
|
||||
onClick = onClick,
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
color = Color(0xFF1C1C1E),
|
||||
modifier = Modifier
|
||||
.width(130.dp)
|
||||
.fillMaxHeight(),
|
||||
border = BorderStroke(1.dp, Color.White.copy(alpha = 0.1f))
|
||||
) {
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
// Background accent with selected color
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(3.dp)
|
||||
.background(color)
|
||||
.align(Alignment.TopCenter)
|
||||
)
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(12.dp)
|
||||
.align(Alignment.CenterStart)
|
||||
) {
|
||||
Text(
|
||||
text = lut.getName(),
|
||||
color = Color.White,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 13.sp,
|
||||
maxLines = 1
|
||||
)
|
||||
Text(
|
||||
text = lut.category ?: "Filter",
|
||||
color = Color.White.copy(alpha = 0.4f),
|
||||
fontSize = 10.sp,
|
||||
modifier = Modifier.padding(top = 2.dp)
|
||||
)
|
||||
}
|
||||
|
||||
if (isCurrent) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Check,
|
||||
contentDescription = null,
|
||||
tint = color.copy(alpha = 0.8f),
|
||||
modifier = Modifier
|
||||
.size(20.dp)
|
||||
.align(Alignment.BottomEnd)
|
||||
.padding(end = 8.dp, bottom = 8.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Color.isDark(): Boolean {
|
||||
val luminance = 0.299 * red + 0.587 * green + 0.114 * blue
|
||||
return luminance < 0.5
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import androidx.compose.foundation.lazy.grid.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.DirectionsWalk
|
||||
import androidx.compose.material.icons.filled.Palette
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -36,6 +37,7 @@ data class ToolboxItem(
|
||||
fun ToolboxScreen(
|
||||
onBack: () -> Unit,
|
||||
onLutCreatorClick: () -> Unit,
|
||||
onColorWalkClick: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val items = listOf(
|
||||
@@ -44,6 +46,12 @@ fun ToolboxScreen(
|
||||
descriptionRes = R.string.lut_creator_desc,
|
||||
icon = Icons.Default.Palette,
|
||||
onClick = onLutCreatorClick
|
||||
),
|
||||
ToolboxItem(
|
||||
titleRes = R.string.color_walk_title,
|
||||
descriptionRes = R.string.color_walk_short_desc,
|
||||
icon = Icons.Default.DirectionsWalk,
|
||||
onClick = onColorWalkClick
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -2485,6 +2485,13 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 为指定颜色推荐最合适的 LUT 列表
|
||||
*/
|
||||
suspend fun recommendLutsForColor(color: Int): List<LutInfo> = withContext(Dispatchers.IO) {
|
||||
contentRepository.lutManager.recommendLutsForColor(color)
|
||||
}
|
||||
|
||||
fun setPhantomLut(lutId: String?) {
|
||||
viewModelScope.launch {
|
||||
userPreferencesRepository.savePhantomLutConfig(lutId)
|
||||
|
||||
@@ -9,6 +9,14 @@
|
||||
<string name="timer">定时器</string>
|
||||
<string name="toolbox_title">工具箱</string>
|
||||
<string name="toolbox_description">实用工具与创意功能</string>
|
||||
<string name="color_walk_title">Color Walk</string>
|
||||
<string name="color_walk_desc">“Color Walk(色彩漫步)”是一种观察世界的正念练习。通过专注于特定的颜色,我们能够放慢脚步,在平凡的日常中发现被忽视的美。选择一个此刻最能触动你的颜色,开启一段专属于你的视觉探索之旅。</string>
|
||||
<string name="color_walk_short_desc">开启一段专注色彩的正念观察之旅</string>
|
||||
<string name="color_walk_recommendations">推荐滤镜</string>
|
||||
<string name="color_walk_random">遇见惊喜</string>
|
||||
<string name="color_walk_recommended_frame">推荐边框</string>
|
||||
<string name="color_walk_apply_frame">应用边框</string>
|
||||
<string name="color_walk_select_color">选择一种颜色</string>
|
||||
<string name="histogram">直方图</string>
|
||||
<string name="grid">网格</string>
|
||||
<string name="back">返回</string>
|
||||
|
||||
@@ -9,6 +9,14 @@
|
||||
<string name="timer">Timer</string>
|
||||
<string name="toolbox_title">Toolbox</string>
|
||||
<string name="toolbox_description">Utility tools and creative features</string>
|
||||
<string name="color_walk_title">Color Walk</string>
|
||||
<string name="color_walk_desc">A Color Walk is a form of mindfulness. By focusing on a specific color, we slow down and discover the hidden beauty in our daily surroundings. Choose a color that resonates with your mood today, and let it guide your perspective.</string>
|
||||
<string name="color_walk_short_desc">Discover mindfulness through a journey of colors.</string>
|
||||
<string name="color_walk_recommendations">Recommended Filters</string>
|
||||
<string name="color_walk_random">Surprise Me</string>
|
||||
<string name="color_walk_recommended_frame">Recommended Frame</string>
|
||||
<string name="color_walk_apply_frame">Apply Frame</string>
|
||||
<string name="color_walk_select_color">Select a Color</string>
|
||||
<string name="histogram">Histogram</string>
|
||||
<string name="grid">Grid</string>
|
||||
<string name="back">Back</string>
|
||||
|
||||
Reference in new issue
Block a user