|
|
@ -4,6 +4,8 @@ import { blackAndWhite, grayScale } from '../processing/gray-scale.ts';
|
|
|
|
import ImageCollection from './ImageCollection.vue';
|
|
|
|
import ImageCollection from './ImageCollection.vue';
|
|
|
|
|
|
|
|
|
|
|
|
const canvas = ref<HTMLCanvasElement | null>(null);
|
|
|
|
const canvas = ref<HTMLCanvasElement | null>(null);
|
|
|
|
|
|
|
|
const collection = ref<typeof ImageCollection>();
|
|
|
|
|
|
|
|
const overlay = ref<string | null>(null);
|
|
|
|
const currentWidth = ref(100);
|
|
|
|
const currentWidth = ref(100);
|
|
|
|
const currentHeight = ref(100);
|
|
|
|
const currentHeight = ref(100);
|
|
|
|
let img: HTMLImageElement;
|
|
|
|
let img: HTMLImageElement;
|
|
|
@ -44,11 +46,45 @@ function onChangeSlideHeight() {
|
|
|
|
canvas.value!.height = height;
|
|
|
|
canvas.value!.height = height;
|
|
|
|
ctx.drawImage(img, 0, 0, canvas.value!.width, height);
|
|
|
|
ctx.drawImage(img, 0, 0, canvas.value!.width, height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onDragOver(event: DragEvent) {
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
event.dataTransfer!.dropEffect = 'copy';
|
|
|
|
|
|
|
|
if (event.offsetX > canvas.value!.width / 2) {
|
|
|
|
|
|
|
|
overlay.value = 'right';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
overlay.value = 'bottom';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onDrop(event: DragEvent) {
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
overlay.value = null;
|
|
|
|
|
|
|
|
const id = event.dataTransfer!.getData('text/plain');
|
|
|
|
|
|
|
|
const img: HTMLImageElement = collection.value!.images[parseInt(id)];
|
|
|
|
|
|
|
|
if (event.offsetX > canvas.value!.width / 2) {
|
|
|
|
|
|
|
|
const dx = canvas.value!.width;
|
|
|
|
|
|
|
|
const imageData = ctx.getImageData(0, 0, canvas.value!.width, canvas.value!.height);
|
|
|
|
|
|
|
|
canvas.value!.width += img.width;
|
|
|
|
|
|
|
|
ctx.putImageData(imageData, 0, 0)
|
|
|
|
|
|
|
|
ctx.drawImage(img, dx, 0);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const dy = canvas.value!.height;
|
|
|
|
|
|
|
|
const imageData = ctx.getImageData(0, 0, canvas.value!.width, canvas.value!.height);
|
|
|
|
|
|
|
|
canvas.value!.height += img.height;
|
|
|
|
|
|
|
|
ctx.putImageData(imageData, 0, 0)
|
|
|
|
|
|
|
|
ctx.drawImage(img, 0, dy);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onDragLeave() {
|
|
|
|
|
|
|
|
overlay.value = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<div class="editor">
|
|
|
|
<div class="editor">
|
|
|
|
<ImageCollection @selected="onSelected" />
|
|
|
|
<ImageCollection ref="collection" @selected="onSelected" />
|
|
|
|
<div class="working-area">
|
|
|
|
<div class="working-area">
|
|
|
|
<div class="options">
|
|
|
|
<div class="options">
|
|
|
|
<button @click="blackAndWhiteApply">
|
|
|
|
<button @click="blackAndWhiteApply">
|
|
|
@ -60,8 +96,9 @@ function onChangeSlideHeight() {
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="inner">
|
|
|
|
<div class="inner">
|
|
|
|
<input v-model="currentHeight" type="range" min="1" max="200" value="100" orient="vertical" @change="onChangeSlideHeight">
|
|
|
|
<input v-model="currentHeight" type="range" min="1" max="200" value="100" orient="vertical" @change="onChangeSlideHeight">
|
|
|
|
<div class="preview">
|
|
|
|
<div class="preview" @dragover="onDragOver" @dragleave="onDragLeave" @drop="onDrop">
|
|
|
|
<canvas ref="canvas"></canvas>
|
|
|
|
<canvas ref="canvas"></canvas>
|
|
|
|
|
|
|
|
<div v-if="overlay" :class="`overlay overlay-${overlay}`"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="controls">
|
|
|
|
<div class="controls">
|
|
|
|