From 5e14670ae09f91ad457f054a6a127ff2eba5b4ec Mon Sep 17 00:00:00 2001 From: JannisX11 Date: Sun, 19 Nov 2023 17:44:23 +0100 Subject: [PATCH] Fix manual color input in color panel not working Make texture editing faster --- js/texturing/color.js | 2 +- js/texturing/textures.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/js/texturing/color.js b/js/texturing/color.js index b3ce64bd..459a419d 100644 --- a/js/texturing/color.js +++ b/js/texturing/color.js @@ -136,7 +136,7 @@ Interface.definePanels(() => { second_color_selected: false, get color_code() {return this.hover_color || (this.second_color_selected ? this.second_color : this.main_color)}, set color_code(color) { - if (this.second_color_selected) { + if (this.second_color_selected == false) { this.main_color = color.toLowerCase().replace(/[^a-f0-9#]/g, ''); } else { this.second_color = color.toLowerCase().replace(/[^a-f0-9#]/g, ''); diff --git a/js/texturing/textures.js b/js/texturing/textures.js index 134fe980..f308493b 100644 --- a/js/texturing/textures.js +++ b/js/texturing/textures.js @@ -38,7 +38,7 @@ class Texture { //Setup Img/Mat this.canvas = document.createElement('canvas'); this.canvas.width = this.canvas.height = 16; - this.ctx = this.canvas.getContext('2d'); + this.ctx = this.canvas.getContext('2d', {willReadFrequently: true}); let img = this.img = new Image() img.src = 'assets/missing.png' @@ -1769,8 +1769,7 @@ class Texture { let target = Texture.all[Texture.all.indexOf(texture)-1]; Undo.initEdit({textures: [target], bitmap: true}); - target.edit(canvas => { - let ctx = canvas.getContext('2d'); + target.edit((canvas, {ctx}) => { ctx.drawImage(texture.img, 0, 0); }, {no_undo: true})