bugfixes, Add import options /Image,Layer,Ignore/
This commit is contained in:
+5
-4
@@ -50,10 +50,11 @@ class Canvas_Tab:
|
||||
def image_buffer(self, unique_id, mask, canvas, images=None):
|
||||
|
||||
collected_images = list()
|
||||
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))
|
||||
if images is not None:
|
||||
for image in images:
|
||||
i = 255. * image.cpu().numpy()
|
||||
img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8))
|
||||
collected_images.append(image_to_data_url(img))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -349,6 +349,23 @@ function addNewImage(image) {
|
||||
return(result)
|
||||
}
|
||||
|
||||
function addNewLayer(image) {
|
||||
if (!selectedExport) {
|
||||
setExportPic(addNewImage(image));
|
||||
return;
|
||||
}
|
||||
let pic = selectedExport;
|
||||
if (pic.canvas.width === image.width && pic.canvas.height==image.height) {
|
||||
const layer = new Layer("generation",pic.canvas);
|
||||
layer.ctx.drawImage(image,0,0);
|
||||
console.log("new layer", layer)
|
||||
console.log(layer.canvas.width, layer.canvas.height)
|
||||
pic.layers.push(layer);
|
||||
updateLayerList();
|
||||
pic.updateVisualRepresentation();
|
||||
}
|
||||
}
|
||||
|
||||
function handleMouseDown(e) {
|
||||
//console.log("mousedown on pic",e);
|
||||
let pic = e.currentTarget.pic;
|
||||
|
||||
@@ -11,6 +11,16 @@
|
||||
<body>
|
||||
<div class="fillparent">
|
||||
<div class="panel noselect">
|
||||
<div id="import_control">
|
||||
<label for="import_mode">
|
||||
Incoming Images
|
||||
</label>
|
||||
<select id="import_mode">
|
||||
<option value="image">Create new Image</option>
|
||||
<option value="layer">Add layer <small>(if size matches)</small></option>
|
||||
<option value="ignore">Ignore</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="pixels" class="pen button" style="background-image:url(images/pixels.png);"></div>
|
||||
<div id="tip1" class="pen button" style="background-image:url(images/tip_1.png);"></div>
|
||||
<div id="tip2" class="pen button" style="background-image:url(images/tip_2.png);"></div>
|
||||
|
||||
+12
-2
@@ -100,8 +100,18 @@ canvas.addEventListener('contextmenu', (e) => {
|
||||
function loadImagefromURL(url) {
|
||||
var img = new Image();
|
||||
img.onload = function() {
|
||||
setExportPic(addNewImage(img));
|
||||
|
||||
console.log("import mode is",$("#import_mode").val())
|
||||
switch ($("#import_mode").val()) {
|
||||
case "layer":
|
||||
addNewLayer(img)
|
||||
break;
|
||||
case "image":
|
||||
setExportPic(addNewImage(img));
|
||||
|
||||
break;
|
||||
case "ignore":
|
||||
default:
|
||||
}
|
||||
};
|
||||
img.src = url;
|
||||
}
|
||||
|
||||
+17
-1
@@ -328,4 +328,20 @@ input.maskColor {
|
||||
position:absolute;
|
||||
top: -3px;
|
||||
height:28px;
|
||||
}
|
||||
}
|
||||
|
||||
#import_control {
|
||||
display: inline-block;
|
||||
width: 184px;
|
||||
padding: 0.5em;
|
||||
text-align: center;
|
||||
height: var(--top-panel-height);
|
||||
vertical-align: top;
|
||||
padding-top: 1em;
|
||||
border-right: 1px solid black;
|
||||
}
|
||||
|
||||
#import_control select {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user