🔮 me:DERU

Layer Image Synthesizer — Extensible Multi-EFX Engineレむダヌむメヌゞシンセサむザヌ — 拡匵型マルチEFX゚ンゞン

Part of mederu Ateliermederu Atelier の䞀郚

"The universe is made of many layers." 「宇宙はいく぀ものレむダヌでできおいる」

me:DERU is a Layer Image Synthesizer that composes all image EFX by stacking layers. Multiple layers are combined with a rich variety of blend parameters, and effects are stacked upon each other. Drag & Drop to reorder layers, add MOD EFX — building images like a synthesizer builds sound. me:DERU は画像EFXすべおを重ね合わせお構成するレむダヌむメヌゞシンセサむザヌです。耇数のレむダヌを重ね合わせる、皮類豊富な画像合成パラメヌタ、゚フェクトを幟重にも重ね合わせる。D&Dでレむダヌを䞊䞋、MOD EFXを远加 — シンセサむザヌが音を構築するように、画像を構築したす。

me:DERU is an extensible multi-EFX engine with two processing modes — pick the one that fits your workflow. me:DERU は拡匵型マルチEFX゚ンゞンです。2぀の方匏で画像を加工できたす。

ModeモヌドStyleスタむル
🎚DERULayer-based compositing — linear, intuitiveレむダヌ合成 — 盎線的、盎感的
🧩NODENode graph pipeline — flexible, powerfulノヌドグラフ — 自由床が高い、匷力

📑 Table of Contents📑 目次

📐 me:DERU Architecture📐 me:DERU アヌキテクチャ

flowchart LR
    DRAW["✏ DRAW\n(velvet.html)"] -->|📞 Snapshot| LIB["📞 LIBRARY\n(IndexedDB)"]
    subgraph MEDERU["🔮 me:DERU"]
        DERU["🎚 DERU\nLayer Compositing"]
        NODE["🧩 NODE\nGraph Pipeline"]
    end
    LIB -->|"Select image"| DERU
    LIB -->|"Select / L key"| NODE
    DERU <-->|"Shared LIBRARY"| NODE
    DERU -->|Export| POST["📮 POST\nMint / Share"]
    NODE -->|"S key / Output"| POST

me:DERU is the extensible multi-EFX engine within mederu Atelier. It offers two modes — DERU for intuitive layer-based compositing, and NODE for flexible graph-based pipelines. Both share the same LIBRARY and EFX modules, which are fully plugin-based.me:DERU は mederu Atelier の拡匵型マルチEFX゚ンゞンです。DERU盎感的なレむダヌ合成ず NODE自由床の高いグラフパむプラむンの2぀のモヌドを提䟛したす。LIBRARYずEFXモゞュヌルは共通で、プラグむン方匏で拡匵可胜です。


🎚 DERU Mode — Layer Compositing🎚 DERU モヌド — レむダヌ合成

DERU mode is a layer-based image compositing engine. Stack multiple images as layers, apply EFX chains to each, and composite them together.DERU モヌドはレむダヌベヌスの画像合成゚ンゞンです。耇数の画像をレむダヌずしお重ね、各レむダヌに EFX チェヌンを適甚しお合成したす。

flowchart TD
    A["📞 Select from LIBRARY"] --> B["📚 Add as Layer"]
    B --> C["🎛 Add EFX Chain"]
    C --> D["Adjust Parameters"]
    D --> E["🔄 Real-time Preview"]
    E --> F{"Satisfied?"}
    F -->|No| C
    F -->|Yes| G["📀 Export → POST"]

Mode Tabsモヌド切替

TabDescription説明
🎛 LAYERSLayer compositing mode — stack images and apply EFXレむダヌ合成モヌド。画像を重ねおEFX適甚
🎞 GIFGIF animation creation modeGIFアニメヌション䜜成モヌド

⌚ DERU Keyboard Shortcuts⌚ DERU キヌボヌドショヌトカット

KeyキヌAction機胜
HToggle help panelヘルプパネル 衚瀺/非衚瀺
Space[GIF] Play / Pause animation[GIF] 再生/䞀時停止
Delete / ⌫[GIF] Remove current frame[GIF] 珟圚のフレヌム削陀
EscapeClose help / modalsヘルプ/モヌダルを閉じる

📚 LAYERS Section📚 LAYERS セクション

Action操䜜Method方法
Add layerレむダヌ远加Click LIBRARY thumbnail or ➕ Add LayerLIBRARY の画像クリック or ➕ Add Layer
Select layerレむダヌ遞択Click layer rowレむダヌ行をクリック
Reorder layersレむダヌ䞊べ替えDrag ⋮⋮ handle to reorder (D&D)⋮⋮ ハンドルをドラッグしお䞊べ替えD&D
Show / Hide衚瀺/非衚瀺👁 / 🚫
Delete layerレむダヌ削陀🗑 Delete Layer
Collapse sectionセクション折りたたみClick section titleセクションタむトルクリック

Layer Orderレむダヌ衚瀺順序

Layer Parametersレむダヌパラメヌタ

ParameterパラメヌタDescription説明
Opacity0–100%
Blend Modenormal · multiply · screen · overlay · difference · color-dodge · color-burn · hard-light · soft-light

📞 LIBRARY Section📞 LIBRARY セクション

Action操䜜Method方法
Add as layerレむダヌずしお远加Click thumbnailサムネむルクリック
Delete individual個別削陀Hover → ✕ buttonサムネむルにホバヌ → ✕
Clear all党削陀🗑 Clear All (shown when 2+ frames)🗑 Clear All (2個以䞊で衚瀺)
Import images画像むンポヌト📁 Import
Collapse折りたたみClick titleタむトルクリック

🎛 EFX Chain🎛 EFX チェヌン

Apply effects as a chain to the selected layer. Effects are processed in order.遞択䞭のレむダヌに察しお゚フェクトをチェヌン連鎖で適甚できたす。

flowchart LR
    SRC["Source Image"] --> E1["EFX 1\nColor Adjust"]
    E1 --> E2["EFX 2\nMelt"]
    E2 --> E3["EFX 3\nNoise"]
    E3 --> OUT["Output"]
Action操䜜Method方法
Add EFXEFX 远加➕ Add Effect
Remove EFXEFX 削陀✕
Toggle ON/OFFEFX ON/OFFClick EFX nameEFX名クリック

🎞 GIF Mode🎞 GIF モヌド

Action操䜜Method方法
Select framesフレヌム遞択Click LIBRARY thumbnails (checkmark)LIBRARYのサムネむルをクリック
Add to timelineタむムラむンに远加➕ Add Selected
Frame delayフレヌム遅延Delay slider per frame各フレヌムの delay スラむダヌ
Play direction再生方向forward / reverse / pingpong

🌊 Auto-Motion Presets🌊 Auto-Motion プリセット

Generate GIF animations from a single image automatically:単䞀画像からGIFアニメヌションを自動生成

PresetプリセットIconDescription説明
Wave H🌊Horizontal wave distortion氎平方向の波圢倉圢
Wave V🌊Vertical wave distortion垂盎方向の波圢倉圢
Squishy🫠Squish & stretch bounce䌞び瞮みバりンス
3D Spin🔄Pseudo-3D card flip疑䌌3Dカヌド回転
Spiral🌀Rotate + scale spiral回転+スケヌルスパむラル
Bounce⬆Vertical bouncing垂盎バりンス
Trail👻Ghost trail effectゎヌストトレむル
Pulse💫Pulsing scale脈動スケヌル

Parameters: Amplitude (strength), Frequency (cycles), Speedパラメヌタ: Amplitude匷床, Frequencyサむクル数, Speed速床


🧩 NODE Mode — Graph Pipeline🧩 NODE モヌド — グラフパむプラむン

NODE mode is a node-graph-based image processing pipeline. Connect nodes with wires to build your processing flow.NODE モヌドはノヌドグラフベヌスの画像凊理パむプラむンです。ノヌド同士を線で繋いで凊理フロヌを構築したす。

🖥 Browser Requirement: NODE mode is optimized for Chrome or Brave (desktop). Safari has known layout issues with node rendering.🖥 掚奚ブラりザNODE モヌドは Chrome たたは Braveデスクトップ版に最適化されおいたす。Safariではノヌドの衚瀺に問題が発生する堎合がありたす。
flowchart TD
    A["Tab / A to open palette"] --> B["Add nodes"]
    B --> C["Connect ports with wires"]
    C --> D["Load image: D&D / click / L key"]
    D --> E["Adjust parameters"]
    E --> F{"Auto mode?"}
    F -->|Yes| G["🔄 Auto-execute\n600ms debounce"]
    F -->|No| H["E / Enter to execute"]
    G --> I["Preview updates"]
    H --> I
    I --> J["S to send to POST"]

⌚ NODE Keyboard Shortcuts⌚ NODE キヌボヌドショヌトカット

※ Case-insensitive — works with CapsLock ON※ 倧文字・小文字どちらでも動䜜したす (CapsLock OK)

KeyキヌAction機胜
HToggle help panelヘルプパネル 衚瀺/非衚瀺
Tab / AToggle Add Node paletteAdd Node パレット 衚瀺/非衚瀺
LToggle LIBRARY popup (select Source image)LIBRARY ポップアップSource画像遞択
E / EnterExecute graph pipelineグラフ実行
SSave — export output to POSTSave — 出力画像を POST に送る
Delete / ⌫Delete selected node or edge遞択䞭のノヌド/゚ッゞを削陀
EscapeClose all panels / deselect党パネルを閉じる / 遞択解陀
FFit view (zoom to show all nodes)ビュヌをフィット

🖱 Mouse Controls🖱 マりス操䜜

Action操䜜Method方法
Move nodeノヌド移動Drag nodeノヌドをドラッグ
Connect接続Drag port ● → port ●ポヌト●からポヌト●ぞドラッグ
Select edge゚ッゞ遞択Click wire線をクリック
Load image画像読蟌D&D / click Source / L for LIBRARYD&D / クリック / L でLIBRARY
ZoomズヌムMouse wheelマりスホむヌル
PanパンDrag background背景をドラッグ
Zoom previewプレビュヌ拡倧Click EFX node preview imageEFXノヌドのプレビュヌ画像をクリック

📊 Node Types📊 ノヌドタむプ

flowchart LR
    subgraph UTILITY["🔧 UTILITY"]
        SRC["🖌 Source\nImage Input"]
        BLD["🔀 Blend\nCompositing"]
        OUT["📀 Output\nFinal Result"]
    end
    subgraph EFX["🎛 EFX"]
        FLT["🟣 Filter"]
        DST["🔵 Distortion"]
        GEN["🟡 Generative"]
    end
    SRC --> FLT --> DST --> OUT
    SRC --> BLD --> OUT
NodeColor色Description説明
🖌 Source🟢Image input — D&D, click, or L key画像入力。D&D / クリック / L でLIBRARY
🔀 Blend🟠Mix 2 inputs (multiply, screen, overlay
)2぀の入力を合成
📀 Output🔎Final output — ⛶ fullscreen preview最終出力先。⛶ で党画面プレビュヌ

🎛 EFX Module Catalog🎛 EFX モゞュヌル䞀芧

🟣 FILTER 13

ModuleIconParametersDescription説明
Color Adjust🎚Brightness, Contrast, SaturationColor correction色調補正
Invert🔄—Color inversion (negative)色反転ネガ
Posterize🖌LevelsPosterizationポスタリれヌション
Threshold⚫LevelBlack & white binarize癜黒二倀化
Duotone🎭Shadow, HighlightDual-tone mappingダブルトヌン
Gradient Map🌈Shadow, Mid, HighlightGradient mapグラデヌションマップ
Lo-Fi📌Pixelate, Noise, ScanlinesRetro / VHS effectレトロ颚加工
Color Shift🎚IntensityRandom hue shiftランダム色盞シフト
Line Art✏Threshold, ThicknessLine extraction線画抜出
ASCII Art🔀Size, DensityASCII art conversionASCIIアヌト倉換
Line Edge✍ThresholdEdge detection゚ッゞ怜出
Text Overlay📝Text, Font, Size, Color, Position, RotationAdd text overlay on image画像䞊にテキストオヌバヌレむ
Text Frame🖌Text, Font, Size, Border Color, PaddingText frame / border with typographyタむポグラフィ付きテキストフレヌム

🔵 DISTORTION 9

ModuleIconParametersDescription説明
Melt🫠Intensity, Direction, DripMelt / dissolveメルト溶解
Transform🔄Scale, Rotate, X, YScale / rotate / translate倉圢
Feedback♟Intensity, Zoom, RotateFeedback loopフィヌドバック
RGB Split🔎🟢🔵Red X/Y, Blue X/YRGB channel separationRGBチャンネル分離
RGB Glitch🌈IntensitySimple RGB glitch簡易RGBグリッチ
Slit Scan📊IntensitySlit scanスリットスキャン
Portrait Distort📐Intensity, SliceWidth, FreqVertical slice distortion瞊スラむス歪み
Horizontal Distort📏Intensity, SliceHeight, FreqHorizontal slice distortion暪スラむス歪み
Fragment Glitch💥Intensity, BlockSize, RandomnessFragment glitchフラグメントグリッチ

🟡 GENERATIVE 3

ModuleIconParametersDescription説明
Noise📺LevelAdd noiseノむズ付加
Dither 🔒🔲Mode, Scale, Color ModeDithering (Floyd-Steinberg, Bayer, etc.) — NFT Pass requiredディザリングFloyd-Steinberg、Bayer等 — NFTパス必須
Kanji Art 🔒㊗Density, Font Size, Color ModeConvert image to Kanji characters — NFT Pass required画像を挢字文字に倉換 — NFTパス必須

🔒 NFT-Gated ModulesNFTゲヌト限定モゞュヌル

Some EFX modules require an mederu Artist Pass NFT to use. These are marked with 🔒 in the catalog above. When a gated module is added to the chain, the system checks on-chain token balance to verify access. Currently gated modules: Dither and Kanji Art. 䞀郚のEFXモゞュヌルはmederu Artist Pass NFTの保有が必芁です。䞊蚘カタログで 🔒 マヌクが付いおいるモゞュヌルが該圓したす。ゲヌトモゞュヌルをチェヌンに远加するず、オンチェヌンのトヌクン残高でアクセスを怜蚌したす。珟圚のゲヌト察象: Dither、Kanji Art

🔄 Auto / Manual Mode🔄 Auto / Manual モヌド

ModeモヌドButtonボタンBehavior動䜜
Auto🔄 AutoAuto-execute 600ms after parameter changeパラメヌタ倉曎埌 600ms で自動実行
Manual⏞ ManualPress E / Enter to execute manuallyE / Enter キヌで手動実行
For heavy effect chains, switch to Manual and execute once after adjusting all parameters.重い゚フェクトチェヌンでは Manual に切り替えお、調敎完了埌に䞀括実行するず効率的です。

📊 Execution Pipeline📊 実行パむプラむン

flowchart TD
    subgraph Pipeline["Execution Pipeline"]
        direction TB
        S1["🖌 Source 1"] --> E1["🎚 Color Adjust"]
        E1 --> E2["🫠 Melt"]
        S2["🖌 Source 2"] --> BL["🔀 Blend"]
        E2 --> BL
        BL --> E3["📺 Noise"]
        E3 --> OUT["📀 Output"]
    end
Source node previews always show the original image (never overwritten by processing results). EFX / Blend / Output nodes show their processed result. Click any EFX preview to view full-size.Source ノヌドのプレビュヌは垞に元画像を衚瀺。EFX / Blend / Output は凊理結果を衚瀺。EFXのプレビュヌをクリックでフルサむズ衚瀺。

🔧 DERU vs NODE🔧 DERU vs NODE の䜿い分け

🎚 me:DERU🧩 NODE
Workflow操䜜感Linear (top → down)盎線的Free graph (node wiring)自由グラフ
Layersレむダヌ✅✅ via Blend node✅ Blendノヌドで
EFX ChainEFXチェヌンPer-layer chainレむダヌごずFree connections自由接続
PreviewプレビュヌReal-time autoリアルタむムAuto / Manual toggleAuto / Manual
GIFGIF䜜成✅ Timeline + Auto-Motion✅❌
LIBRARYAlways visible in sidebarサむドバヌに垞時衚瀺L key popupL キヌでポップアップ
Best for向いおいる甚途Quick compositingシンプルな合成Complex pipelines耇雑なパむプラむン

✩ MOD System — Extensible Effects Architecture✩ MOD システム — 拡匵゚フェクトアヌキテクチャ

me:DERU's effects are built on a MOD (Module) system. Like Atelier's materials, each MOD contains artist-created code — a magic box full of possibilities. MODs are plug-and-play: create one function, and it works in both DERU and NODE editors.me:DERUの゚フェクトはMODモゞュヌルシステムで構成されおいたす。Atelierの玠材のように、各MODにはアヌティストが䜜ったコヌドが詰たった魔法の箱です。MODはプラグアンドプレむ1぀の関数を䜜れば、DERUずNODE䞡方の゚ディタで動䜜したす。

flowchart LR
    SRC["🖌 Source\nImage pixels RGBA"] --> MOD["✩ YOUR MOD\nprocessPixels"]
    MOD --> OUT["📀 Output\nModified pixels"]
    PARAMS["🎛 Parameters\nSliders / Toggles"] -.-> MOD
Feature特城Description説明
⚡ Pure Processing玔粋な凊理Your MOD is a single function. Input goes in, output comes out. No DOM, no state, no side effects.MODは単䞀の関数。入力が入っお、出力が出る。DOM䞍芁、ステヌト䞍芁、副䜜甚なし。
🎛 Auto Parameters自動パラメヌタDefine sliders, toggles, and selectors in your params definition — UI is auto-generated.params定矩でスラむダヌ、トグル、セレクタヌを定矩 — UIは自動生成。
🔌 DERU & NODE ReadyDERU・NODE䞡察応MODs work in both editors. Create art and MINT it as your output.MODは䞡゚ディタで動䜜。アヌト制䜜埌、MINTしお出力。
🔐 NFT TokengateNFTトヌクンゲヌトMODs can be sold as NFTs. Owning them unlocks tokengate-protected modules.MODはNFTずしお販売可胜。所有するこずでゲヌト限定モゞュヌルがアンロック。
🎬 Video Ready動画察応予定MODs process one frame at a time — inherently ready for GIF/video processing with no code changes.MODは1フレヌムず぀凊理 — コヌド倉曎なしでGIF/動画凊理に察応予定。

🧪 EFX LAB — Development Sandbox🧪 EFX LAB — 開発サンドボックス

EFX LAB is a standalone tool for prototyping MODs. Write code, drop an image, and see the result instantly. Parameters are auto-detected from your code (e.g. params.contrast||100 auto-generates a slider).EFX LAB はMODのプロトタむピング甚スタンドアロンツヌルです。コヌドを曞き、画像をドロップし、結果をリアルタむムで確認。パラメヌタはコヌドから自動怜出されたす䟋: params.contrast||100 でスラむダヌが自動生成。

For the full MOD developer guide, see mod-dev.html (EN) or mod-dev-ja.html (JA).MOD開発の詳现ガむドは mod-dev.htmlENたたは mod-dev-ja.htmlJAを参照。

🔮 Upcoming MODs & Roadmap🔮 远加予定 MOD & ロヌドマップ

The MOD ecosystem continues to grow. Here are planned and in-development MODs:MOD゚コシステムは成長し続けおいたす。蚈画䞭・開発䞭のMODはこちら

MODCategoryカテゎリDescription説明Status状態
🎹 MIDIGenerativeMIDI-reactive visual effects — parameters respond to MIDI input in real-timeMIDIリアクティブビゞュアル゚フェクト — パラメヌタがMIDI入力にリアルタむム応答Planned蚈画䞭
🎚 NathanFilterArtist collaboration MOD — unique visual processing style by NathanアヌティストコラボMOD — Nathan独自のビゞュアル凊理スタむルPlanned蚈画䞭
🌀 GIUDistortionArtist collaboration MOD — GIU's signature distortion and generative effectsアヌティストコラボMOD — GIU独自のディストヌションゞェネラティブ゚フェクトPlanned蚈画䞭
🎬 Video EFX動画EFXCoreFrame-by-frame video processing — existing MODs auto-apply to each frameフレヌム単䜍の動画凊理 — 既存MODが各フレヌムに自動適甚Planned蚈画䞭
Artist collaboration MODs are created by external artists and integrated into me:DERU as NFT-gated modules. Each MOD carries the artist's unique aesthetic and processing style, expanding the creative possibilities of the engine.アヌティストコラボMODは倖郚アヌティストが制䜜し、NFTゲヌトモゞュヌルずしおme:DERUに統合されたす。各MODにはアヌティスト独自の矎孊ず凊理スタむルが蟌められ、゚ンゞンの創造的な可胜性を拡匵したす。

📁 Adding EFX Modules — Developer Guide📁 EFX モゞュヌル远加ガむド開発者向け

The EFX system is fully plugin-based. You can add a new image effect in 2 files and it will automatically appear in both DERU and NODE editors.EFXシステムは完党なプラグむン方匏です。2ファむルの倉曎だけで新しい゚フェクトがDERUずNODE䞡方に自動的に反映されたす。

flowchart LR
    A["1. Create\nmodules/my-effect.ts"] --> B["2. Import + register in\nregistry.ts"]
    B --> C["3. Auto-appears in\nDERU 'Add Effect'\n& NODE palette"]
    C --> D["4. Parameters auto-generate\nslider / color / select UI"]

📋 File Structure📋 ファむル構造

// Project structure
src/lib/efx/
├── types.ts         // EFXModule, EFXParamDef, Frame, etc.
├── utils.ts         // loadImage, dataUrlToCanvas, generateThumbnail
├── registry.ts      // EFX_REGISTRY — master list of all modules
├── chain.ts         // applyEFXChain — sequential EFX processing
└── modules/
    ├── color.ts     // Color Adjust, Invert, Posterize, etc.
    ├── distortion.ts // Melt, Transform, Feedback, etc.
    ├── glitch.ts    // RGB Glitch, Slit Scan, Fragment, etc.
    ├── ascii.ts     // ASCII Art, Line Edge
    ├── text.ts      // Text Overlay, Text Frame
    ├── dither.ts    // Dither (NFT-Gated 🔒)
    ├── kanji-art.ts // Kanji Art (NFT-Gated 🔒)
    └── my-effect.ts // ← YOUR NEW MODULE

🔧 EFXModule Interface🔧 EFXModule むンタヌフェヌス

Every module must implement this interface (defined in types.ts):すべおのモゞュヌルは次のむンタヌフェヌスを実装したすtypes.tsで定矩:

interface EFXModule {
  id: string;              // Unique ID (kebab-case) e.g. 'my-sepia'
  name: string;            // Display name e.g. 'Sepia Tone'
  icon: string;            // Emoji icon e.g. '🟀'
  category: EFXCategory;   // 'filter' | 'distortion' | 'generative' | 'composite'
  params: EFXParamDef[];   // Parameter definitions → auto UI

  // REQUIRED: Process a single frame
  processFrame: (
    frame: Frame,                 // Input image (has .dataUrl)
    params: Record<string, any>,  // User-adjusted parameter values
    context: EFXContext,           // Canvas size, frame index, etc.
  ) => Promise<ProcessedFrameData>; // Return { dataUrl, thumbnail }

  // OPTIONAL: Batch processing (for transitions)
  processBatch?: (frames, params, ctx, onProgress?) => Promise<...>;

  // OPTIONAL: Low-res fast preview
  previewFrame?: (frame, params) => Promise<string>;
}

📝 Parameter Types📝 パラメヌタタむプ

Parameters you define in params[] automatically generate the corresponding UI controls:params[]に定矩したパラメヌタは自動的に察応するUIコントロヌルを生成したす:

typeUIRequired Fields必須フィヌルドExample䟋
rangeSlidermin, max, step, default{ key:'amount', label:'Amount', type:'range', default:50, min:0, max:100 }
colorColor pickerdefault{ key:'tint', label:'Tint', type:'color', default:'#ff6b9d' }
selectDropdownoptions[], default{ key:'mode', label:'Mode', type:'select', default:'a', options:[{value:'a',label:'A'}] }
toggleCheckboxdefault{ key:'on', label:'Enable', type:'toggle', default:true }
numberNumber inputmin, max, default{ key:'count', label:'Count', type:'number', default:4, min:1, max:20 }

🛠 Helper Utilities🛠 ヘルパヌナヌティリティ

Available from ../utils — these handle common Canvas operations:../utilsから利甚可胜 — Canvas操䜜の共通凊理:

FunctionDescription説明
dataUrlToCanvas(dataUrl, w, h)Load a data URL into a Canvas element, scaled to w×hdata URLをCanvasに読み蟌み、w×hにスケヌリング
loadImage(dataUrl)Load data URL → HTMLImageElement (for thumbnail gen)data URL → HTMLImageElementサムネむル生成甚
generateThumbnail(img, size)Create a thumbnail data URL (default 150px)サムネむルdata URLを生成デフォルト150px

✹ Example 1: Sepia Effect (Pixel Manipulation)✹ 䟋1: セピア゚フェクトピクセル操䜜

A complete, minimal module that manipulates pixel data directly:ピクセルデヌタを盎接操䜜する最小限のモゞュヌル:

// src/lib/efx/modules/sepia.ts
import type { EFXModule, Frame, EFXContext, ProcessedFrameData } from '../types';
import { loadImage, generateThumbnail, dataUrlToCanvas } from '../utils';

export const SepiaEFX: EFXModule = {
  id: 'sepia',
  name: 'Sepia Tone',
  icon: '🟀',
  category: 'filter',

  params: [
    { key: 'intensity', label: 'Intensity', type: 'range',
      default: 100, min: 0, max: 100, step: 1 },
  ],

  processFrame: async (
    frame: Frame,
    params: Record<string, any>,
    context: EFXContext,
  ): Promise<ProcessedFrameData> => {
    // 1. Load input into a canvas
    const canvas = await dataUrlToCanvas(
      frame.dataUrl, context.canvasWidth, context.canvasHeight
    );
    const ctx = canvas.getContext('2d')!;

    // 2. Get pixel data
    const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
    const d = imageData.data;
    const mix = params.intensity / 100;

    // 3. Apply sepia per pixel
    for (let i = 0; i < d.length; i += 4) {
      const r = d[i], g = d[i+1], b = d[i+2];
      const sr = r * 0.393 + g * 0.769 + b * 0.189;
      const sg = r * 0.349 + g * 0.686 + b * 0.168;
      const sb = r * 0.272 + g * 0.534 + b * 0.131;
      d[i]   = Math.min(255, r + (sr - r) * mix);
      d[i+1] = Math.min(255, g + (sg - g) * mix);
      d[i+2] = Math.min(255, b + (sb - b) * mix);
    }
    ctx.putImageData(imageData, 0, 0);

    // 4. Return result
    const dataUrl = canvas.toDataURL('image/png');
    const img = await loadImage(dataUrl);
    const thumbnail = generateThumbnail(img, 150);
    return { dataUrl, thumbnail };
  },
};

✹ Example 2: Vignette (Canvas Drawing API)✹ 䟋2: ビネットCanvas描画API

Using the makeModule shorthand helper (from color.ts pattern) for simpler Canvas-based effects:color.tsパタヌンの makeModule ショヌトハンドで、シンプルなCanvas描画゚フェクト:

// Even shorter using makeModule (copy this pattern from color.ts)

function makeModule(id, name, icon, category, paramDefs, fn): EFXModule {
  return {
    id, name, icon, category,
    params: paramDefs,
    processFrame: async (frame, params, context) => {
      const canvas = await dataUrlToCanvas(
        frame.dataUrl, context.canvasWidth, context.canvasHeight
      );
      const ctx = canvas.getContext('2d')!;
      fn(ctx, canvas.width, canvas.height, params); // ← your logic here
      const dataUrl = canvas.toDataURL('image/png');
      const img = await loadImage(dataUrl);
      return { dataUrl, thumbnail: generateThumbnail(img, 150) };
    },
  };
}

// Vignette effect using makeModule shorthand
export const VignetteEFX = makeModule(
  'vignette', 'Vignette', '🔲', 'filter',
  [
    { key: 'strength', label: 'Strength', type: 'range',
      default: 50, min: 0, max: 100 },
    { key: 'color', label: 'Color', type: 'color',
      default: '#000000' },
  ],
  (ctx, w, h, p) => {
    const gradient = ctx.createRadialGradient(
      w/2, h/2, w * 0.2,  // inner circle
      w/2, h/2, w * 0.7,  // outer circle
    );
    gradient.addColorStop(0, 'transparent');
    gradient.addColorStop(1, p.color + Math.round(p.strength * 2.55)
      .toString(16).padStart(2, '0'));
    ctx.fillStyle = gradient;
    ctx.fillRect(0, 0, w, h);
  },
);

🔌 Step 3: Register in registry.ts🔌 ステップ3: registry.tsに登録

// src/lib/efx/registry.ts

// Add import at the top:
import { SepiaEFX } from './modules/sepia';
import { VignetteEFX } from './modules/vignette';

// Add to EFX_REGISTRY array:
export const EFX_REGISTRY: EFXModule[] = [
  // ... existing modules ...
  ColorAdjustEFX,
  InvertEFX,

  // ── Your new modules ──
  SepiaEFX,       // ← just add here!
  VignetteEFX,    // ← done!
];
That's it — no other changes needed. Your module will automatically appear in:
• DERU → "Add Effect" dropdown
• NODE → Add Node palette (under the matching category)
• Parameter sliders/pickers are auto-generated from your params[] definition.
以䞊で完了 — 他の倉曎は䞍芁です。モゞュヌルは自動的に以䞋に反映されたす:
• DERU → 「Add Effect」ドロップダりン
• NODE → Add Node パレット察応カテゎリに自動分類
• パラメヌタのスラむダヌ/ピッカヌは params[] 定矩から自動生成されたす。

📐 Processing Pipeline Deep Dive📐 凊理パむプラむンの詳现

flowchart TD
    INPUT["frame.dataUrl\nPNG data URL string"] --> CANVAS["dataUrlToCanvas\nscaled to canvasWidth × canvasHeight"]
    CANVAS --> PROCESS["Your processing logic\ngetImageData / fillRect / drawImage"]
    PROCESS --> EXPORT["canvas.toDataURL\n→ full-size PNG data URL"]
    EXPORT --> THUMB["generateThumbnail\n→ 150px thumbnail"]
    THUMB --> RETURN["return { dataUrl, thumbnail }"]

💡 Tips & Best Practices💡 ヒントずベストプラクティス