fix: watermark用エフェクトは別で定義し直す

This commit is contained in:
kakkokari-gtyih
2025-06-15 12:15:57 +09:00
parent 74fa65f41f
commit 92b2b5e006
7 changed files with 69 additions and 53 deletions
+28 -28
View File
@@ -12113,6 +12113,14 @@ export interface Locale extends ILocale {
* *
*/ */
"stripe": string; "stripe": string;
/**
*
*/
"stripeWidth": string;
/**
*
*/
"stripeFrequency": string;
/** /**
* *
*/ */
@@ -12121,6 +12129,26 @@ export interface Locale extends ILocale {
* *
*/ */
"checker": string; "checker": string;
/**
*
*/
"polkadotMainDotOpacity": string;
/**
*
*/
"polkadotMainDotRadius": string;
/**
*
*/
"polkadotSubDotOpacity": string;
/**
*
*/
"polkadotSubDotRadius": string;
/**
*
*/
"polkadotSubDotDivisions": string;
}; };
"_imageEffector": { "_imageEffector": {
/** /**
@@ -12298,34 +12326,6 @@ export interface Locale extends ILocale {
* *
*/ */
"blueComponent": string; "blueComponent": string;
/**
*
*/
"polkadotMainDotOpacity": string;
/**
*
*/
"polkadotMainDotRadius": string;
/**
*
*/
"polkadotSubDotOpacity": string;
/**
*
*/
"polkadotSubDotRadius": string;
/**
*
*/
"polkadotSubDotDivisions": string;
/**
*
*/
"stripeWidth": string;
/**
*
*/
"stripeFrequency": string;
/** /**
* *
*/ */
+7 -7
View File
@@ -3243,8 +3243,15 @@ _watermarkEditor:
advanced: "高度" advanced: "高度"
angle: "角度" angle: "角度"
stripe: "ストライプ" stripe: "ストライプ"
stripeWidth: "ラインの幅"
stripeFrequency: "ラインの数"
polkadot: "ポルカドット" polkadot: "ポルカドット"
checker: "チェッカー" checker: "チェッカー"
polkadotMainDotOpacity: "メインドットの不透明度"
polkadotMainDotRadius: "メインドットの大きさ"
polkadotSubDotOpacity: "サブドットの不透明度"
polkadotSubDotRadius: "サブドットの大きさ"
polkadotSubDotDivisions: "サブドットの数"
_imageEffector: _imageEffector:
title: "エフェクト" title: "エフェクト"
@@ -3294,13 +3301,6 @@ _imageEffector:
redComponent: "赤色成分" redComponent: "赤色成分"
greenComponent: "緑色成分" greenComponent: "緑色成分"
blueComponent: "青色成分" blueComponent: "青色成分"
polkadotMainDotOpacity: "メインドットの不透明度"
polkadotMainDotRadius: "メインドットの大きさ"
polkadotSubDotOpacity: "サブドットの不透明度"
polkadotSubDotRadius: "サブドットの大きさ"
polkadotSubDotDivisions: "サブドットの数"
stripeWidth: "ラインの幅"
stripeFrequency: "ラインの数"
threshold: "しきい値" threshold: "しきい値"
centerX: "中心X" centerX: "中心X"
centerY: "中心Y" centerY: "中心Y"
@@ -74,10 +74,6 @@ type ImageEffectorFxParamDef = NumberParamDef | NumberEnumParamDef | BooleanPara
export type ImageEffectorFxParamDefs = Record<string, ImageEffectorFxParamDef>; export type ImageEffectorFxParamDefs = Record<string, ImageEffectorFxParamDef>;
export type ParamDefToPremitiveRecord<PS extends ImageEffectorFxParamDefs> = {
[key in keyof PS]: PS[key]['type'] extends keyof ParamTypeToPrimitive ? ParamTypeToPrimitive[PS[key]['type']] : never;
};
export function defineImageEffectorFx<ID extends string, PS extends ImageEffectorFxParamDefs, US extends string[]>(fx: ImageEffectorFx<ID, PS, US>) { export function defineImageEffectorFx<ID extends string, PS extends ImageEffectorFxParamDefs, US extends string[]>(fx: ImageEffectorFx<ID, PS, US>) {
return fx; return fx;
} }
@@ -30,10 +30,10 @@ export const FXS = [
FX_distort, FX_distort,
FX_threshold, FX_threshold,
FX_zoomLines, FX_zoomLines,
FX_stripe,
FX_polkadot,
FX_checker, FX_checker,
FX_chromaticAberration, FX_chromaticAberration,
FX_tearing, FX_tearing,
FX_blockNoise, FX_blockNoise,
FX_stripe, // Primarily used for watermark
FX_polkadot, // Primarily used for watermark
] as const satisfies ImageEffectorFx<string, any>[]; ] as const satisfies ImageEffectorFx<string, any>[];
@@ -78,6 +78,7 @@ void main() {
} }
`; `;
// Primarily used for watermark
export const FX_polkadot = defineImageEffectorFx({ export const FX_polkadot = defineImageEffectorFx({
id: 'polkadot' as const, id: 'polkadot' as const,
name: i18n.ts._imageEffector._fxs.polkadot, name: i18n.ts._imageEffector._fxs.polkadot,
@@ -102,7 +103,7 @@ export const FX_polkadot = defineImageEffectorFx({
step: 0.1, step: 0.1,
}, },
majorRadius: { majorRadius: {
label: i18n.ts._imageEffector._fxProps.polkadotMainDotRadius, label: i18n.ts._watermarkEditor.polkadotMainDotRadius,
type: 'number' as const, type: 'number' as const,
default: 0.1, default: 0.1,
min: 0.0, min: 0.0,
@@ -110,7 +111,7 @@ export const FX_polkadot = defineImageEffectorFx({
step: 0.01, step: 0.01,
}, },
majorOpacity: { majorOpacity: {
label: i18n.ts._imageEffector._fxProps.polkadotMainDotOpacity, label: i18n.ts._watermarkEditor.polkadotMainDotOpacity,
type: 'number' as const, type: 'number' as const,
default: 0.75, default: 0.75,
min: 0.0, min: 0.0,
@@ -119,7 +120,7 @@ export const FX_polkadot = defineImageEffectorFx({
toViewValue: v => Math.round(v * 100) + '%', toViewValue: v => Math.round(v * 100) + '%',
}, },
minorDivisions: { minorDivisions: {
label: i18n.ts._imageEffector._fxProps.polkadotSubDotDivisions, label: i18n.ts._watermarkEditor.polkadotSubDotDivisions,
type: 'number' as const, type: 'number' as const,
default: 4, default: 4,
min: 0, min: 0,
@@ -127,7 +128,7 @@ export const FX_polkadot = defineImageEffectorFx({
step: 1, step: 1,
}, },
minorRadius: { minorRadius: {
label: i18n.ts._imageEffector._fxProps.polkadotSubDotRadius, label: i18n.ts._watermarkEditor.polkadotSubDotRadius,
type: 'number' as const, type: 'number' as const,
default: 0.25, default: 0.25,
min: 0.0, min: 0.0,
@@ -135,7 +136,7 @@ export const FX_polkadot = defineImageEffectorFx({
step: 0.01, step: 0.01,
}, },
minorOpacity: { minorOpacity: {
label: i18n.ts._imageEffector._fxProps.polkadotSubDotOpacity, label: i18n.ts._watermarkEditor.polkadotSubDotOpacity,
type: 'number' as const, type: 'number' as const,
default: 0.5, default: 0.5,
min: 0.0, min: 0.0,
@@ -48,6 +48,7 @@ void main() {
} }
`; `;
// Primarily used for watermark
export const FX_stripe = defineImageEffectorFx({ export const FX_stripe = defineImageEffectorFx({
id: 'stripe' as const, id: 'stripe' as const,
name: i18n.ts._imageEffector._fxs.stripe, name: i18n.ts._imageEffector._fxs.stripe,
@@ -64,7 +65,7 @@ export const FX_stripe = defineImageEffectorFx({
toViewValue: v => Math.round(v * 90) + '°', toViewValue: v => Math.round(v * 90) + '°',
}, },
frequency: { frequency: {
label: i18n.ts._imageEffector._fxProps.stripeFrequency, label: i18n.ts._watermarkEditor.stripeFrequency,
type: 'number' as const, type: 'number' as const,
default: 10.0, default: 10.0,
min: 1.0, min: 1.0,
@@ -72,7 +73,7 @@ export const FX_stripe = defineImageEffectorFx({
step: 0.1, step: 0.1,
}, },
threshold: { threshold: {
label: i18n.ts._imageEffector._fxProps.stripeWidth, label: i18n.ts._watermarkEditor.stripeWidth,
type: 'number' as const, type: 'number' as const,
default: 0.1, default: 0.1,
min: 0.0, min: 0.0,
+23 -5
View File
@@ -7,7 +7,7 @@ import { FX_watermarkPlacement } from '@/utility/image-effector/fxs/watermarkPla
import { FX_stripe } from '@/utility/image-effector/fxs/stripe.js'; import { FX_stripe } from '@/utility/image-effector/fxs/stripe.js';
import { FX_polkadot } from '@/utility/image-effector/fxs/polkadot.js'; import { FX_polkadot } from '@/utility/image-effector/fxs/polkadot.js';
import { FX_checker } from '@/utility/image-effector/fxs/checker.js'; import { FX_checker } from '@/utility/image-effector/fxs/checker.js';
import type { ImageEffectorFx, ImageEffectorLayer, ParamDefToPremitiveRecord } from '@/utility/image-effector/ImageEffector.js'; import type { ImageEffectorFx, ImageEffectorLayer } from '@/utility/image-effector/ImageEffector.js';
import { ImageEffector } from '@/utility/image-effector/ImageEffector.js'; import { ImageEffector } from '@/utility/image-effector/ImageEffector.js';
export const WATERMARK_FXS = [ export const WATERMARK_FXS = [
@@ -40,16 +40,34 @@ export type WatermarkPreset = {
angle: number; angle: number;
align: { x: 'left' | 'center' | 'right'; y: 'top' | 'center' | 'bottom' }; align: { x: 'left' | 'center' | 'right'; y: 'top' | 'center' | 'bottom' };
opacity: number; opacity: number;
} | ({ } | {
id: string; id: string;
type: 'stripe'; type: 'stripe';
} & ParamDefToPremitiveRecord<typeof FX_stripe.params>) | ({ angle: number;
frequency: number;
threshold: number;
color: [r: number, g: number, b: number];
opacity: number;
} | {
id: string; id: string;
type: 'polkadot'; type: 'polkadot';
} & ParamDefToPremitiveRecord<typeof FX_polkadot.params>) | ({ angle: number;
scale: number;
majorRadius: number;
majorOpacity: number;
minorDivisions: number;
minorRadius: number;
minorOpacity: number;
color: [r: number, g: number, b: number];
opacity: number;
} | {
id: string; id: string;
type: 'checker'; type: 'checker';
} & ParamDefToPremitiveRecord<typeof FX_checker.params>))[]; angle: number;
scale: number;
color: [r: number, g: number, b: number];
opacity: number;
})[];
}; };
export class WatermarkRenderer { export class WatermarkRenderer {