From 906d99446b4d2865f52c9f2b43254546001267d9 Mon Sep 17 00:00:00 2001 From: Cosmo Myzrail Gorynych aka Comigo Date: Fri, 25 Jan 2019 01:46:57 +1200 Subject: [PATCH] :bug: Don't forget to update glob.width, glob.height while importing/creating new images --- src/js/blocks/composing.ts | 9 +++++---- src/riotTags/components-palette.tag | 6 +++++- src/riotTags/editor-screen.tag | 11 +++++------ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/js/blocks/composing.ts b/src/js/blocks/composing.ts index 08bd034..924973b 100644 --- a/src/js/blocks/composing.ts +++ b/src/js/blocks/composing.ts @@ -1,3 +1,4 @@ +const glob = require('./../global.js'); const mask = { nameLoc: 'blocks.composing.mask.name', name: 'Mask', @@ -38,8 +39,8 @@ const mask = { exec(inputs, block) { return new Promise((resolve, reject) => { const canvas = document.createElement('canvas'); - canvas.width = inputs.top.width; - canvas.height = inputs.top.height; + canvas.width = glob.width; + canvas.height = glob.height; const cx = canvas.getContext('2d'); cx.drawImage(inputs.bottom, 0, 0); @@ -107,8 +108,8 @@ const blend = { exec(inputs, block) { return new Promise((resolve, reject) => { const canvas = document.createElement('canvas'); - canvas.width = inputs.top.width; - canvas.height = inputs.top.height; + canvas.width = glob.width; + canvas.height = glob.height; const cx = canvas.getContext('2d'); cx.drawImage(inputs.bottom, 0, 0); diff --git a/src/riotTags/components-palette.tag b/src/riotTags/components-palette.tag index def78e1..25fbd70 100644 --- a/src/riotTags/components-palette.tag +++ b/src/riotTags/components-palette.tag @@ -30,5 +30,9 @@ components-palette window.signals.trigger('graphChange', e); }; this.selectCategory = e => { - this.selectedCategory = e.item.category; + if (this.selectedCategory !== e.item.category) { + this.selectedCategory = e.item.category; + } else { + this.selectedCategory = void 0; + } }; \ No newline at end of file diff --git a/src/riotTags/editor-screen.tag b/src/riotTags/editor-screen.tag index 48722c5..5775323 100644 --- a/src/riotTags/editor-screen.tag +++ b/src/riotTags/editor-screen.tag @@ -102,10 +102,9 @@ editor-screen if (width && width > 0) { var height = Number(prompt('Image height:', 512)); if (height && height > 0) { - var c = document.createElement('canvas'); - c.width = width; - c.height = height; - glob.sourceImage = c; + glob.sourceImage.width = glob.width = width; + glob.sourceImage.height = glob.height = height; + glob.sourceImage.getContext('2d').clearRect(0, 0, width, height); setTimeout(this.render, 0); } } @@ -173,8 +172,8 @@ editor-screen this.finishImportImage = e => { var img = document.createElement('img'); img.onload = () => { - glob.sourceImage.width = img.width; - glob.sourceImage.height = img.height; + glob.sourceImage.width = glob.width = img.width; + glob.sourceImage.height = glob.height = img.height; var x = glob.sourceImage.getContext('2d'); x.clearRect(0, 0, img.width, img.height); x.drawImage(img, 0, 0);