bugfixes, Allow no image input. Switching images transmits updates. No select on mousevver

This commit is contained in:
Neil Graham
2023-08-25 20:11:29 +12:00
parent 1d715a8370
commit 65c22da48f
2 changed files with 18 additions and 6 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ class Canvas_Tab:
def image_buffer(self, unique_id, mask, canvas, images=None):
collected_images = list()
for image in images:
for image in images or []:
i = 255. * image.cpu().numpy()
img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8))
collected_images.append(image_to_data_url(img))
+17 -5
View File
@@ -51,6 +51,7 @@ function setActivePic(newValue) {
updateLayerList()
}
var dragging = false;
@@ -189,6 +190,7 @@ function createDrawArea(canvas = blankCanvas()) {
canvas.ctx.clearRect(0,0,canvas.width,canvas.height)
for (const layer of this.layers) {
if (suppressMask && this.mask==layer) continue;
if (!layer.visible) continue;
canvas.ctx.globalAlpha = layer.opacity;
canvas.ctx.globalCompositeOperation=layer.composite;
if (this.isDrawing && layer===this.activeLayer) {
@@ -225,11 +227,18 @@ function createDrawArea(canvas = blankCanvas()) {
if (activePic===this) {
updateLayerList(); //inefficient to remake all controls on edit, fix this
}
this.composite();
this.updateVisualRepresentation();
},
updateVisualRepresentation(transmit=false) {
this.composite();
if (transmit && this===selectedExport) transmitCanvas(canvas);
},
startDraw(x,y) {
if (!this.activeLayer.visible) return; //don't draw on hidden layers.
let data = this.activeLayer.ctx.getAllImageData()
activeOperationCanvas.ctx.putImageData(data,0,0);
this.isDrawing=true;
@@ -420,7 +429,7 @@ function handleMouseUp(e) {
}
function handleMouseMove(e) {
let pic = e.currentTarget.pic;
activePic = pic;
if (pic!==activePic) return;
if (dragging) {
if (e.buttons!==4) {
stopDragging();
@@ -697,13 +706,15 @@ function poulateLayerControl() {
$("input.maskColor").on("change", e=>{
lastUsedMaskColor = e.currentTarget.value;
activePic.activeLayer.maskColor=lastUsedMaskColor;
activePic.composite();
activePic.updateVisualRepresentation();
updateLayerList();
});
$("input.opacity").on("input", e=> {
activePic.activeLayer.opacity = e.currentTarget.value/100;
activePic.composite();
activePic.activeLayer.opacity = e.currentTarget.value/100;
activePic.updateVisualRepresentation(true);
//shouldn't need this
updateLayerList();
});
}
@@ -728,6 +739,7 @@ function updateLayerList() {
result.querySelector(".visibilitybox").onmousedown = e => {
e.stopPropagation();
layer.visible=!layer.visible;
pic.updateVisualRepresentation(true);
updateLayerList();
}