色反転の実装に成功
Browse files- index.html +6 -0
- index.js +52 -45
index.html
CHANGED
|
@@ -69,6 +69,12 @@
|
|
| 69 |
ダミー
|
| 70 |
</label>
|
| 71 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
</div>
|
| 73 |
</div>
|
| 74 |
|
|
|
|
| 69 |
ダミー
|
| 70 |
</label>
|
| 71 |
</div>
|
| 72 |
+
<div class="btn-check-wrapper">
|
| 73 |
+
<input type="checkbox" class="btn-check" name="postProcess" id="postProcessInvert" value="invert">
|
| 74 |
+
<label class="btn btn-outline-success" for="postProcessInvert">
|
| 75 |
+
色反転
|
| 76 |
+
</label>
|
| 77 |
+
</div>
|
| 78 |
</div>
|
| 79 |
</div>
|
| 80 |
|
index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import { applyEffect, getAvailableEffects } from './effects.js';
|
| 2 |
import { DummyPostProcess } from './postprocess/dummy.js';
|
|
|
|
| 3 |
import { BasePostProcess } from './postprocess/base.js';
|
| 4 |
|
| 5 |
const tagDisplayNames = {
|
|
@@ -227,7 +228,8 @@ function debounceRender(callback, delay = 200) {
|
|
| 227 |
|
| 228 |
// ポストプロセス処理のインスタンスを作成
|
| 229 |
const postProcessors = {
|
| 230 |
-
dummy: new DummyPostProcess()
|
|
|
|
| 231 |
};
|
| 232 |
|
| 233 |
/**
|
|
@@ -289,9 +291,56 @@ async function updatePreview(effectType) {
|
|
| 289 |
}
|
| 290 |
}
|
| 291 |
|
| 292 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
document.getElementById('postProcessContainer').addEventListener('change', () => {
|
| 294 |
-
|
| 295 |
});
|
| 296 |
|
| 297 |
// イベントリスナーの設定を更新
|
|
@@ -503,48 +552,6 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|
| 503 |
renderAllPresets();
|
| 504 |
});
|
| 505 |
|
| 506 |
-
// すべてのプリセットを描画する関数
|
| 507 |
-
async function renderAllPresets() {
|
| 508 |
-
effectGrid.innerHTML = '';
|
| 509 |
-
const text = textInput.value || 'プレビュー';
|
| 510 |
-
const fontFamily = fontSelect.value;
|
| 511 |
-
const fontSize = fontSizeInput.value + 'px';
|
| 512 |
-
|
| 513 |
-
const effects = getAvailableEffects();
|
| 514 |
-
for (const effect of effects) {
|
| 515 |
-
try {
|
| 516 |
-
const imageUrl = await textToImage(text, fontFamily, fontSize, effect.name);
|
| 517 |
-
|
| 518 |
-
const presetCard = document.createElement('div');
|
| 519 |
-
presetCard.className = 'effect-item';
|
| 520 |
-
presetCard.dataset.effect = effect.name;
|
| 521 |
-
presetCard.innerHTML = `
|
| 522 |
-
<div class="effect-name">${effect.name}</div>
|
| 523 |
-
<div class="preview-container">
|
| 524 |
-
<img src="${imageUrl}" alt="${effect.name}">
|
| 525 |
-
</div>
|
| 526 |
-
`;
|
| 527 |
-
|
| 528 |
-
effectGrid.appendChild(presetCard);
|
| 529 |
-
} catch (error) {
|
| 530 |
-
console.error(`プリセット ${effect.name} の描画エラー:`, error);
|
| 531 |
-
|
| 532 |
-
const errorCard = document.createElement('div');
|
| 533 |
-
errorCard.className = 'effect-item error';
|
| 534 |
-
errorCard.dataset.effect = effect.name;
|
| 535 |
-
errorCard.innerHTML = `
|
| 536 |
-
<div class="effect-name text-danger">${effect.name}</div>
|
| 537 |
-
<div class="preview-container">
|
| 538 |
-
<div class="text-danger">
|
| 539 |
-
<small>エラー: ${error.message}</small>
|
| 540 |
-
</div>
|
| 541 |
-
</div>
|
| 542 |
-
`;
|
| 543 |
-
effectGrid.appendChild(errorCard);
|
| 544 |
-
}
|
| 545 |
-
}
|
| 546 |
-
}
|
| 547 |
-
|
| 548 |
// フォント変更時の処理
|
| 549 |
fontSelect.addEventListener('change', async (e) => {
|
| 550 |
try {
|
|
|
|
| 1 |
import { applyEffect, getAvailableEffects } from './effects.js';
|
| 2 |
import { DummyPostProcess } from './postprocess/dummy.js';
|
| 3 |
+
import { InvertPostProcess } from './postprocess/invert.js';
|
| 4 |
import { BasePostProcess } from './postprocess/base.js';
|
| 5 |
|
| 6 |
const tagDisplayNames = {
|
|
|
|
| 228 |
|
| 229 |
// ポストプロセス処理のインスタンスを作成
|
| 230 |
const postProcessors = {
|
| 231 |
+
dummy: new DummyPostProcess(),
|
| 232 |
+
invert: new InvertPostProcess()
|
| 233 |
};
|
| 234 |
|
| 235 |
/**
|
|
|
|
| 291 |
}
|
| 292 |
}
|
| 293 |
|
| 294 |
+
// すべてのプリセットを描画する関数
|
| 295 |
+
async function renderAllPresets() {
|
| 296 |
+
const effectGrid = document.querySelector('.effect-grid');
|
| 297 |
+
const textInput = document.getElementById('textInput');
|
| 298 |
+
const fontSelect = document.getElementById('googleFontInput');
|
| 299 |
+
const fontSizeInput = document.getElementById('fontSize');
|
| 300 |
+
|
| 301 |
+
effectGrid.innerHTML = '';
|
| 302 |
+
const text = textInput.value || 'プレビュー';
|
| 303 |
+
const fontFamily = fontSelect.value;
|
| 304 |
+
const fontSize = fontSizeInput.value + 'px';
|
| 305 |
+
|
| 306 |
+
const effects = getAvailableEffects();
|
| 307 |
+
for (const effect of effects) {
|
| 308 |
+
try {
|
| 309 |
+
const imageUrl = await textToImage(text, fontFamily, fontSize, effect.name);
|
| 310 |
+
|
| 311 |
+
const presetCard = document.createElement('div');
|
| 312 |
+
presetCard.className = 'effect-item';
|
| 313 |
+
presetCard.dataset.effect = effect.name;
|
| 314 |
+
presetCard.innerHTML = `
|
| 315 |
+
<div class="effect-name">${effect.name}</div>
|
| 316 |
+
<div class="preview-container">
|
| 317 |
+
<img src="${imageUrl}" alt="${effect.name}">
|
| 318 |
+
</div>
|
| 319 |
+
`;
|
| 320 |
+
|
| 321 |
+
effectGrid.appendChild(presetCard);
|
| 322 |
+
} catch (error) {
|
| 323 |
+
console.error(`プリセット ${effect.name} の描画エラー:`, error);
|
| 324 |
+
|
| 325 |
+
const errorCard = document.createElement('div');
|
| 326 |
+
errorCard.className = 'effect-item error';
|
| 327 |
+
errorCard.dataset.effect = effect.name;
|
| 328 |
+
errorCard.innerHTML = `
|
| 329 |
+
<div class="effect-name text-danger">${effect.name}</div>
|
| 330 |
+
<div class="preview-container">
|
| 331 |
+
<div class="text-danger">
|
| 332 |
+
<small>エラー: ${error.message}</small>
|
| 333 |
+
</div>
|
| 334 |
+
</div>
|
| 335 |
+
`;
|
| 336 |
+
effectGrid.appendChild(errorCard);
|
| 337 |
+
}
|
| 338 |
+
}
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
// イベントリスナーを追加(ポストプロセスの変更時にすべてのプレビューを更新)
|
| 342 |
document.getElementById('postProcessContainer').addEventListener('change', () => {
|
| 343 |
+
renderAllPresets();
|
| 344 |
});
|
| 345 |
|
| 346 |
// イベントリスナーの設定を更新
|
|
|
|
| 552 |
renderAllPresets();
|
| 553 |
});
|
| 554 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 555 |
// フォント変更時の処理
|
| 556 |
fontSelect.addEventListener('change', async (e) => {
|
| 557 |
try {
|