mirror of
https://github.com/Ku6epXBOCTuK/easy-png-tools.git
synced 2026-09-14 21:46:35 +00:00
feat: update text tools to new types
This commit is contained in:
@@ -3,7 +3,7 @@ import { drawTextBlock, drawTextTile } from "../core/domText";
|
|||||||
import type { Position9 } from "../core/textdraw";
|
import type { Position9 } from "../core/textdraw";
|
||||||
import type { FontStyle, Plate } from "../registry-schema";
|
import type { FontStyle, Plate } from "../registry-schema";
|
||||||
import { field, toolSchema } from "../registry-schema";
|
import { field, toolSchema } from "../registry-schema";
|
||||||
import type { ToolEntry } from "./types";
|
import { imgTool, type ToolEntry } from "./types";
|
||||||
|
|
||||||
interface AddTextParams {
|
interface AddTextParams {
|
||||||
text: string;
|
text: string;
|
||||||
@@ -47,7 +47,8 @@ const addText: ToolEntry<AddTextParams> = {
|
|||||||
category: "text",
|
category: "text",
|
||||||
domOnly: true,
|
domOnly: true,
|
||||||
schema: addTextSchema,
|
schema: addTextSchema,
|
||||||
run: (img, p) =>
|
input: "image",
|
||||||
|
run: imgTool((img, p) =>
|
||||||
drawTextBlock(img, {
|
drawTextBlock(img, {
|
||||||
text: p.text,
|
text: p.text,
|
||||||
fontSize: p.style.size,
|
fontSize: p.style.size,
|
||||||
@@ -60,6 +61,7 @@ const addText: ToolEntry<AddTextParams> = {
|
|||||||
plateColor: p.plate.enabled ? p.plate.color : undefined,
|
plateColor: p.plate.enabled ? p.plate.color : undefined,
|
||||||
plateOpacityPercent: p.plate.opacity,
|
plateOpacityPercent: p.plate.opacity,
|
||||||
}),
|
}),
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
interface DateStampParams {
|
interface DateStampParams {
|
||||||
@@ -107,7 +109,8 @@ const dateStamp: ToolEntry<DateStampParams> = {
|
|||||||
category: "text",
|
category: "text",
|
||||||
domOnly: true,
|
domOnly: true,
|
||||||
schema: dateStampSchema,
|
schema: dateStampSchema,
|
||||||
run: (img, p) =>
|
input: "image",
|
||||||
|
run: imgTool((img, p) =>
|
||||||
drawTextBlock(img, {
|
drawTextBlock(img, {
|
||||||
text: formatStamp(new Date(), p.format),
|
text: formatStamp(new Date(), p.format),
|
||||||
fontSize: p.style.size,
|
fontSize: p.style.size,
|
||||||
@@ -120,6 +123,7 @@ const dateStamp: ToolEntry<DateStampParams> = {
|
|||||||
plateColor: p.plate.enabled ? p.plate.color : undefined,
|
plateColor: p.plate.enabled ? p.plate.color : undefined,
|
||||||
plateOpacityPercent: p.plate.opacity,
|
plateOpacityPercent: p.plate.opacity,
|
||||||
}),
|
}),
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
interface WatermarkTileParams {
|
interface WatermarkTileParams {
|
||||||
@@ -169,7 +173,8 @@ const watermarkTile: ToolEntry<WatermarkTileParams> = {
|
|||||||
category: "text",
|
category: "text",
|
||||||
domOnly: true,
|
domOnly: true,
|
||||||
schema: watermarkTileSchema,
|
schema: watermarkTileSchema,
|
||||||
run: (img, p) =>
|
input: "image",
|
||||||
|
run: imgTool((img, p) =>
|
||||||
drawTextTile(img, {
|
drawTextTile(img, {
|
||||||
text: p.text,
|
text: p.text,
|
||||||
fontSize: p.style.size,
|
fontSize: p.style.size,
|
||||||
@@ -181,6 +186,7 @@ const watermarkTile: ToolEntry<WatermarkTileParams> = {
|
|||||||
stepY: p.stepY,
|
stepY: p.stepY,
|
||||||
angleDeg: p.angle,
|
angleDeg: p.angle,
|
||||||
}),
|
}),
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const textEntries = [addText, dateStamp, watermarkTile];
|
export const textEntries = [addText, dateStamp, watermarkTile];
|
||||||
|
|||||||
Reference in New Issue
Block a user