From 244f5a27933405c3318ab29859720b2b9a0c7e40 Mon Sep 17 00:00:00 2001
From: syuilo <4439005+syuilo@users.noreply.github.com>
Date: Sun, 2 Nov 2025 18:57:01 +0900
Subject: [PATCH] wip
---
locales/index.d.ts | 8 ++++++
locales/ja-JP.yml | 2 ++
.../components/MkImageFrameEditorDialog.vue | 28 ++++++++++++++++++-
.../src/utility/image-effector/fxs/frame.glsl | 11 ++++++--
.../src/utility/image-effector/fxs/frame.ts | 7 ++++-
.../src/utility/image-frame-renderer.ts | 4 +--
6 files changed, 52 insertions(+), 8 deletions(-)
diff --git a/locales/index.d.ts b/locales/index.d.ts
index e753cebeb2..22d17dfc14 100644
--- a/locales/index.d.ts
+++ b/locales/index.d.ts
@@ -5658,6 +5658,14 @@ export interface Locale extends ILocale {
* 二次元コード
*/
"withQrCode": string;
+ /**
+ * 背景色
+ */
+ "backgroundColor": string;
+ /**
+ * 文字色
+ */
+ "textColor": string;
};
"_compression": {
"_quality": {
diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml
index d8536aa4c4..afc2bc1c51 100644
--- a/locales/ja-JP.yml
+++ b/locales/ja-JP.yml
@@ -1411,6 +1411,8 @@ _imageFrameEditor:
captionSub: "キャプション(小)"
availableVariables: "利用可能な変数"
withQrCode: "二次元コード"
+ backgroundColor: "背景色"
+ textColor: "文字色"
_compression:
_quality:
diff --git a/packages/frontend/src/components/MkImageFrameEditorDialog.vue b/packages/frontend/src/components/MkImageFrameEditorDialog.vue
index 388a29d4e3..ac3e05ed98 100644
--- a/packages/frontend/src/components/MkImageFrameEditorDialog.vue
+++ b/packages/frontend/src/components/MkImageFrameEditorDialog.vue
@@ -35,6 +35,14 @@ SPDX-License-Identifier: AGPL-3.0-only
{{ i18n.ts._imageFrameEditor.borderThickness }}
+ { const c = getRgb(v); if (c != null) frame.bgColor = c; }">
+ {{ i18n.ts._imageFrameEditor.backgroundColor }}
+
+
+ { const c = getRgb(v); if (c != null) frame.fgColor = c; }">
+ {{ i18n.ts._imageFrameEditor.textColor }}
+
+
{{ i18n.ts._imageFrameEditor.header }}
@@ -180,7 +188,7 @@ const frame = reactive(deepClone(props.frame) ?? {
centered: false,
withQrCode: true,
},
- bgColor: [255, 255, 255],
+ bgColor: [1, 1, 1],
fgColor: [0, 0, 0],
});
@@ -321,6 +329,24 @@ async function save() {
emit('ok', preset);
}
+
+function getHex(c: [number, number, number]) {
+ return `#${c.map(x => (x * 255).toString(16).padStart(2, '0')).join('')}`;
+}
+
+function getRgb(hex: string | number): [number, number, number] | null {
+ if (
+ typeof hex === 'number' ||
+ typeof hex !== 'string' ||
+ !/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(hex)
+ ) {
+ return null;
+ }
+
+ const m = hex.slice(1).match(/[0-9a-fA-F]{2}/g);
+ if (m == null) return [0, 0, 0];
+ return m.map(x => parseInt(x, 16) / 255) as [number, number, number];
+}