diff --git a/form/res-judicata/src/views/Apply.vue b/form/res-judicata/src/views/Apply.vue index 4f85f95..9e1b76c 100644 --- a/form/res-judicata/src/views/Apply.vue +++ b/form/res-judicata/src/views/Apply.vue @@ -20,7 +20,7 @@
- +
{{ getDescription(detection) }} @@ -66,8 +66,15 @@ export default { name: 'Apply', components: {ICry}, props: { - "detections": Array, - "paintingColor": String, + }, + data: function() { + return { + "paintingColor": "transparent", + "ctx": null, + "painting": false, + "lastcoord": null, + "beforelast": null, // TODO stupid babycode, use array instead + } }, methods: { processForm: function () { @@ -90,6 +97,7 @@ export default { canvas.width = width; canvas.height = height; const ctx = canvas.getContext('2d'); + this.ctx = ctx; let offset = 0; for (const img of imgs) { ctx.drawImage(img, 0, offset); @@ -138,6 +146,36 @@ export default { } } }, + mouseMove(e) { + if (!this.ctx) { + return; + } + const canvas = document.getElementById("content"); + const rect = canvas.getBoundingClientRect(); + const scaleX = canvas.width / rect.width; + const scaleY = canvas.height / rect.height; + const x = (e.clientX - rect.left) * scaleX; + const y = (e.clientY - rect.top) * scaleY; + const a = 75; + if (e.buttons === 1) { + this.painting = true; + if (this.lastcoord && this.beforelast) { + console.log([x, y]); + this.ctx.lineWidth = a; + this.ctx.strokeStyle = this.paintingColor.replace("rgb", "rgba").replace(")", ",0.5)"); + this.ctx.beginPath(); + this.ctx.moveTo(...this.beforelast); + this.ctx.lineTo(x, y) + this.ctx.stroke(); + } + this.beforelast = this.lastcoord; + this.lastcoord = [x, y]; + } else { + this.painting = false; + this.lastcoord = null; + this.beforelast = null; + } + }, }, }