Fix manual color input in color panel not working

Make texture editing faster
This commit is contained in:
JannisX11 2023-11-19 17:44:23 +01:00
parent 275d916024
commit 5e14670ae0
2 changed files with 3 additions and 4 deletions

View File

@ -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, '');

View File

@ -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})