Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54940ccf87 |
@@ -2,6 +2,7 @@
|
||||
|
||||
Condensed version-by-version index of DEVLOG.md (each line: version + one-line summary of what changed and why). Full rationale, code details, and "How to apply" lessons live in the excluded DEVLOG.md itself; this index exists so graphify can extract a queryable semantic node per release without feeding the full log to the local Ollama model. Regenerate with `python tools/generate_doc_index.py devlog` whenever DEVLOG.md changes.
|
||||
|
||||
- **v0.9.3(2026-11-05)** — Image Edit: Drawツールのカラーパレット・ショートカット・スポイト(Comic Creator v1.67.0 から移植)
|
||||
- **v0.9.2(2026-11-03)** — Selectorイベントループ有効時に画像が壊れて届く不具合を修正
|
||||
- **v0.9.1(2026-11-03)** — TagSpace: 選んだタグだけを追加 / タグのカッコをエスケープして追加
|
||||
- **v0.9.0(2026-11-03)** — マニュアル(画像なし配布版)を v0.9.0 に改訂
|
||||
|
||||
@@ -2,6 +2,30 @@
|
||||
|
||||
---
|
||||
|
||||
## v0.9.3(2026-11-05)
|
||||
|
||||
### Image Edit: Drawツールのカラーパレット・ショートカット・スポイト(Comic Creator v1.67.0 から移植)
|
||||
|
||||
- 新規 `static/js/image-edit/DrawPalette.js`: Drawツールの2段目(`ie-tool-options`)に色1/色2、基本色20色、カスタム色20枠を表示する。右クリックで現在の色の登録・色の編集・削除(カスタム色)・初期の色に戻す(変更済みの基本色)。保存先は localStorage `ie_draw_palette_v1`。
|
||||
- `image-edit-tab.js`: 色の変更を `_setDrawColor` に集約し、モードは `_setDrawMode`、サイズは `_setDrawBrushSize` / `_stepDrawBrushSize` に分離。
|
||||
- ショートカット(Draw中のみ): `D` Draw / `E` Erase / `X` 色1・色2切替 / `[` `]` サイズ増減(1〜10pxは1、10〜50pxは5、50〜200pxは10刻み)/ `B` ブラシ選択の開閉。ブラシ選択の表示中は D/E/X/[/] を無効にし、Escで閉じる。他のツールからのBはこれまでどおりDrawへの切り替え。
|
||||
- スポイト: WFSのDrawツールには無かったためCC版から追加。右パネルのColorの隣のボタンからキャンバスの色を拾う。Esc・再クリック・ツール切替・キャンバス外クリック・Closeで解除。
|
||||
- ブラシの初期色を赤から黒に変更(色1/色2 = 黒/白)。
|
||||
|
||||
**CC版との違い**
|
||||
|
||||
- 色の引き継ぎは、Drawツールの表示時ではなく `_initCanvases` で `DrawTool` を作り直す時点で行う。
|
||||
- スポイトは `ie-canvas-draw` から色を読むため、アクティブレイヤーのみの表示なら合成し直してから読む。
|
||||
- 右クリックメニューを開いたままツールを切り替えても残らないよう、`_renderToolOptions` で閉じる。
|
||||
|
||||
**検証(Playwright、ComfyUI :8189)**: パレットからの描画色、登録と再読み込み後の保持、重複登録の通知、右クリックメニュー、基本色の復元、Color入力との連動、各ショートカット、入力欄やCtrl/Alt同時押しで反応しないこと、サイズの刻み、ブラシ選択の開閉、ブラシ未登録時の通知、Newでの色の引き継ぎ、スポイトの取得と解除、Undo履歴が増えないこと、別レイヤーの色の取得を確認。コンソールエラーなし。
|
||||
|
||||
**未確認**: 「色を編集…」で開くブラウザ標準のカラーピッカーの表示と、日本語キーボードでの `[` `]` の実打鍵。
|
||||
|
||||
**補足**: 透明部分をスポイトすると黒を拾う(CCと同じ)。描いた線から拾うと値が1ずれることがある。READMEのバージョンバッジが0.8.11のままだったので0.9.3に更新した。
|
||||
|
||||
---
|
||||
|
||||
## v0.9.2(2026-11-03)
|
||||
|
||||
### Selectorイベントループ有効時に画像が壊れて届く不具合を修正
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ A comprehensive workflow, asset management, and generation UI plugin for [ComfyU
|
||||
- Built-in AI tools (translation and more)
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
## Features (tab -> feature names)
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ A comprehensive workflow, asset management, and generation UI plugin for [ComfyU
|
||||
- Built-in AI tools (translation and more)
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
## Screenshots
|
||||
|
||||
@@ -442,7 +442,7 @@ An experimental batch generator: runs the workflow currently loaded in GenerateU
|
||||
- **New button** — create a blank canvas with custom dimensions (WxH prompt); clears all existing layers and automatically adds an empty Layer 1 (v0.3.70)
|
||||
- **Tools** — Select (V), Draw (B), Text (T), Shape (S), Fill (G), Mask (🎭), Blur (≈), BG Remove (⬚), Filter (★), Inpaint (🩹); tool options bar updates per active tool
|
||||
- **Select** — click to select; drag to move; drag corner handles to resize; drag circle handle to rotate; Flip H / Flip V / Rotate angle in the options bar; double-click a text layer to re-edit its content
|
||||
- **Draw** — freehand brush; options: color, brush size, blend mode; paints directly onto the active draw layer while all other layers remain visible; brush cursor shown as a size-accurate circle; strokes can start from outside the canvas margin and continue past the edge; **pen tablet support** (v0.6.2) — brush size and opacity respond to pen pressure (mouse behaves exactly as before); the canvas listens for Pointer Events so pen, touch, and mouse all work through the same code path
|
||||
- **Draw** — freehand brush; options: color, brush size, blend mode; paints directly onto the active draw layer while all other layers remain visible; brush cursor shown as a size-accurate circle; strokes can start from outside the canvas margin and continue past the edge; **pen tablet support** (v0.6.2) — brush size and opacity respond to pen pressure (mouse behaves exactly as before); the canvas listens for Pointer Events so pen, touch, and mouse all work through the same code path; **color palette** on the second row — Color 1/Color 2, 20 basic colors, and 20 custom slots (registered and edited colors are saved in the browser); **eyedropper** button next to Color picks a color from the canvas (`Esc` cancels); shortcuts while Draw is active: `D` Draw, `E` Erase, `X` switch Color 1/2, `[` `]` brush size, `B` open or close the brush picker (`Esc` also closes it)
|
||||
- **Text** — click to place; configure font, size, bold/italic, align, and color; placed as an exact-size text layer sized to the measured bounding box; double-click to re-edit
|
||||
- **Shape** — drag to draw geometric shapes (Rect / Ellipse / Line / FreeLine); options: shape type, Rounded toggle (Rect/Ellipse), Fill color, Stroke color + width, Opacity; each committed shape becomes an independent draw layer; Stroke None hidden for Line/FreeLine (stroke always active)
|
||||
- **Fill** (v0.6.2) — bucket fill; click a contiguous same-color region on the active layer to flood-fill it (scanline-based, ported from the Comic Creator plugin's Image tab); **Properties pane**: Mode (Solid / Gradient) — Solid: Color picker; Gradient: Shape (Linear / Radial), a draggable color-stop Ramp (click a stop to select it, drag to reposition, +/- to add/remove stops, color swatch to edit the selected stop's color), and a Direction dial (drag to set angle/radius); both Tolerance (0–255, color-match threshold) and Opacity apply to either mode; Ramp and Direction dial are pointer-event based with pointer capture, so pen tablets work the same as mouse
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "comfyui-workflow-studio"
|
||||
description = "A comprehensive workflow, asset management, and generation UI plugin for ComfyUI. Manage workflows, models, images, and prompts; batch generation and Image Feeder in the GenerateUI tab; library side panel with canvas drag & drop and AI tools."
|
||||
version = "0.9.2"
|
||||
version = "0.9.3"
|
||||
license = { file = "LICENSE" }
|
||||
requires-python = ">= 3.10"
|
||||
dependencies = ["jinja2"]
|
||||
|
||||
@@ -466,3 +466,103 @@
|
||||
background: var(--wfm-border);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
/* Draw tool palette */
|
||||
.ie-palette-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 14px;
|
||||
}
|
||||
|
||||
.ie-palette-wells {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.ie-palette-well,
|
||||
.ie-palette-swatch {
|
||||
padding: 0;
|
||||
border-radius: 50%;
|
||||
background: var(--swatch, transparent);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ie-palette-well {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border: 1px solid var(--wfm-text-secondary);
|
||||
}
|
||||
|
||||
.ie-palette-well.is-active {
|
||||
outline: 2px solid var(--wfm-primary);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.ie-palette-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(10, 16px);
|
||||
grid-auto-rows: 16px;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.ie-palette-swatch {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border: 1px solid rgba(128, 128, 128, 0.7);
|
||||
}
|
||||
|
||||
.ie-palette-swatch.is-empty {
|
||||
border-color: var(--wfm-text-secondary);
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.ie-palette-swatch:hover,
|
||||
.ie-palette-swatch:focus-visible,
|
||||
.ie-palette-well:focus-visible {
|
||||
outline: 1px solid var(--wfm-text);
|
||||
outline-offset: 1px;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.ie-palette-swatch.is-current {
|
||||
outline: 2px solid var(--wfm-primary);
|
||||
outline-offset: 0;
|
||||
}
|
||||
|
||||
.ie-palette-picker {
|
||||
position: fixed;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.ie-palette-menu {
|
||||
position: fixed;
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 150px;
|
||||
padding: 4px;
|
||||
border: 1px solid var(--wfm-border);
|
||||
border-radius: 4px;
|
||||
background: var(--wfm-surface);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.ie-palette-menu button {
|
||||
padding: 5px 10px;
|
||||
border: 0;
|
||||
border-radius: 3px;
|
||||
background: transparent;
|
||||
color: var(--wfm-text);
|
||||
font-size: 12px;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ie-palette-menu button:hover {
|
||||
background: var(--wfm-surface-hover);
|
||||
}
|
||||
|
||||
@@ -645,6 +645,8 @@ function applyI18nToHtml() {
|
||||
"wfm-help-imageedit-26": "helpImageEdit26", "wfm-help-imageedit-27": "helpImageEdit27",
|
||||
"wfm-help-imageedit-28": "helpImageEdit28", "wfm-help-imageedit-29": "helpImageEdit29",
|
||||
"wfm-help-imageedit-30": "helpImageEdit30",
|
||||
"wfm-help-imageedit-draw-palette": "helpImageEditDrawPalette", "wfm-help-imageedit-draw-kbd": "helpImageEditDrawKbd",
|
||||
"wfm-help-imageedit-tabkbd-draw": "helpImageEditDrawKbd",
|
||||
"wfm-help-imageedit-31": "helpImageEdit31", "wfm-help-imageedit-32": "helpImageEdit32",
|
||||
"wfm-help-imageedit-33": "helpImageEdit33", "wfm-help-imageedit-34": "helpImageEdit34",
|
||||
"wfm-help-imageedit-7b": "helpImageEdit7b", "wfm-help-imageedit-7c": "helpImageEdit7c",
|
||||
|
||||
@@ -1387,6 +1387,24 @@ const LANGUAGES = {
|
||||
helpImageEditGmicInstall2: "Extract the zip to any folder (e.g. C:\\tools\\gmic); no installer required",
|
||||
helpImageEditGmicInstall3: "Open Settings → G'MIC-Qt Executable Path, enter the full path to gmic_qt.exe (e.g. C:\\tools\\gmic\\gmic_qt.exe), then click Save",
|
||||
helpImageEditTabKbdTitle: "Image Edit Tab Shortcuts",
|
||||
imageEditPaletteColor1: "Color 1",
|
||||
imageEditPaletteColor2: "Color 2",
|
||||
imageEditPaletteBase: "Basic",
|
||||
imageEditPaletteCustom: "Custom",
|
||||
imageEditPaletteAddTitle: "Register the current color in the next empty custom slot",
|
||||
imageEditPaletteEmptyTitle: "Click to register the current color; right-click to choose a color",
|
||||
imageEditPaletteSwatchTitle: "Click to use; right-click to register or edit",
|
||||
imageEditPaletteRegisterCurrent: "Register current color",
|
||||
imageEditPaletteEditColor: "Edit color…",
|
||||
imageEditPalettePickColor: "Choose color to register…",
|
||||
imageEditPaletteDelete: "Delete",
|
||||
imageEditPaletteResetBase: "Restore default color",
|
||||
imageEditPaletteExists: "This color is already registered",
|
||||
imageEditPaletteFull: "All custom color slots are full. Right-click a slot to overwrite or delete it",
|
||||
imageEditNoAbrBrushes: "No brushes available. Import ABR brushes in Mask Editor One",
|
||||
helpImageEditDrawPalette: "Draw color palette (second row): Color 1/Color 2, 20 basic colors, and 20 custom slots. Click a color to paint with it. Use + or click an empty slot to register the current color; right-click a color to register, edit, or delete it (basic colors can be changed and restored). Registered colors are saved per browser. The eyedropper button next to Color picks a color from the canvas (Esc cancels)",
|
||||
imageEditPixelColorFail: "Could not read pixel color",
|
||||
helpImageEditDrawKbd: "While Draw is active: D Draw / E Erase / X switch Color 1/2 / [ ] brush size / B open or close the brush picker (Esc also closes it)",
|
||||
helpShortcutsTitle: "Keyboard Shortcuts",
|
||||
helpShortcuts1: "Escape: Close modal/panel",
|
||||
helpShortcuts2: "Enter: Confirm rename, send chat",
|
||||
@@ -3196,6 +3214,24 @@ const LANGUAGES = {
|
||||
helpImageEditGmicInstall2: "zipを任意のフォルダに解凍する(例: C:\\tools\\gmic);インストーラー不要",
|
||||
helpImageEditGmicInstall3: "設定タブ → G'MIC-Qt Executable Path に gmic_qt.exe のフルパスを入力(例: C:\\tools\\gmic\\gmic_qt.exe)して Save をクリック",
|
||||
helpImageEditTabKbdTitle: "Image Edit タブのショートカット",
|
||||
imageEditPaletteColor1: "色1",
|
||||
imageEditPaletteColor2: "色2",
|
||||
imageEditPaletteBase: "基本色",
|
||||
imageEditPaletteCustom: "カスタム",
|
||||
imageEditPaletteAddTitle: "現在の色をカスタム色の空き枠に登録します",
|
||||
imageEditPaletteEmptyTitle: "クリックで現在の色を登録・右クリックで色を指定",
|
||||
imageEditPaletteSwatchTitle: "クリックで使用・右クリックで登録/編集",
|
||||
imageEditPaletteRegisterCurrent: "現在の色を登録",
|
||||
imageEditPaletteEditColor: "色を編集…",
|
||||
imageEditPalettePickColor: "色を指定して登録…",
|
||||
imageEditPaletteDelete: "削除",
|
||||
imageEditPaletteResetBase: "初期の色に戻す",
|
||||
imageEditPaletteExists: "この色は登録済みです",
|
||||
imageEditPaletteFull: "カスタム色の枠がいっぱいです。右クリックで上書きするか削除してください",
|
||||
imageEditNoAbrBrushes: "ブラシがありません。Mask Editor OneでABRブラシをインポートしてください",
|
||||
helpImageEditDrawPalette: "Drawのカラーパレット(2段目):色1/色2、基本色20色、カスタム色20枠。色をクリックするとその色で描けます。「+」か空き枠のクリックで現在の色を登録し、色の上で右クリックすると登録・編集・削除ができます(基本色も変更でき、初期の色に戻せます)。登録した色はブラウザごとに保存されます。Colorの隣のスポイトボタンでキャンバスから色を拾えます(Escで取り消し)",
|
||||
imageEditPixelColorFail: "ピクセルの色を取得できませんでした",
|
||||
helpImageEditDrawKbd: "Drawツール中:D Draw / E Erase / X 色1・色2の切り替え / [ ] ブラシサイズ / B ブラシ選択の開閉(Escでも閉じます)",
|
||||
helpShortcutsTitle: "キーボード操作",
|
||||
helpShortcuts1: "Escape:モーダル・パネルを閉じる",
|
||||
helpShortcuts2: "Enter:名前変更の確定、チャット送信",
|
||||
@@ -5005,6 +5041,24 @@ const LANGUAGES = {
|
||||
helpImageEditGmicInstall2: "将zip解压到任意文件夹(如 C:\\tools\\gmic);无需安装程序",
|
||||
helpImageEditGmicInstall3: "打开设置 → G'MIC-Qt Executable Path,输入 gmic_qt.exe 的完整路径(如 C:\\tools\\gmic\\gmic_qt.exe),点击 Save",
|
||||
helpImageEditTabKbdTitle: "图像编辑选项卡快捷键",
|
||||
imageEditPaletteColor1: "颜色1",
|
||||
imageEditPaletteColor2: "颜色2",
|
||||
imageEditPaletteBase: "基本色",
|
||||
imageEditPaletteCustom: "自定义",
|
||||
imageEditPaletteAddTitle: "将当前颜色登记到自定义颜色的空位",
|
||||
imageEditPaletteEmptyTitle: "单击登记当前颜色,右键指定颜色",
|
||||
imageEditPaletteSwatchTitle: "单击使用,右键登记或编辑",
|
||||
imageEditPaletteRegisterCurrent: "登记当前颜色",
|
||||
imageEditPaletteEditColor: "编辑颜色…",
|
||||
imageEditPalettePickColor: "指定颜色并登记…",
|
||||
imageEditPaletteDelete: "删除",
|
||||
imageEditPaletteResetBase: "恢复初始颜色",
|
||||
imageEditPaletteExists: "此颜色已登记",
|
||||
imageEditPaletteFull: "自定义颜色已满。请右键覆盖或删除",
|
||||
imageEditNoAbrBrushes: "没有可用画笔。请在 Mask Editor One 中导入 ABR 画笔",
|
||||
helpImageEditDrawPalette: "Draw调色板(第二行):颜色1/颜色2、20种基本色和20个自定义颜色位。单击颜色即可用该颜色绘制。使用“+”或单击空位可登记当前颜色;在颜色上右键可登记、编辑或删除(基本色也可修改并恢复初始颜色)。登记的颜色按浏览器分别保存。使用Color旁的吸管按钮可从画布取色(按Esc取消)",
|
||||
imageEditPixelColorFail: "无法读取像素颜色",
|
||||
helpImageEditDrawKbd: "Draw工具使用中:D Draw / E Erase / X 切换颜色1/2 / [ ] 笔刷大小 / B 打开或关闭笔刷选择(也可按Esc关闭)",
|
||||
helpShortcutsTitle: "键盘操作",
|
||||
helpShortcuts1: "Escape:关闭弹窗/面板",
|
||||
helpShortcuts2: "Enter:确认重命名、发送聊天",
|
||||
|
||||
+140
-26
@@ -6,6 +6,7 @@
|
||||
|
||||
import { LayerManager, Layer } from "./image-edit/LayerManager.js";
|
||||
import { DrawTool } from "./image-edit/DrawTool.js";
|
||||
import { DrawPalette } from "./image-edit/DrawPalette.js";
|
||||
import { TextTool, TEXT_FONTS } from "./image-edit/TextTool.js";
|
||||
import { SelectTool } from "./image-edit/SelectTool.js";
|
||||
import { ShapeTool } from "./image-edit/ShapeTool.js";
|
||||
@@ -20,10 +21,22 @@ import { MaskEditorOneBridge } from "./image-edit/MaskEditorOneBridge.js";
|
||||
import { InpaintI2IActions } from "./image-edit/InpaintI2IActions.js";
|
||||
import { FileExport } from "./image-edit/FileExport.js";
|
||||
import { showToast } from "./app.js";
|
||||
import { t as tr } from "./i18n.js";
|
||||
import { comfyUI } from "./comfyui-client.js";
|
||||
import { comfyEditor } from "./comfyui-editor.js";
|
||||
import { comfyWorkflow } from "./comfyui-workflow.js";
|
||||
|
||||
// Draw Tool: スポイト(Eyedropper)アイコン。ボタンとカスタムカーソルの両方で使い回す。
|
||||
const EYEDROPPER_ICON_PATH = "M20.71 5.63l-2.34-2.34a1 1 0 0 0-1.41 0L14.7 5.55 12 8.24 3 17.24V21h3.76l9-9 2.69-2.69 2.26-2.26a1 1 0 0 0 0-1.41zM6.34 19H5v-1.34l8.06-8.06 1.41 1.41L6.34 19z";
|
||||
const EYEDROPPER_ICON_SVG =
|
||||
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="14" height="14" fill="currentColor"><path d="${EYEDROPPER_ICON_PATH}"/></svg>`;
|
||||
|
||||
function _eyedropperCursorCss() {
|
||||
const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'>`
|
||||
+ `<path d='${EYEDROPPER_ICON_PATH}' fill='%23ffffff' stroke='%23000000' stroke-width='1'/></svg>`;
|
||||
return `url("data:image/svg+xml,${svg}") 2 22, crosshair`;
|
||||
}
|
||||
|
||||
const TOOL_DEFS = [
|
||||
{ id: "select", icon: "▲", label: "Select", ready: true },
|
||||
{ id: "draw", icon: "✏", label: "Draw", ready: true },
|
||||
@@ -49,6 +62,11 @@ class ImageEditTab {
|
||||
this._layerMgr = null;
|
||||
this._activeTool = "select";
|
||||
this._drawTool = new DrawTool(null);
|
||||
this._eyedropperActive = false; // Drawツールのスポイト(色抽出)モード
|
||||
this._drawPalette = new DrawPalette({
|
||||
onColorChange: hex => this._setDrawColor(hex),
|
||||
toast: showToast,
|
||||
});
|
||||
this._textTool = new TextTool(null);
|
||||
this._selectTool = new SelectTool();
|
||||
this._zoom = 1.0;
|
||||
@@ -196,6 +214,7 @@ class ImageEditTab {
|
||||
_updateBrushCursor(e) {
|
||||
const el = this._brushCursorEl;
|
||||
if (!el) return;
|
||||
this._lastBrushCursorEvent = e; // キー操作でサイズを変えたときに再描画するため保持
|
||||
const tool = this._activeTool;
|
||||
const size = tool === "draw"
|
||||
? this._drawTool?.brushSize
|
||||
@@ -226,6 +245,79 @@ class ImageEditTab {
|
||||
if (this._brushCursorEl) this._brushCursorEl.style.display = "none";
|
||||
}
|
||||
|
||||
// ── Draw: スポイト(Eyedropper) ─────────────────
|
||||
|
||||
_setEyedropperActive(active) {
|
||||
this._eyedropperActive = active;
|
||||
const drawCanvas = document.getElementById("ie-canvas-draw");
|
||||
const overlay = document.getElementById("ie-canvas-overlay");
|
||||
const cursor = active ? _eyedropperCursorCss() : "";
|
||||
if (drawCanvas) drawCanvas.style.cursor = cursor;
|
||||
if (overlay) overlay.style.cursor = cursor;
|
||||
if (active) this._hideBrushCursor();
|
||||
document.getElementById("ie-draw-eyedropper")?.classList.toggle("ie-opt-active", active);
|
||||
}
|
||||
|
||||
_pickColorAt(x, y) {
|
||||
const canvas = document.getElementById("ie-canvas-draw");
|
||||
const px = Math.floor(x), py = Math.floor(y);
|
||||
if (!canvas || px < 0 || py < 0 || px >= canvas.width || py >= canvas.height) {
|
||||
this._setEyedropperActive(false);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// 見えている色を拾うため、アクティブレイヤーのみの表示なら合成し直す
|
||||
if (!this._compositeMode) this._updateCompositeView();
|
||||
const [r, g, b] = canvas.getContext("2d").getImageData(px, py, 1, 1).data;
|
||||
const hex = "#" + [r, g, b].map(v => v.toString(16).padStart(2, "0")).join("");
|
||||
this._setDrawColor(hex);
|
||||
this._drawPalette.syncColor(hex);
|
||||
} catch {
|
||||
showToast(tr("imageEditPixelColorFail"), "error");
|
||||
}
|
||||
this._setEyedropperActive(false);
|
||||
}
|
||||
|
||||
_setDrawMode(mode) {
|
||||
this._drawTool.mode = mode;
|
||||
this._drawTool._stamp = null;
|
||||
this._renderDrawProps();
|
||||
}
|
||||
|
||||
_setDrawBrushSize(size) {
|
||||
this._drawTool.brushSize = size;
|
||||
this._drawTool._stamp = null;
|
||||
const slider = document.getElementById("ie-draw-size");
|
||||
if (slider) slider.value = size;
|
||||
const label = document.getElementById("ie-draw-size-lbl");
|
||||
if (label) label.textContent = size + "px";
|
||||
if (this._lastBrushCursorEvent && !this._eyedropperActive) {
|
||||
this._updateBrushCursor(this._lastBrushCursorEvent);
|
||||
}
|
||||
}
|
||||
|
||||
/** [ / ] キー: サイズが大きいほど刻みを粗くする */
|
||||
_stepDrawBrushSize(direction) {
|
||||
const size = this._drawTool.brushSize;
|
||||
const base = direction < 0 ? size - 1 : size;
|
||||
const step = base < 10 ? 1 : base < 50 ? 5 : 10;
|
||||
this._setDrawBrushSize(Math.min(200, Math.max(1, size + direction * step)));
|
||||
}
|
||||
|
||||
/** Drawツール中のBキー: ブラシ選択モーダルを開閉する */
|
||||
_toggleDrawBrushPicker() {
|
||||
if (this._abrAvailable) this._openAbrBrushPickerForDraw();
|
||||
else showToast(tr("imageEditNoAbrBrushes"), "info");
|
||||
}
|
||||
|
||||
_setDrawColor(hex) {
|
||||
this._drawTool.color = hex;
|
||||
this._drawTool._stamp = null;
|
||||
this._drawTool._imgStamp = null;
|
||||
const input = document.getElementById("ie-draw-color");
|
||||
if (input) input.value = hex;
|
||||
}
|
||||
|
||||
// ── ツールボタン ──────────────────────────────
|
||||
|
||||
_setupToolButtons() {
|
||||
@@ -240,6 +332,7 @@ class ImageEditTab {
|
||||
|
||||
_setActiveTool(toolId) {
|
||||
this._hideBrushCursor();
|
||||
if (this._eyedropperActive) this._setEyedropperActive(false);
|
||||
if (this._activeTool === "draw") this._drawTool?.deactivate();
|
||||
if (this._activeTool === "text") this._textTool?.deactivate();
|
||||
if (this._activeTool === "select") this._selectTool?.deactivate();
|
||||
@@ -306,6 +399,7 @@ class ImageEditTab {
|
||||
_renderToolOptions(toolId) {
|
||||
const el = document.getElementById("ie-tool-options");
|
||||
if (!el) return;
|
||||
this._drawPalette.closeMenu();
|
||||
el.innerHTML = "";
|
||||
|
||||
if (toolId === "select" && this._selectTool) {
|
||||
@@ -355,6 +449,7 @@ class ImageEditTab {
|
||||
|
||||
} else if (toolId === "draw" && this._drawTool) {
|
||||
el.innerHTML = "";
|
||||
this._drawPalette.render(el);
|
||||
this._renderDrawProps();
|
||||
|
||||
} else if (toolId === "fill" && this._fillTool) {
|
||||
@@ -873,18 +968,22 @@ class ImageEditTab {
|
||||
<div class="ie-props-row">
|
||||
<label>Mode</label>
|
||||
<div style="display:flex;gap:4px;">
|
||||
<button class="wfm-btn wfm-btn-sm${t.mode === "draw" ? " ie-opt-active" : ""}" id="ie-draw-mode-draw" style="flex:1;">Draw</button>
|
||||
<button class="wfm-btn wfm-btn-sm${t.mode === "erase" ? " ie-opt-active" : ""}" id="ie-draw-mode-erase" style="flex:1;">Erase</button>
|
||||
<button class="wfm-btn wfm-btn-sm${t.mode === "draw" ? " ie-opt-active" : ""}" id="ie-draw-mode-draw" title="Draw (D)" style="flex:1;">Draw</button>
|
||||
<button class="wfm-btn wfm-btn-sm${t.mode === "erase" ? " ie-opt-active" : ""}" id="ie-draw-mode-erase" title="Erase (E)" style="flex:1;">Erase</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ie-props-row">
|
||||
<label>Color</label>
|
||||
<input type="color" id="ie-draw-color" value="${t.color}"
|
||||
style="width:36px;height:24px;padding:0;border:1px solid var(--wfm-border);cursor:pointer;border-radius:3px;flex-shrink:0;">
|
||||
<div style="display:flex;gap:4px;align-items:center;">
|
||||
<input type="color" id="ie-draw-color" value="${t.color}"
|
||||
style="width:36px;height:24px;padding:0;border:1px solid var(--wfm-border);cursor:pointer;border-radius:3px;flex-shrink:0;">
|
||||
<button class="wfm-btn wfm-btn-sm${this._eyedropperActive ? " ie-opt-active" : ""}" id="ie-draw-eyedropper"
|
||||
title="Eyedropper" style="flex-shrink:0;width:auto;height:24px;padding:2px 6px;display:flex;align-items:center;justify-content:center;">${EYEDROPPER_ICON_SVG}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ie-props-row">
|
||||
<label>Size</label>
|
||||
<input type="range" id="ie-draw-size" min="1" max="200" value="${t.brushSize}">
|
||||
<label title="[ / ]">Size</label>
|
||||
<input type="range" id="ie-draw-size" min="1" max="200" value="${t.brushSize}" title="[ / ]">
|
||||
<span id="ie-draw-size-lbl">${t.brushSize}px</span>
|
||||
</div>
|
||||
<div class="ie-props-row">
|
||||
@@ -906,7 +1005,7 @@ class ImageEditTab {
|
||||
<label>Brush</label>
|
||||
<span style="font-size:11px;color:var(--wfm-text-secondary);flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"
|
||||
title="${t.brushName ?? "Circle"}">${t.brushName ?? "Circle"}</span>
|
||||
<button class="wfm-btn wfm-btn-sm" id="ie-draw-select-brush" style="font-size:10px;padding:1px 6px;flex-shrink:0;" ${this._abrAvailable ? "" : "disabled"}>Select</button>
|
||||
<button class="wfm-btn wfm-btn-sm" id="ie-draw-select-brush" title="B" style="font-size:10px;padding:1px 6px;flex-shrink:0;" ${this._abrAvailable ? "" : "disabled"}>Select</button>
|
||||
${t.brushImage ? `<button class="wfm-btn wfm-btn-sm" id="ie-draw-clear-brush" style="font-size:10px;padding:1px 5px;flex-shrink:0;">✕</button>` : ""}
|
||||
</div>
|
||||
${t.brushImage ? `
|
||||
@@ -933,25 +1032,17 @@ class ImageEditTab {
|
||||
</div>` : ""}
|
||||
`;
|
||||
|
||||
document.getElementById("ie-draw-mode-draw")?.addEventListener("click", () => {
|
||||
this._drawTool.mode = "draw";
|
||||
this._drawTool._stamp = null;
|
||||
this._renderDrawProps();
|
||||
});
|
||||
document.getElementById("ie-draw-mode-erase")?.addEventListener("click", () => {
|
||||
this._drawTool.mode = "erase";
|
||||
this._drawTool._stamp = null;
|
||||
this._renderDrawProps();
|
||||
});
|
||||
document.getElementById("ie-draw-mode-draw")?.addEventListener("click", () => this._setDrawMode("draw"));
|
||||
document.getElementById("ie-draw-mode-erase")?.addEventListener("click", () => this._setDrawMode("erase"));
|
||||
document.getElementById("ie-draw-color")?.addEventListener("input", e => {
|
||||
this._drawTool.color = e.target.value;
|
||||
this._drawTool._stamp = null;
|
||||
this._drawTool._imgStamp = null;
|
||||
this._setDrawColor(e.target.value);
|
||||
this._drawPalette.syncColor(e.target.value);
|
||||
});
|
||||
document.getElementById("ie-draw-eyedropper")?.addEventListener("click", () => {
|
||||
this._setEyedropperActive(!this._eyedropperActive);
|
||||
});
|
||||
document.getElementById("ie-draw-size")?.addEventListener("input", e => {
|
||||
this._drawTool.brushSize = parseInt(e.target.value);
|
||||
document.getElementById("ie-draw-size-lbl").textContent = e.target.value + "px";
|
||||
this._drawTool._stamp = null;
|
||||
this._setDrawBrushSize(parseInt(e.target.value));
|
||||
});
|
||||
document.getElementById("ie-draw-hard")?.addEventListener("input", e => {
|
||||
this._drawTool.hardness = parseInt(e.target.value) / 100;
|
||||
@@ -1461,7 +1552,9 @@ class ImageEditTab {
|
||||
}
|
||||
// Draw/Mask: update brush cursor and continue stroke outside canvas
|
||||
const tool = this._activeTool;
|
||||
if (tool === "draw" || tool === "mask") {
|
||||
if (this._eyedropperActive) {
|
||||
this._hideBrushCursor();
|
||||
} else if (tool === "draw" || tool === "mask") {
|
||||
this._updateBrushCursor(e);
|
||||
const isDrawing = tool === "draw"
|
||||
? this._drawTool?._drawing
|
||||
@@ -1514,6 +1607,11 @@ class ImageEditTab {
|
||||
// PointerEvent.pressure: pen -> actual pressure, mouse -> 0.5 while a button is held.
|
||||
const pressure = e.pressure || 0.5;
|
||||
|
||||
if (this._eyedropperActive) {
|
||||
this._pickColorAt(pos.x, pos.y);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._activeTool === "draw" && this._drawTool) {
|
||||
const activeLayer = this._layerMgr.activeLayer;
|
||||
if (!activeLayer) return;
|
||||
@@ -1781,6 +1879,7 @@ class ImageEditTab {
|
||||
|
||||
// 現在のドキュメントを閉じ、未保存の変更を破棄してプレースホルダー表示に戻す
|
||||
_closeDocument() {
|
||||
if (this._eyedropperActive) this._setEyedropperActive(false);
|
||||
if (!this._layerMgr) return;
|
||||
if (!confirm("Close the current document? Unsaved changes will be lost.")) return;
|
||||
|
||||
@@ -1848,6 +1947,8 @@ class ImageEditTab {
|
||||
this._layerMgr.on("change", () => this._refreshLayerList());
|
||||
|
||||
this._drawTool = new DrawTool(null);
|
||||
// 新規ドキュメントでも選択中の色を引き継ぐ(パレットを色の正とする)
|
||||
this._drawTool.color = this._drawPalette.currentColor;
|
||||
this._drawTool.onChange(() => {
|
||||
// layer.canvas に直接描くため sync 不要
|
||||
this._updateCompositeView();
|
||||
@@ -2458,6 +2559,9 @@ class ImageEditTab {
|
||||
const wrap = document.getElementById("ie-canvas-wrap");
|
||||
if (wrap && !this._panning) wrap.style.cursor = "grab";
|
||||
}
|
||||
if (e.key === "Escape" && this._eyedropperActive) this._setEyedropperActive(false);
|
||||
const brushPicker = document.getElementById("wfm-abr-picker-overlay");
|
||||
if (e.key === "Escape") brushPicker?.remove();
|
||||
if (e.ctrlKey && e.key === "z") { e.preventDefault(); this._undo(); }
|
||||
if (e.ctrlKey && e.key === "y") { e.preventDefault(); this._redo(); }
|
||||
if (this._activeTool === "mask" && this._maskSubtool === "vector") {
|
||||
@@ -2465,10 +2569,20 @@ class ImageEditTab {
|
||||
}
|
||||
if (!e.ctrlKey && !e.target.closest("input, textarea, select")) {
|
||||
if (e.key === "v") this._setActiveTool("select");
|
||||
if (e.key === "b") this._setActiveTool("draw");
|
||||
if (e.key === "b") {
|
||||
if (this._activeTool === "draw") this._toggleDrawBrushPicker();
|
||||
else this._setActiveTool("draw");
|
||||
}
|
||||
if (e.key === "t") this._setActiveTool("text");
|
||||
if (e.key === "s") this._setActiveTool("shape");
|
||||
if (e.key === "g") this._setActiveTool("fill");
|
||||
if (this._activeTool === "draw" && !brushPicker && !e.altKey && !e.metaKey) {
|
||||
if (e.key === "d") this._setDrawMode("draw");
|
||||
if (e.key === "e") this._setDrawMode("erase");
|
||||
if (e.key === "x") this._drawPalette.toggleWell();
|
||||
if (e.key === "[") this._stepDrawBrushSize(-1);
|
||||
if (e.key === "]") this._stepDrawBrushSize(1);
|
||||
}
|
||||
// Delete/Backspaceで選択オブジェクト削除
|
||||
if ((e.key === "Delete" || e.key === "Backspace") && this._activeTool === "select") {
|
||||
const layer = this._selectTool?.getSelectedLayer();
|
||||
@@ -2929,7 +3043,7 @@ class ImageEditTab {
|
||||
return null;
|
||||
};
|
||||
|
||||
const currentColor = this._drawTool?.color ?? "#ff0000";
|
||||
const currentColor = this._drawTool?.color ?? "#000000";
|
||||
const hex = currentColor.replace("#", "");
|
||||
const cr = parseInt(hex.slice(0, 2), 16);
|
||||
const cg = parseInt(hex.slice(2, 4), 16);
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
/**
|
||||
* Image Edit Tab - Draw Tool color palette
|
||||
* Drawツールの2段目(ie-tool-options)に並べるカラーパレット。
|
||||
* 色1/色2の切替、基本色、カスタム色の登録を担当する。
|
||||
* 基本色・カスタム色はユーザー設定として localStorage に保存する(作品データには含めない)。
|
||||
*/
|
||||
|
||||
import { t } from "../i18n.js";
|
||||
|
||||
const STORAGE_KEY = "ie_draw_palette_v1";
|
||||
const CUSTOM_SLOTS = 20;
|
||||
|
||||
const DEFAULT_BASE = [
|
||||
"#000000", "#7f7f7f", "#880015", "#ed1c24", "#ff7f27", "#fff200", "#22b14c", "#00a2e8", "#3f48cc", "#a349a4",
|
||||
"#ffffff", "#c3c3c3", "#b97a57", "#ffaec9", "#ffc90e", "#efe4b0", "#b5e61d", "#99d9ea", "#7092be", "#c8bfe7",
|
||||
];
|
||||
|
||||
function normalizeHex(value) {
|
||||
if (typeof value !== "string") return null;
|
||||
const hex = value.toLowerCase();
|
||||
return /^#[0-9a-f]{6}$/.test(hex) ? hex : null;
|
||||
}
|
||||
|
||||
function loadPalette() {
|
||||
let saved = null;
|
||||
try { saved = JSON.parse(localStorage.getItem(STORAGE_KEY)); } catch { /* 破損時は初期値 */ }
|
||||
return {
|
||||
base: DEFAULT_BASE.map((c, i) => normalizeHex(saved?.base?.[i]) ?? c),
|
||||
custom: Array.from({ length: CUSTOM_SLOTS }, (_, i) => normalizeHex(saved?.custom?.[i])),
|
||||
};
|
||||
}
|
||||
|
||||
export class DrawPalette {
|
||||
/**
|
||||
* @param {object} opts
|
||||
* @param {(hex: string) => void} opts.onColorChange ブラシ色を変更する
|
||||
* @param {(msg: string, type?: string) => void} opts.toast
|
||||
*/
|
||||
constructor({ onColorChange, toast }) {
|
||||
this._onColorChange = onColorChange;
|
||||
this._toast = toast;
|
||||
this._wells = ["#000000", "#ffffff"];
|
||||
this._activeWell = 0;
|
||||
Object.assign(this, loadPalette());
|
||||
this._content = null;
|
||||
this._picker = null;
|
||||
this._pickerTarget = null;
|
||||
this._menu = null;
|
||||
this._closeMenuOnOutside = e => { if (!this._menu?.contains(e.target)) this.closeMenu(); };
|
||||
this._closeMenuOnEscape = e => { if (e.key === "Escape") this.closeMenu(); };
|
||||
}
|
||||
|
||||
get currentColor() { return this._wells[this._activeWell]; }
|
||||
|
||||
/** ie-tool-options へパレットを描画する */
|
||||
render(container) {
|
||||
this.closeMenu();
|
||||
|
||||
const root = document.createElement("div");
|
||||
root.className = "ie-palette";
|
||||
this._content = document.createElement("div");
|
||||
this._content.className = "ie-palette-content";
|
||||
this._picker = document.createElement("input");
|
||||
this._picker.type = "color";
|
||||
this._picker.className = "ie-palette-picker";
|
||||
this._picker.tabIndex = -1;
|
||||
root.append(this._content, this._picker);
|
||||
container.appendChild(root);
|
||||
|
||||
root.addEventListener("click", e => this._onClick(e));
|
||||
root.addEventListener("contextmenu", e => this._onContextMenu(e));
|
||||
this._picker.addEventListener("input", () => this._onPickerInput());
|
||||
this._refresh();
|
||||
}
|
||||
|
||||
/** スポイト・カラー入力などパレット外で変わった色を反映する */
|
||||
syncColor(color) {
|
||||
const hex = normalizeHex(color);
|
||||
if (!hex) return;
|
||||
this._wells[this._activeWell] = hex;
|
||||
this._refresh();
|
||||
}
|
||||
|
||||
/** 色1/色2を切り替える */
|
||||
toggleWell() {
|
||||
this._selectWell(1 - this._activeWell);
|
||||
}
|
||||
|
||||
closeMenu() {
|
||||
if (!this._menu) return;
|
||||
this._menu.remove();
|
||||
this._menu = null;
|
||||
document.removeEventListener("pointerdown", this._closeMenuOnOutside, true);
|
||||
document.removeEventListener("keydown", this._closeMenuOnEscape, true);
|
||||
}
|
||||
|
||||
_refresh() {
|
||||
if (!this._content?.isConnected) return;
|
||||
const wells = this._wells.map((color, i) => {
|
||||
const label = t(i === 0 ? "imageEditPaletteColor1" : "imageEditPaletteColor2");
|
||||
return `<button type="button" class="ie-palette-well${i === this._activeWell ? " is-active" : ""}"
|
||||
data-well="${i}" style="--swatch:${color}" title="${label} (X): ${color}" aria-label="${label}"></button>`;
|
||||
}).join("");
|
||||
this._content.innerHTML = `
|
||||
<div class="ie-opt-group ie-palette-wells">${wells}</div>
|
||||
<div class="ie-opt-group">
|
||||
<label>${t("imageEditPaletteBase")}</label>
|
||||
<div class="ie-palette-grid">${this._swatches("base")}</div>
|
||||
</div>
|
||||
<div class="ie-opt-group">
|
||||
<label>${t("imageEditPaletteCustom")}</label>
|
||||
<div class="ie-palette-grid">${this._swatches("custom")}</div>
|
||||
<button type="button" class="wfm-btn wfm-btn-sm" data-palette-add
|
||||
title="${t("imageEditPaletteAddTitle")}">+</button>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
_swatches(kind) {
|
||||
return this[kind].map((color, i) => {
|
||||
const attrs = `data-kind="${kind}" data-index="${i}"`;
|
||||
if (!color) {
|
||||
const title = t("imageEditPaletteEmptyTitle");
|
||||
return `<button type="button" class="ie-palette-swatch is-empty" ${attrs} title="${title}" aria-label="${title}"></button>`;
|
||||
}
|
||||
const current = color === this.currentColor ? " is-current" : "";
|
||||
const title = `${color} — ${t("imageEditPaletteSwatchTitle")}`;
|
||||
return `<button type="button" class="ie-palette-swatch${current}" ${attrs}
|
||||
style="--swatch:${color}" title="${title}" aria-label="${color}"></button>`;
|
||||
}).join("");
|
||||
}
|
||||
|
||||
_onClick(e) {
|
||||
const well = e.target.closest("[data-well]");
|
||||
if (well) {
|
||||
this._selectWell(Number(well.dataset.well));
|
||||
return;
|
||||
}
|
||||
if (e.target.closest("[data-palette-add]")) {
|
||||
this._addCurrent();
|
||||
return;
|
||||
}
|
||||
const swatch = e.target.closest("[data-kind]");
|
||||
if (!swatch) return;
|
||||
const { kind, index } = swatch.dataset;
|
||||
const color = this[kind][index];
|
||||
if (color) this._applyColor(color);
|
||||
else this._setSlot(kind, index, this.currentColor);
|
||||
}
|
||||
|
||||
_onContextMenu(e) {
|
||||
const swatch = e.target.closest("[data-kind]");
|
||||
if (!swatch) return;
|
||||
e.preventDefault();
|
||||
this._openMenu(swatch, e.clientX, e.clientY);
|
||||
}
|
||||
|
||||
_selectWell(index) {
|
||||
this._activeWell = index;
|
||||
this._applyColor(this.currentColor);
|
||||
}
|
||||
|
||||
_applyColor(color) {
|
||||
this._wells[this._activeWell] = color;
|
||||
this._onColorChange(color);
|
||||
this._refresh();
|
||||
}
|
||||
|
||||
_addCurrent() {
|
||||
const color = this.currentColor;
|
||||
if (this.custom.includes(color)) {
|
||||
this._toast(t("imageEditPaletteExists"), "info");
|
||||
return;
|
||||
}
|
||||
const index = this.custom.indexOf(null);
|
||||
if (index < 0) {
|
||||
this._toast(t("imageEditPaletteFull"), "error");
|
||||
return;
|
||||
}
|
||||
this._setSlot("custom", index, color);
|
||||
}
|
||||
|
||||
_setSlot(kind, index, color) {
|
||||
this[kind][index] = color;
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify({ base: this.base, custom: this.custom }));
|
||||
} catch { /* 保存できなくてもこのセッション中は使える */ }
|
||||
this._refresh();
|
||||
}
|
||||
|
||||
_openMenu(swatch, x, y) {
|
||||
this.closeMenu();
|
||||
const { kind, index } = swatch.dataset;
|
||||
const color = this[kind][index];
|
||||
const items = [
|
||||
["imageEditPaletteRegisterCurrent", () => this._setSlot(kind, index, this.currentColor)],
|
||||
[color ? "imageEditPaletteEditColor" : "imageEditPalettePickColor", () => this._openPicker(kind, index, x, y)],
|
||||
];
|
||||
if (kind === "custom" && color) {
|
||||
items.push(["imageEditPaletteDelete", () => this._setSlot(kind, index, null)]);
|
||||
}
|
||||
if (kind === "base" && color !== DEFAULT_BASE[index]) {
|
||||
items.push(["imageEditPaletteResetBase", () => this._setSlot(kind, index, DEFAULT_BASE[index])]);
|
||||
}
|
||||
|
||||
const menu = document.createElement("div");
|
||||
menu.className = "ie-palette-menu";
|
||||
for (const [key, action] of items) {
|
||||
const button = document.createElement("button");
|
||||
button.type = "button";
|
||||
button.textContent = t(key);
|
||||
button.addEventListener("click", () => { this.closeMenu(); action(); });
|
||||
menu.appendChild(button);
|
||||
}
|
||||
this._content.closest("#wfm-tab-image-edit").appendChild(menu);
|
||||
menu.style.left = `${Math.min(x, window.innerWidth - menu.offsetWidth - 4)}px`;
|
||||
menu.style.top = `${Math.min(y, window.innerHeight - menu.offsetHeight - 4)}px`;
|
||||
this._menu = menu;
|
||||
document.addEventListener("pointerdown", this._closeMenuOnOutside, true);
|
||||
document.addEventListener("keydown", this._closeMenuOnEscape, true);
|
||||
}
|
||||
|
||||
_openPicker(kind, index, x, y) {
|
||||
this._pickerTarget = { kind, index };
|
||||
this._picker.value = this[kind][index] ?? this.currentColor;
|
||||
this._picker.style.left = `${x}px`;
|
||||
this._picker.style.top = `${y}px`;
|
||||
this._picker.click();
|
||||
}
|
||||
|
||||
_onPickerInput() {
|
||||
const { kind, index } = this._pickerTarget;
|
||||
this._setSlot(kind, index, this._picker.value);
|
||||
this._applyColor(this._picker.value);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ export class DrawTool {
|
||||
this.brushSize = 20;
|
||||
this.hardness = 0.8; // 0.0 = very soft, 1.0 = hard edge
|
||||
this.opacity = 1.0;
|
||||
this.color = "#ff0000";
|
||||
this.color = "#000000";
|
||||
this.mode = "draw"; // "draw" | "erase"
|
||||
this.spacing = 0.25; // stamp interval as fraction of brushSize (image brush only)
|
||||
this.angle = 0; // degrees [0, 359]
|
||||
|
||||
@@ -2050,6 +2050,7 @@
|
||||
<ul>
|
||||
<li id="wfm-help-imageedit-4">Select (V): click to select a layer; drag to move; drag corner handles to resize; drag the circle above the top edge to rotate; double-click a text layer to re-edit its content; Tool Options bar shows Flip H / Flip V / Rotate field</li>
|
||||
<li id="wfm-help-imageedit-5">Draw (B): freehand brush drawing onto the active draw layer; Tool Options: color, brush size, blend mode; Properties pane includes a MASK EDITOR ONE (COLOR) section for ABR image brushes — always visible, header text is green when brushes are available, gray when none are imported yet; Select is disabled until at least one brush exists</li>
|
||||
<li id="wfm-help-imageedit-draw-palette">Draw color palette (second row): Color 1/Color 2, 20 basic colors, and 20 custom slots. Click a color to paint with it. Use + or click an empty slot to register the current color; right-click a color to register, edit, or delete it (basic colors can be changed and restored). Registered colors are saved per browser. The eyedropper button next to Color picks a color from the canvas (Esc cancels)</li>
|
||||
<li id="wfm-help-imageedit-6">Text (T): click on the canvas to place a text input overlay; configure font family, size, bold/italic, align, color in the Tool Options bar; click OK to place the text as an exact-size Text layer; double-click an existing text layer with the Select tool to re-edit</li>
|
||||
<li id="wfm-help-imageedit-7">Shape (S): draw geometric shapes onto the canvas; each committed shape becomes an independent draw layer; Tool Options: Shape type (Rect / Ellipse / Line / FreeLine), Rounded checkbox (Rect / Ellipse only), Fill color + None toggle (hidden for Line / FreeLine), Stroke color + width + None toggle (None hidden for Line / FreeLine where stroke is always active), Opacity slider, ↩ Undo button; drag to draw — a blue dashed outline previews the shape; release to commit</li>
|
||||
<li id="wfm-help-imageedit-7a2">Fill (G): bucket fill — click a contiguous same-color region on the active layer to flood-fill it with a solid color or a linear/radial gradient; Tool Options: Mode (Solid / Gradient), Color (solid) or Shape + Ramp (drag stops to reposition, click a stop then use the color swatch, +/- to add/remove) + Direction dial (drag to set angle/radius, gradient), Tolerance (color-match threshold), Opacity</li>
|
||||
@@ -2156,6 +2157,7 @@
|
||||
<li id="wfm-help-imageedit-24">T: Text tool</li>
|
||||
<li id="wfm-help-imageedit-25">S: Shape tool</li>
|
||||
<li id="wfm-help-imageedit-25b">G: Fill tool</li>
|
||||
<li id="wfm-help-imageedit-draw-kbd">While Draw is active: D Draw / E Erase / X switch Color 1/2 / [ ] brush size / B open or close the brush picker (Esc also closes it)</li>
|
||||
<li id="wfm-help-imageedit-26">Delete: Delete selected layer (requires 2+ layers)</li>
|
||||
<li id="wfm-help-imageedit-27">Ctrl+Z / Ctrl+Y: Undo / Redo</li>
|
||||
<li id="wfm-help-imageedit-28">Space + drag: Pan canvas</li>
|
||||
@@ -2208,6 +2210,7 @@
|
||||
<li id="wfm-help-imageedit-tabkbd-3">T: Text tool</li>
|
||||
<li id="wfm-help-imageedit-tabkbd-4">S: Shape tool</li>
|
||||
<li id="wfm-help-imageedit-tabkbd-4b">G: Fill tool</li>
|
||||
<li id="wfm-help-imageedit-tabkbd-draw">While Draw is active: D Draw / E Erase / X switch Color 1/2 / [ ] brush size / B open or close the brush picker (Esc also closes it)</li>
|
||||
<li id="wfm-help-imageedit-tabkbd-5">Delete: Delete selected layer (requires 2+ layers)</li>
|
||||
<li id="wfm-help-imageedit-tabkbd-6">Ctrl+Z / Ctrl+Y: Undo / Redo</li>
|
||||
<li id="wfm-help-imageedit-tabkbd-7">Space + drag: Pan canvas</li>
|
||||
|
||||
Reference in New Issue
Block a user