feat: primary color calibration support

This commit is contained in:
Hinnka committed 2026-04-05 17:32:52 +08:00
1 parent f6b7413886
commit b205e20256
7 files changed
+324 -18

No files matched your search

@@ -106,6 +106,9 @@ class LutImageProcessor {
private var uLchHueAdjustmentsLoc = 0
private var uLchChromaAdjustmentsLoc = 0
private var uLchLightnessAdjustmentsLoc = 0
private var uPrimaryHueLoc = 0
private var uPrimarySaturationLoc = 0
private var uPrimaryLightnessLoc = 0
// 后期处理参数 Uniform 位置(仅拍摄和后期编辑时生效)
private var uSharpeningLoc = 0
@@ -502,6 +505,9 @@ class LutImageProcessor {
GLES30.glUniform1fv(uLchHueAdjustmentsLoc, LCH_COLOR_BAND_COUNT, lchHueAdjustments, 0)
GLES30.glUniform1fv(uLchChromaAdjustmentsLoc, LCH_COLOR_BAND_COUNT, lchChromaAdjustments, 0)
GLES30.glUniform1fv(uLchLightnessAdjustmentsLoc, LCH_COLOR_BAND_COUNT, lchLightnessAdjustments, 0)
GLES30.glUniform3f(uPrimaryHueLoc, effectiveRecipeParams?.primaryRedHue ?: 0f, effectiveRecipeParams?.primaryGreenHue ?: 0f, effectiveRecipeParams?.primaryBlueHue ?: 0f)
GLES30.glUniform3f(uPrimarySaturationLoc, effectiveRecipeParams?.primaryRedSaturation ?: 0f, effectiveRecipeParams?.primaryGreenSaturation ?: 0f, effectiveRecipeParams?.primaryBlueSaturation ?: 0f)
GLES30.glUniform3f(uPrimaryLightnessLoc, effectiveRecipeParams?.primaryRedLightness ?: 0f, effectiveRecipeParams?.primaryGreenLightness ?: 0f, effectiveRecipeParams?.primaryBlueLightness ?: 0f)
}
// 设置曲线纹理(Unit 3)
@@ -778,6 +784,9 @@ class LutImageProcessor {
uLchHueAdjustmentsLoc = GLES30.glGetUniformLocation(shaderProgram, "uLchHueAdjustments")
uLchChromaAdjustmentsLoc = GLES30.glGetUniformLocation(shaderProgram, "uLchChromaAdjustments")
uLchLightnessAdjustmentsLoc = GLES30.glGetUniformLocation(shaderProgram, "uLchLightnessAdjustments")
uPrimaryHueLoc = GLES30.glGetUniformLocation(shaderProgram, "uPrimaryHue")
uPrimarySaturationLoc = GLES30.glGetUniformLocation(shaderProgram, "uPrimarySaturation")
uPrimaryLightnessLoc = GLES30.glGetUniformLocation(shaderProgram, "uPrimaryLightness")
uSharpeningLoc = GLES30.glGetUniformLocation(shaderProgram, "uSharpening")
uTexelSizeLoc = GLES30.glGetUniformLocation(shaderProgram, "uTexelSize")
@@ -1300,6 +1309,12 @@ class LutImageProcessor {
uniform float uNoiseSeed; // 噪点随机种子
uniform float uLowRes; // 0.0 ~ 1.0 (低像素强度)
uniform float uAspectRatio; // 图像长宽比
// Primary Calibration
uniform vec3 uPrimaryHue;
uniform vec3 uPrimarySaturation;
uniform vec3 uPrimaryLightness;
uniform float uLchHueAdjustments[9];
uniform float uLchChromaAdjustments[9];
uniform float uLchLightnessAdjustments[9];
@@ -1540,6 +1555,54 @@ class LutImageProcessor {
return clamp(linearToSrgb(mixedLinear), 0.0, 1.0);
}
vec3 applyPrimaryCalibration(vec3 color) {
if (abs(uPrimaryHue.x) < 0.0001 && abs(uPrimaryHue.y) < 0.0001 && abs(uPrimaryHue.z) < 0.0001 &&
abs(uPrimarySaturation.x) < 0.0001 && abs(uPrimarySaturation.y) < 0.0001 && abs(uPrimarySaturation.z) < 0.0001 &&
abs(uPrimaryLightness.x) < 0.0001 && abs(uPrimaryLightness.y) < 0.0001 && abs(uPrimaryLightness.z) < 0.0001) {
return color;
}
float minC = min(min(color.r, color.g), color.b);
vec3 rgb = color - minC;
// 1. Hue Shift (mixes primaries via channel rotation mapping)
float rH = uPrimaryHue.x * 0.35;
float gH = uPrimaryHue.y * 0.35;
float bH = uPrimaryHue.z * 0.35;
vec3 r_vec = vec3(1.0 - abs(rH), rH > 0.0 ? rH : 0.0, rH < 0.0 ? -rH : 0.0);
vec3 g_vec = vec3(gH < 0.0 ? -gH : 0.0, 1.0 - abs(gH), gH > 0.0 ? gH : 0.0);
vec3 b_vec = vec3(bH > 0.0 ? bH : 0.0, bH < 0.0 ? -bH : 0.0, 1.0 - abs(bH));
vec3 mixed = rgb.r * r_vec + rgb.g * g_vec + rgb.b * b_vec;
// 2. Saturation Shift (scales the mixed vector uniformly to strictly preserve hue ratio)
float total_rgb = rgb.r + rgb.g + rgb.b;
if (total_rgb > 0.0001) {
float rS = uPrimarySaturation.x;
float gS = uPrimarySaturation.y;
float bS = uPrimarySaturation.z;
float sat_scale = (rgb.r * rS + rgb.g * gS + rgb.b * bS) / total_rgb;
if (sat_scale > 0.0) {
mixed *= (1.0 + sat_scale);
} else {
vec3 lumaWeights = vec3(0.299, 0.587, 0.114);
float m_luma = dot(mixed, lumaWeights);
mixed = mix(mixed, vec3(m_luma), -sat_scale);
}
}
// 3. Lightness Shift
float rL = uPrimaryLightness.x * 0.5;
float gL = uPrimaryLightness.y * 0.5;
float bL = uPrimaryLightness.z * 0.5;
vec3 light_add = vec3(rgb.r * rL + rgb.g * gL + rgb.b * bL);
return clamp(vec3(minC) + mixed + light_add, 0.0, 1.0);
}
vec3 applyLutCurve(vec3 l, int curveType) {
if (curveType == 0) { // sRGB
return linearToSrgb(l);
@@ -1699,6 +1762,10 @@ class LutImageProcessor {
color.rgb = sanitizeColor(color.rgb);
}
// 6.5. 颜色校准 (Camera Calibration)
color.rgb = applyPrimaryCalibration(color.rgb);
color.rgb = sanitizeColor(color.rgb);
color.rgb = applyLchColorMixer(color.rgb);
color.rgb = sanitizeColor(color.rgb);
@@ -120,6 +120,9 @@ class LutRenderer : GLSurfaceView.Renderer {
private var uLchHueAdjustmentsLocation: Int = 0
private var uLchChromaAdjustmentsLocation: Int = 0
private var uLchLightnessAdjustmentsLocation: Int = 0
private var uPrimaryHueLocation: Int = 0
private var uPrimarySaturationLocation: Int = 0
private var uPrimaryLightnessLocation: Int = 0
private var uSTMatrixFragLocation: Int = 0
private var uCropRectLocation: Int = 0
private var uApertureLocation: Int = 0
@@ -282,6 +285,16 @@ class LutRenderer : GLSurfaceView.Renderer {
@Volatile
var halation: Float = 0f // 0.0 ~ 1.0
@Volatile var primaryRedHue: Float = 0f
@Volatile var primaryRedSaturation: Float = 0f
@Volatile var primaryRedLightness: Float = 0f
@Volatile var primaryGreenHue: Float = 0f
@Volatile var primaryGreenSaturation: Float = 0f
@Volatile var primaryGreenLightness: Float = 0f
@Volatile var primaryBlueHue: Float = 0f
@Volatile var primaryBlueSaturation: Float = 0f
@Volatile var primaryBlueLightness: Float = 0f
private val lchHueAdjustments = FloatArray(LCH_COLOR_BAND_COUNT)
private val lchChromaAdjustments = FloatArray(LCH_COLOR_BAND_COUNT)
private val lchLightnessAdjustments = FloatArray(LCH_COLOR_BAND_COUNT)
@@ -682,6 +695,10 @@ class LutRenderer : GLSurfaceView.Renderer {
GLES30.glUniform1fv(uLchHueAdjustmentsLocation, LCH_COLOR_BAND_COUNT, lchHueAdjustments, 0)
GLES30.glUniform1fv(uLchChromaAdjustmentsLocation, LCH_COLOR_BAND_COUNT, lchChromaAdjustments, 0)
GLES30.glUniform1fv(uLchLightnessAdjustmentsLocation, LCH_COLOR_BAND_COUNT, lchLightnessAdjustments, 0)
GLES30.glUniform3f(uPrimaryHueLocation, primaryRedHue, primaryGreenHue, primaryBlueHue)
GLES30.glUniform3f(uPrimarySaturationLocation, primaryRedSaturation, primaryGreenSaturation, primaryBlueSaturation)
GLES30.glUniform3f(uPrimaryLightnessLocation, primaryRedLightness, primaryGreenLightness, primaryBlueLightness)
}
// 曲线纹理上传(如有待处理数据)
@@ -828,6 +845,9 @@ class LutRenderer : GLSurfaceView.Renderer {
uLchHueAdjustmentsLocation = GLES30.glGetUniformLocation(programId, "uLchHueAdjustments")
uLchChromaAdjustmentsLocation = GLES30.glGetUniformLocation(programId, "uLchChromaAdjustments")
uLchLightnessAdjustmentsLocation = GLES30.glGetUniformLocation(programId, "uLchLightnessAdjustments")
uPrimaryHueLocation = GLES30.glGetUniformLocation(programId, "uPrimaryHue")
uPrimarySaturationLocation = GLES30.glGetUniformLocation(programId, "uPrimarySaturation")
uPrimaryLightnessLocation = GLES30.glGetUniformLocation(programId, "uPrimaryLightness")
uSTMatrixFragLocation = GLES30.glGetUniformLocation(programId, "uSTMatrix")
uCropRectLocation = GLES30.glGetUniformLocation(programId, "uCropRect")
uApertureLocation = GLES30.glGetUniformLocation(programId, "uAperture")
@@ -1832,6 +1852,15 @@ class LutRenderer : GLSurfaceView.Renderer {
redCurvePoints = redCurvePoints,
greenCurvePoints = greenCurvePoints,
blueCurvePoints = blueCurvePoints,
primaryRedHue = primaryRedHue,
primaryRedSaturation = primaryRedSaturation,
primaryRedLightness = primaryRedLightness,
primaryGreenHue = primaryGreenHue,
primaryGreenSaturation = primaryGreenSaturation,
primaryGreenLightness = primaryGreenLightness,
primaryBlueHue = primaryBlueHue,
primaryBlueSaturation = primaryBlueSaturation,
primaryBlueLightness = primaryBlueLightness,
)
}
@@ -1867,6 +1896,15 @@ class LutRenderer : GLSurfaceView.Renderer {
halation = params.halation
noise = params.noise
lowRes = params.lowRes
primaryRedHue = params.primaryRedHue
primaryRedSaturation = params.primaryRedSaturation
primaryRedLightness = params.primaryRedLightness
primaryGreenHue = params.primaryGreenHue
primaryGreenSaturation = params.primaryGreenSaturation
primaryGreenLightness = params.primaryGreenLightness
primaryBlueHue = params.primaryBlueHue
primaryBlueSaturation = params.primaryBlueSaturation
primaryBlueLightness = params.primaryBlueLightness
setLchAdjustments(
floatArrayOf(
params.skinHue, params.redHue, params.orangeHue, params.yellowHue,
@@ -240,6 +240,9 @@ object Shaders {
uniform float uLchHueAdjustments[9];
uniform float uLchChromaAdjustments[9];
uniform float uLchLightnessAdjustments[9];
uniform vec3 uPrimaryHue;
uniform vec3 uPrimarySaturation;
uniform vec3 uPrimaryLightness;
uniform float uAperture; // 计算光圈 (1.4 ~ 16.0)
uniform vec2 uFocusPoint; // 对焦点 (0.0 ~ 1.0)
@@ -462,6 +465,54 @@ object Shaders {
return clamp(linearToSrgb(mixedLinear), 0.0, 1.0);
}
vec3 applyPrimaryCalibration(vec3 color) {
if (abs(uPrimaryHue.x) < 0.0001 && abs(uPrimaryHue.y) < 0.0001 && abs(uPrimaryHue.z) < 0.0001 &&
abs(uPrimarySaturation.x) < 0.0001 && abs(uPrimarySaturation.y) < 0.0001 && abs(uPrimarySaturation.z) < 0.0001 &&
abs(uPrimaryLightness.x) < 0.0001 && abs(uPrimaryLightness.y) < 0.0001 && abs(uPrimaryLightness.z) < 0.0001) {
return color;
}
float minC = min(min(color.r, color.g), color.b);
vec3 rgb = color - minC;
// 1. Hue Shift (mixes primaries via channel rotation mapping)
float rH = uPrimaryHue.x * 0.35;
float gH = uPrimaryHue.y * 0.35;
float bH = uPrimaryHue.z * 0.35;
vec3 r_vec = vec3(1.0 - abs(rH), rH > 0.0 ? rH : 0.0, rH < 0.0 ? -rH : 0.0);
vec3 g_vec = vec3(gH < 0.0 ? -gH : 0.0, 1.0 - abs(gH), gH > 0.0 ? gH : 0.0);
vec3 b_vec = vec3(bH > 0.0 ? bH : 0.0, bH < 0.0 ? -bH : 0.0, 1.0 - abs(bH));
vec3 mixed = rgb.r * r_vec + rgb.g * g_vec + rgb.b * b_vec;
// 2. Saturation Shift (scales the mixed vector uniformly to strictly preserve hue ratio)
float total_rgb = rgb.r + rgb.g + rgb.b;
if (total_rgb > 0.0001) {
float rS = uPrimarySaturation.x;
float gS = uPrimarySaturation.y;
float bS = uPrimarySaturation.z;
float sat_scale = (rgb.r * rS + rgb.g * gS + rgb.b * bS) / total_rgb;
if (sat_scale > 0.0) {
mixed *= (1.0 + sat_scale);
} else {
vec3 lumaWeights = vec3(0.299, 0.587, 0.114);
float m_luma = dot(mixed, lumaWeights);
mixed = mix(mixed, vec3(m_luma), -sat_scale);
}
}
// 3. Lightness Shift
float rL = uPrimaryLightness.x * 0.5;
float gL = uPrimaryLightness.y * 0.5;
float bL = uPrimaryLightness.z * 0.5;
vec3 light_add = vec3(rgb.r * rL + rgb.g * gL + rgb.b * bL);
return clamp(vec3(minC) + mixed + light_add, 0.0, 1.0);
}
vec3 applyLutCurve(vec3 l, int curveType) {
if (curveType == 0) { // sRGB
return linearToSrgb(l);
@@ -626,6 +677,10 @@ object Shaders {
color.rgb = sanitizeColor(color.rgb);
}
// 6.5. 颜色校准 (Camera Calibration)
color.rgb = applyPrimaryCalibration(color.rgb);
color.rgb = sanitizeColor(color.rgb);
color.rgb = applyLchColorMixer(color.rgb);
color.rgb = sanitizeColor(color.rgb);
@@ -58,6 +58,15 @@ data class ColorRecipeParams(
val magentaHue: Float = 0f,
val magentaChroma: Float = 0f,
val magentaLightness: Float = 0f,
val primaryRedHue: Float = 0f,
val primaryRedSaturation: Float = 0f,
val primaryRedLightness: Float = 0f,
val primaryGreenHue: Float = 0f,
val primaryGreenSaturation: Float = 0f,
val primaryGreenLightness: Float = 0f,
val primaryBlueHue: Float = 0f,
val primaryBlueSaturation: Float = 0f,
val primaryBlueLightness: Float = 0f,
val lutIntensity: Float = 1f, // 0.0 ~ 1.0 (LUT强度,1为完全应用)
val remarks: String = "", // 用户备注
// 曲线控制点 [x0,y0, x1,y1, ...], null = 恒等曲线(无效果)
@@ -119,6 +128,15 @@ data class ColorRecipeParams(
magentaHue == 0f &&
magentaChroma == 0f &&
magentaLightness == 0f &&
primaryRedHue == 0f &&
primaryRedSaturation == 0f &&
primaryRedLightness == 0f &&
primaryGreenHue == 0f &&
primaryGreenSaturation == 0f &&
primaryGreenLightness == 0f &&
primaryBlueHue == 0f &&
primaryBlueSaturation == 0f &&
primaryBlueLightness == 0f &&
remarks.isEmpty() &&
masterCurvePoints == null &&
redCurvePoints == null &&
@@ -179,6 +197,15 @@ data class ColorRecipeParams(
magentaHue == other.magentaHue &&
magentaChroma == other.magentaChroma &&
magentaLightness == other.magentaLightness &&
primaryRedHue == other.primaryRedHue &&
primaryRedSaturation == other.primaryRedSaturation &&
primaryRedLightness == other.primaryRedLightness &&
primaryGreenHue == other.primaryGreenHue &&
primaryGreenSaturation == other.primaryGreenSaturation &&
primaryGreenLightness == other.primaryGreenLightness &&
primaryBlueHue == other.primaryBlueHue &&
primaryBlueSaturation == other.primaryBlueSaturation &&
primaryBlueLightness == other.primaryBlueLightness &&
lutIntensity == other.lutIntensity &&
remarks == other.remarks &&
(masterCurvePoints === other.masterCurvePoints || masterCurvePoints?.contentEquals(other.masterCurvePoints) == true) &&
@@ -262,6 +289,15 @@ enum class RecipeParam(
MAGENTA_HUE(R.string.recipe_param_magenta_hue, -1.0f, 1.0f, 0f),
MAGENTA_CHROMA(R.string.recipe_param_magenta_chroma, -1.0f, 1.0f, 0f),
MAGENTA_LIGHTNESS(R.string.recipe_param_magenta_lightness, -1.0f, 1.0f, 0f),
PRIMARY_RED_HUE(R.string.recipe_param_primary_red_hue, -1.0f, 1.0f, 0f),
PRIMARY_RED_SATURATION(R.string.recipe_param_primary_red_saturation, -1.0f, 1.0f, 0f),
PRIMARY_RED_LIGHTNESS(R.string.recipe_param_primary_red_lightness, -1.0f, 1.0f, 0f),
PRIMARY_GREEN_HUE(R.string.recipe_param_primary_green_hue, -1.0f, 1.0f, 0f),
PRIMARY_GREEN_SATURATION(R.string.recipe_param_primary_green_saturation, -1.0f, 1.0f, 0f),
PRIMARY_GREEN_LIGHTNESS(R.string.recipe_param_primary_green_lightness, -1.0f, 1.0f, 0f),
PRIMARY_BLUE_HUE(R.string.recipe_param_primary_blue_hue, -1.0f, 1.0f, 0f),
PRIMARY_BLUE_SATURATION(R.string.recipe_param_primary_blue_saturation, -1.0f, 1.0f, 0f),
PRIMARY_BLUE_LIGHTNESS(R.string.recipe_param_primary_blue_lightness, -1.0f, 1.0f, 0f),
LUT_INTENSITY(R.string.recipe_param_lut_intensity, 0.0f, 1.0f, 1f);
/**
@@ -319,6 +355,15 @@ enum class RecipeParam(
MAGENTA_HUE -> params.magentaHue
MAGENTA_CHROMA -> params.magentaChroma
MAGENTA_LIGHTNESS -> params.magentaLightness
PRIMARY_RED_HUE -> params.primaryRedHue
PRIMARY_RED_SATURATION -> params.primaryRedSaturation
PRIMARY_RED_LIGHTNESS -> params.primaryRedLightness
PRIMARY_GREEN_HUE -> params.primaryGreenHue
PRIMARY_GREEN_SATURATION -> params.primaryGreenSaturation
PRIMARY_GREEN_LIGHTNESS -> params.primaryGreenLightness
PRIMARY_BLUE_HUE -> params.primaryBlueHue
PRIMARY_BLUE_SATURATION -> params.primaryBlueSaturation
PRIMARY_BLUE_LIGHTNESS -> params.primaryBlueLightness
LUT_INTENSITY -> params.lutIntensity
}
}
@@ -372,6 +417,15 @@ enum class RecipeParam(
MAGENTA_HUE -> params.copy(magentaHue = clampedValue)
MAGENTA_CHROMA -> params.copy(magentaChroma = clampedValue)
MAGENTA_LIGHTNESS -> params.copy(magentaLightness = clampedValue)
PRIMARY_RED_HUE -> params.copy(primaryRedHue = clampedValue)
PRIMARY_RED_SATURATION -> params.copy(primaryRedSaturation = clampedValue)
PRIMARY_RED_LIGHTNESS -> params.copy(primaryRedLightness = clampedValue)
PRIMARY_GREEN_HUE -> params.copy(primaryGreenHue = clampedValue)
PRIMARY_GREEN_SATURATION -> params.copy(primaryGreenSaturation = clampedValue)
PRIMARY_GREEN_LIGHTNESS -> params.copy(primaryGreenLightness = clampedValue)
PRIMARY_BLUE_HUE -> params.copy(primaryBlueHue = clampedValue)
PRIMARY_BLUE_SATURATION -> params.copy(primaryBlueSaturation = clampedValue)
PRIMARY_BLUE_LIGHTNESS -> params.copy(primaryBlueLightness = clampedValue)
LUT_INTENSITY -> params.copy(lutIntensity = clampedValue)
}
}
@@ -49,6 +49,7 @@ fun ColorRecipePanel(
) {
var selectedTabIndex by remember { mutableIntStateOf(0) }
var selectedLchTabIndex by remember { mutableIntStateOf(0) }
var selectedCalibrationTabIndex by remember { mutableIntStateOf(0) }
var isExpanded by remember { mutableStateOf(true) }
val tabs = listOf(
@@ -57,10 +58,11 @@ fun ColorRecipePanel(
R.string.recipe_tab_light, // 2
R.string.recipe_tab_curve, // 3 (曲线)
R.string.recipe_tab_color, // 4
R.string.recipe_tab_lch, // 5
R.string.recipe_tab_texture, // 6
R.string.recipe_tab_lens, // 7
R.string.recipe_tab_remarks, // 8
R.string.recipe_tab_calibration, // 5
R.string.recipe_tab_lch, // 6
R.string.recipe_tab_texture, // 7
R.string.recipe_tab_lens, // 8
R.string.recipe_tab_remarks, // 9
)
val parameterGroups = listOf(
emptyList(), // 0 palette
@@ -80,8 +82,9 @@ fun ColorRecipePanel(
RecipeParam.TINT,
RecipeParam.COLOR
),
emptyList(), // 5 lch (handled specially)
listOf( // 6 texture
emptyList(), // 5 calibration (handled specially)
emptyList(), // 6 lch (handled specially)
listOf( // 7 texture
RecipeParam.VIGNETTE,
RecipeParam.FILM_GRAIN,
RecipeParam.FADE,
@@ -141,6 +144,23 @@ fun ColorRecipePanel(
RecipeParam.MAGENTA_LIGHTNESS,
),
)
val calibrationGroups = listOf(
R.string.recipe_lch_red to listOf(
RecipeParam.PRIMARY_RED_HUE,
RecipeParam.PRIMARY_RED_SATURATION,
RecipeParam.PRIMARY_RED_LIGHTNESS,
),
R.string.recipe_lch_green to listOf(
RecipeParam.PRIMARY_GREEN_HUE,
RecipeParam.PRIMARY_GREEN_SATURATION,
RecipeParam.PRIMARY_GREEN_LIGHTNESS,
),
R.string.recipe_lch_blue to listOf(
RecipeParam.PRIMARY_BLUE_HUE,
RecipeParam.PRIMARY_BLUE_SATURATION,
RecipeParam.PRIMARY_BLUE_LIGHTNESS,
),
)
Column(
modifier = modifier
@@ -182,11 +202,45 @@ fun ColorRecipePanel(
)
}
5 -> {
// Calibration 颜色校准
ColorRingTabs(
count = calibrationGroups.size,
selectedTabIndex = selectedCalibrationTabIndex,
onTabSelected = { selectedCalibrationTabIndex = it },
getColor = { index ->
when (index) {
0 -> Color(0xFFE53935) // Red
1 -> Color(0xFF43A047) // Green
2 -> Color(0xFF1E88E5) // Blue
else -> Color.White
}
}
)
Spacer(modifier = Modifier.height(6.dp))
calibrationGroups[selectedCalibrationTabIndex].second.forEach { param ->
key(param) {
ColorRecipeSlider(
param = param,
value = param.getValue(currentParams),
onValueChange = { newValue ->
onParamChange(param, newValue)
},
onDoubleTap = {
onParamChange(param, param.defaultValue)
}
)
}
}
}
6 -> {
// LCH 颜色混合
LchSecondaryTabs(
tabs = lchGroups.map { it.first },
ColorRingTabs(
count = lchGroups.size,
selectedTabIndex = selectedLchTabIndex,
onTabSelected = { selectedLchTabIndex = it }
onTabSelected = { selectedLchTabIndex = it },
getColor = { getLchTabColor(it) }
)
Spacer(modifier = Modifier.height(6.dp))
@@ -286,24 +340,24 @@ fun ColorRecipePanel(
}
@Composable
private fun LchSecondaryTabs(
tabs: List<Int>,
private fun ColorRingTabs(
count: Int,
selectedTabIndex: Int,
onTabSelected: (Int) -> Unit,
getColor: (Int) -> Color,
modifier: Modifier = Modifier
) {
Row(
modifier = Modifier.fillMaxWidth(),
modifier = modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceEvenly
) {
tabs.forEachIndexed { indexInRow, _ ->
for (indexInRow in 0 until count) {
val isSelected = selectedTabIndex == indexInRow
val ringColor = getLchTabColor(indexInRow)
val ringColor = getColor(indexInRow)
Box(
modifier = Modifier
.weight(1f)
.aspectRatio(1f)
.clip(CircleShape)
.clickable { onTabSelected(indexInRow) }
.padding(6.dp),
@@ -502,6 +556,15 @@ private fun formatParamValue(param: RecipeParam, value: Float): String {
RecipeParam.MAGENTA_HUE,
RecipeParam.MAGENTA_CHROMA,
RecipeParam.MAGENTA_LIGHTNESS,
RecipeParam.PRIMARY_RED_HUE,
RecipeParam.PRIMARY_RED_SATURATION,
RecipeParam.PRIMARY_RED_LIGHTNESS,
RecipeParam.PRIMARY_GREEN_HUE,
RecipeParam.PRIMARY_GREEN_SATURATION,
RecipeParam.PRIMARY_GREEN_LIGHTNESS,
RecipeParam.PRIMARY_BLUE_HUE,
RecipeParam.PRIMARY_BLUE_SATURATION,
RecipeParam.PRIMARY_BLUE_LIGHTNESS,
RecipeParam.VIGNETTE -> {
if (value >= 0) {
String.format("+%.2f", value)
@@ -541,7 +604,10 @@ private fun getParamColor(param: RecipeParam): Color {
RecipeParam.SKIN_LIGHTNESS -> Color(0xFFD7A27A)
RecipeParam.RED_HUE,
RecipeParam.RED_CHROMA,
RecipeParam.RED_LIGHTNESS -> Color(0xFFE53935)
RecipeParam.RED_LIGHTNESS,
RecipeParam.PRIMARY_RED_HUE,
RecipeParam.PRIMARY_RED_SATURATION,
RecipeParam.PRIMARY_RED_LIGHTNESS -> Color(0xFFE53935)
RecipeParam.ORANGE_HUE,
RecipeParam.ORANGE_CHROMA,
RecipeParam.ORANGE_LIGHTNESS -> Color(0xFFFB8C00)
@@ -550,13 +616,19 @@ private fun getParamColor(param: RecipeParam): Color {
RecipeParam.YELLOW_LIGHTNESS -> Color(0xFFFDD835)
RecipeParam.GREEN_HUE,
RecipeParam.GREEN_CHROMA,
RecipeParam.GREEN_LIGHTNESS -> Color(0xFF43A047)
RecipeParam.GREEN_LIGHTNESS,
RecipeParam.PRIMARY_GREEN_HUE,
RecipeParam.PRIMARY_GREEN_SATURATION,
RecipeParam.PRIMARY_GREEN_LIGHTNESS -> Color(0xFF43A047)
RecipeParam.CYAN_HUE,
RecipeParam.CYAN_CHROMA,
RecipeParam.CYAN_LIGHTNESS -> Color(0xFF00ACC1)
RecipeParam.BLUE_HUE,
RecipeParam.BLUE_CHROMA,
RecipeParam.BLUE_LIGHTNESS -> Color(0xFF1E88E5)
RecipeParam.BLUE_LIGHTNESS,
RecipeParam.PRIMARY_BLUE_HUE,
RecipeParam.PRIMARY_BLUE_SATURATION,
RecipeParam.PRIMARY_BLUE_LIGHTNESS -> Color(0xFF1E88E5)
RecipeParam.PURPLE_HUE,
RecipeParam.PURPLE_CHROMA,
RecipeParam.PURPLE_LIGHTNESS -> Color(0xFF8E24AA)
@@ -276,6 +276,15 @@
<string name="recipe_param_magenta_hue">品红 色相</string>
<string name="recipe_param_magenta_chroma">品红 彩度</string>
<string name="recipe_param_magenta_lightness">品红 明度</string>
<string name="recipe_param_primary_red_hue">红原色 色相</string>
<string name="recipe_param_primary_red_saturation">红原色 饱和度</string>
<string name="recipe_param_primary_red_lightness">红原色 明度</string>
<string name="recipe_param_primary_green_hue">绿原色 色相</string>
<string name="recipe_param_primary_green_saturation">绿原色 饱和度</string>
<string name="recipe_param_primary_green_lightness">绿原色 明度</string>
<string name="recipe_param_primary_blue_hue">蓝原色 色相</string>
<string name="recipe_param_primary_blue_saturation">蓝原色 饱和度</string>
<string name="recipe_param_primary_blue_lightness">蓝原色 明度</string>
<!-- Color Recipe Tabs -->
<string name="recipe_tab_basic">基础</string>
@@ -283,6 +292,7 @@
<string name="recipe_tab_lch">LCH</string>
<string name="recipe_tab_light">亮度</string>
<string name="recipe_tab_curve">曲线</string>
<string name="recipe_tab_calibration">校准</string>
<string name="recipe_lch_skin">肤色</string>
<string name="recipe_lch_red">红</string>
<string name="recipe_lch_orange">橙</string>
+10
View File
@@ -281,6 +281,15 @@
<string name="recipe_param_magenta_hue">Magenta Hue</string>
<string name="recipe_param_magenta_chroma">Magenta Chroma</string>
<string name="recipe_param_magenta_lightness">Magenta Light</string>
<string name="recipe_param_primary_red_hue">Red Primary Hue</string>
<string name="recipe_param_primary_red_saturation">Red Primary Sat</string>
<string name="recipe_param_primary_red_lightness">Red Primary Light</string>
<string name="recipe_param_primary_green_hue">Green Primary Hue</string>
<string name="recipe_param_primary_green_saturation">Green Primary Sat</string>
<string name="recipe_param_primary_green_lightness">Green Primary Light</string>
<string name="recipe_param_primary_blue_hue">Blue Primary Hue</string>
<string name="recipe_param_primary_blue_saturation">Blue Primary Sat</string>
<string name="recipe_param_primary_blue_lightness">Blue Primary Light</string>
<!-- Color Recipe Tabs -->
<string name="recipe_tab_basic">Basic</string>
@@ -288,6 +297,7 @@
<string name="recipe_tab_lch">LCH</string>
<string name="recipe_tab_light">Light</string>
<string name="recipe_tab_curve">Curve</string>
<string name="recipe_tab_calibration">Calibration</string>
<string name="recipe_lch_skin">Skin</string>
<string name="recipe_lch_red">Red</string>
<string name="recipe_lch_orange">Orange</string>