Skip to content

Commit

Permalink
tweaks for dynamic variable input not being able to be dynamic....
Browse files Browse the repository at this point in the history
blend node better alpha handling
  • Loading branch information
Amorano committed Aug 28, 2024
1 parent c1a2e18 commit b63e386
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 74 deletions.
3 changes: 1 addition & 2 deletions core/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,9 @@ def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
pA = tensor2cv(pA)
matted = pixel_eval(matte, EnumImageType.BGRA)
pA = image_matte(pA, matted)
tmask = pA

if pB is None:
pB = channel_solid(w, h, matte, chan=EnumImageType.BGRA)
pB = pA
else:
pB = tensor2cv(pB)
tmask = pB
Expand Down
14 changes: 8 additions & 6 deletions sup/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ def cv2tensor(image: TYPE_IMAGE, mask:bool=False) -> torch.Tensor:

def cv2tensor_full(image: TYPE_IMAGE, matte:TYPE_PIXEL=0) -> Tuple[torch.Tensor, ...]:
rgba = image_convert(image, 4)
rgb = image_matte(image, matte)[:,:,:3]
rgb = image_convert(image, 3)
# rgb = image_matte(image, matte)[:,:,:3]
mask = image_mask(image)
rgba = torch.from_numpy(rgba.astype(np.float32) / 255.0).unsqueeze(0)
rgb = torch.from_numpy(rgb.astype(np.float32) / 255.0).unsqueeze(0)
Expand Down Expand Up @@ -738,18 +739,19 @@ def image_blend(imageA: TYPE_IMAGE, imageB: TYPE_IMAGE, mask:Optional[TYPE_IMAGE
imageB = image_crop_center(imageB, w2, h2)
imageB = image_matte(imageB, (0,0,0,0), w, h)
imageB = image_convert(imageB, 4)
old_mask = image_mask(imageB)
if len(old_mask.shape) > 2:
old_mask = old_mask[..., 0][:,:]
#
#old_mask = image_mask(imageB)
#if len(old_mask.shape) > 2:
# old_mask = old_mask[..., 0][:,:]

if mask is not None:
mask = image_crop_center(mask, w, h)
mask = image_matte(mask, (0,0,0,0), w, h)
if len(mask.shape) > 2:
mask = mask[..., 0][:,:]
old_mask = cv2.bitwise_and(mask, old_mask)
#old_mask = cv2.bitwise_and(mask, old_mask)

imageB[..., 3] = old_mask
imageB[..., 3] = mask #old_mask
imageB = cv2pil(imageB)
alpha = np.clip(alpha, 0, 1)
image = blendLayers(imageA, imageB, blendOp.value, alpha)
Expand Down
3 changes: 2 additions & 1 deletion web/core/core_color.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class JovimetrixPanelColorize {
templateColorRow = (data, type = 'block') => {
const isRegex = type === 'regex';
const isHeader = type === 'header';
const self = this;

const createNameCell = () => {
if (isRegex) {
Expand All @@ -223,7 +224,7 @@ class JovimetrixPanelColorize {
name: `regex.${data.idx}`,
value: data.name,
onchange: function() {
this.updateRegexColor(data.idx, "regex", this.value);
self.updateRegexColor(data.idx, "regex", this.value);
}
}),
]);
Expand Down
62 changes: 0 additions & 62 deletions web/core/core_cozy_menu.js

This file was deleted.

2 changes: 1 addition & 1 deletion web/nodes/lerp.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ app.registerExtension({
const me = onNodeCreated?.apply(this);
const alpha = this.widgets.find(w => w.name === '🛟');
widgetHookControl(this, '❓', alpha, true);
widgetHookAB(this, '❓');
widgetHookAB(this, '❓', false);
return me;
}
return nodeType;
Expand Down
6 changes: 4 additions & 2 deletions web/util/util_jov.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function widgetOutputHookType(node, control_key, match_output=0) {
/*
* matchFloatSize forces the target to be float[n] based on its type size
*/
export function widgetHookAB(node, control_key) {
export function widgetHookAB(node, control_key, output_type_match=true) {

const AA = node.widgets.find(w => w.name === '🅰️🅰️');
const BB = node.widgets.find(w => w.name === '🅱️🅱️');
Expand All @@ -87,7 +87,9 @@ export function widgetHookAB(node, control_key) {

widgetHookControl(node, control_key, AA);
widgetHookControl(node, control_key, BB);
widgetOutputHookType(node, control_key);
if (output_type_match) {
widgetOutputHookType(node, control_key);
}
setTimeout(() => { combo.callback(); }, 5);

return combo;
Expand Down

0 comments on commit b63e386

Please sign in to comment.