Yotsuba Games
Back to Node List

Switch

switch

Selects one of two already-evaluated values. This is value selection, not a lazy if statement

Reviewed
Guide available
The node name and summary are available in English. Port, parameter, and article details are currently shown in Japanese.

Input Ports

NameTypeDescription
true ใฎใจใ
true_value
Any
ๆกไปถใŒ true ใฎๆ™‚ใซไฝฟใ†ๅ€คใงใ™
false ใฎใจใ
false_value
Any
ๆกไปถใŒ false ใฎๆ™‚ใซไฝฟใ†ๅ€คใงใ™

Output Ports

NameTypeDescription
ๅ€ค
value
Any
้ธใฐใ‚ŒใŸๅ€คใงใ™

Parameters

NameTypeDefaultRangeDescription / Options
ๅˆ‡ใ‚Šๆ›ฟใˆใ‚‹ๅž‹
value_type
Enum
Floatโ€”

ใ“ใฎ Switch ใŒๅˆ‡ใ‚Šๆ›ฟใˆใ‚‹ๅ€คใฎๅž‹ใ‚’้ธใณใพใ™ใ€‚Any ใฏไธŠ็ดš่€…ๅ‘ใ‘ใงใ™ใ€‚

  • ๆ•ฐๅ€ค๏ผˆๆฑŽ็”จ๏ผ‰Number
    Float ใจ Int ใฎไธกๆ–นใ‚’ๆ‰ฑใˆใ‚‹ๆ•ฐๅ€คใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • ๅฐๆ•ฐFloat
    ๅฐๆ•ฐๅ€คใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • ๆ•ดๆ•ฐInt
    ๆ•ดๆ•ฐๅ€คใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • ON/OFFBool
    ON/OFF ใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • ่‰ฒColor
    ่‰ฒใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • ๆ–‡ๅญ—Text
    ๆ–‡ๅญ—ใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • ็”ปๅƒImage
    ็”ปๅƒใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • ใƒ‘ใ‚นPath
    ใƒ‘ใ‚นใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • ใƒ”ใ‚ฏใ‚ปใƒซ็ทšPixelLine
    ใƒ”ใ‚ฏใ‚ปใƒซ็ทšใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • Vec2Vec2
    2Dใƒ™ใ‚ฏใƒˆใƒซใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • Vec3Vec3
    3Dใƒ™ใ‚ฏใƒˆใƒซใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • OKLCH่ฃœๆญฃOklchAdjust
    OKLCHๅŸบๆบ–ใฎๆ˜Žใ‚‹ใ•ใƒป้ฎฎใ‚„ใ‹ใ•ใƒป่‰ฒ็›ธใƒป้€ๆ˜Žๅบฆใฎ่ฃœๆญฃใ‚ปใƒƒใƒˆใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • ใƒ‘ใƒฌใƒƒใƒˆPalette
    ใƒ‘ใƒฌใƒƒใƒˆใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • ใƒชใ‚นใƒˆList
    ใƒชใ‚นใƒˆใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • ใƒžใƒƒใƒ—Map
    ใƒžใƒƒใƒ—ใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • IsoItemIsoItem
    IsoItem ใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • IsoSceneIsoScene
    IsoScene ใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • IsoWorldIsoWorld
    IsoWorld ใ‚’ๅˆ‡ใ‚Šๆ›ฟใˆใพใ™
  • Any๏ผˆไธŠ็ดš่€…ๅ‘ใ‘๏ผ‰Any
    ไธŠ็ดš่€…ๅ‘ใ‘ใงใ™ใ€‚ใฉใฎๅž‹ใงใ‚‚้€šใ›ใพใ™ใŒใ€้ธใฐใ‚ŒใŸๅ€คใฎๅž‹ใŒไธ‹ๆตใƒŽใƒผใƒ‰ใฎๆœŸๅพ…ใจๅˆใ‚ใชใ„ใจๅฎŸ่กŒๆ™‚ใ‚จใƒฉใƒผใซใชใ‚Šใพใ™ใ€‚
ๅˆ‡ใ‚Šๆ›ฟใˆๆกไปถ
condition
Bool
falseโ€”

true ใชใ‚‰ใ€Œtrue ใฎใจใใ€ใ€false ใชใ‚‰ใ€Œfalse ใฎใจใใ€ใ‚’ไฝฟใ„ใพใ™

What is it for?

  • Switching values based on a condition
  • Branching from the result of Compare
  • Choosing between two colors, numbers, paths, or other values

Overview

Selects which of two already-evaluated values to pass downstream from a Bool condition. It can switch numbers, colors, images, paths, or any other type chosen with value_type. It is a value selector, not a lazy programming-language if that skips the unselected branch.

Usage tips

  • The basic pattern is compare.result โ†’ switch.condition, with condition promoted to an input pin ๐Ÿ“Œ. The output switches when the value crosses the threshold.
  • Switching images creates a minimal two-state animation. motion (Blink) โ†’ compare โ†’ switch<Image> alternates between two images.
  • For three or more choices, value_select selects by index more directly. Deeply nested Switch nodes become hard to read.
  • Choose value_type correctly. Use Any only as a last resort because it disables type checking.

Related nodes

  • compare โ€” create the condition
  • value_select โ€” select among N choices by index
  • gate โ€” stop a value instead of choosing one
  • expression_bool โ€” build a Bool from a compound condition

Notes

  • You can promote condition to an input pin. Connecting the result of Compare directly is the go-to setup.
  • When both sides have upstream nodes, normal graph evaluation runs both upstream branches before Switch selects the delivered value. It does not suppress work, side effects, or errors on the unselected side like a lazy if statement.
  • Only the selected side is required. The unused side may be unconnected.
  • If the selected side is unconnected, Switch itself emits no warning and produces an empty output. A downstream node may warn that its input is unconnected.
  • Changing value_type also changes the types of true_value / false_value / value.
  • Normally, feed true_value and false_value with the same type.
  • Any is for advanced use. A connection may be accepted, but if the selected value does not match the type expected downstream, evaluation produces a warning or node error.

Examples

  1. Switch between 0 and 1 from the result of Compare
    • Produces a flag value.
  2. Switch between two colors from the result of Compare
    • Colors the output according to state.
  3. Switch between two Path values
    • Useful when different modes require different shapes.
  4. Pass the output of Switch<Float> to Math Op
    • Sends the branched value directly to the next stage.
  5. Replace a value for debugging with Switch<Any>
    • This is safe only when the downstream setup accepts Any.
Back to Node List
Switch โ€” PixPipeline Node Reference