Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create "Mix" node #2580

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from __future__ import annotations

import numpy as np

from nodes.properties.inputs import ImageInput, SliderInput
from nodes.properties.outputs import ImageOutput

from .. import compositing_group


@compositing_group.register(
schema_id="chainner:image:mix",
name="Mix",
description="Mixes 2 images together.",
icon="BsLayersHalf",
inputs=[
ImageInput("Image A"),
ImageInput("Image B"),
SliderInput(
"Mix",
minimum=0.0,
maximum=1.0,
default=0.5,
precision=4,
controls_step=0.001,
scale="linear",
),
],
outputs=[
ImageOutput(
image_type="""
Image {
width: Input0.width & Input1.width,
height: Input0.height & Input1.height,
channels: max(Input0.channels, Input1.channels),
}
""",
).with_never_reason("Both images must have the same size."),
],
)
def mix_node(input1: np.ndarray, input2: np.ndarray, mix: float) -> np.ndarray:
mixed_image = (1 - mix) * input1 + mix * input2
return mixed_image
Loading