Skip to content

Commit

Permalink
🐛 Don't forget to update glob.width, glob.height while importing/crea…
Browse files Browse the repository at this point in the history
…ting new images
  • Loading branch information
CosmoMyzrailGorynych committed Jan 24, 2019
1 parent d98aa5f commit 906d994
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
9 changes: 5 additions & 4 deletions src/js/blocks/composing.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const glob = require('./../global.js');
const mask = <IBlockTemplate>{
nameLoc: 'blocks.composing.mask.name',
name: 'Mask',
Expand Down Expand Up @@ -38,8 +39,8 @@ const mask = <IBlockTemplate>{
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);
Expand Down Expand Up @@ -107,8 +108,8 @@ const blend = <IBlockTemplate>{
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);
Expand Down
6 changes: 5 additions & 1 deletion src/riotTags/components-palette.tag
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
11 changes: 5 additions & 6 deletions src/riotTags/editor-screen.tag
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 906d994

Please sign in to comment.