Nodes/Math/Constant/PI.cs
namespace Nodebox.Nodes;

[Register]
[Description("The ratio of a circle's circumference to its diameter")]
[Tag("Math", "Constant")]
[Polymorphic(true)]
public class Pi : Node
{
	public override Vector2 SizeMultiplier => new(0.75f, 1f);
	public override (Pin[] In, Pin[] Out) InitialPins => (
        new Pin[] {
        },
        
        new Pin[] {
            Pin.New<Polymorphic>(""),
        }
    );
    
	public override Node Polymorph(PinWireChange change) =>
        PolymorphHelpers.ToConnectedTypeIfRegistered(typeof(Pi<>), change);

	public DisplayPanel DisplayPanel { get; private set; }
	public override void Render(Panel panel)
	{
        DisplayPanel ??= new DisplayPanel {
            Parent = panel,
            FontSizeOverride = 40f,
        };

        DisplayPanel.Value = "π";
	}
}

[Register(typeof(Library.Float))]
[Polymorphic(typeof(Pi))]
public class Pi<T> : Pi
{

	public override (Pin[] In, Pin[] Out) InitialPins => base.InitialPins.SubstitutePolymorphic<T>();

    public Pi() {
        if (typeof(T) == typeof(float)) {
            SetOutput(0, MathF.PI);
            return;
        }
        else if (typeof(T) == typeof(double)) {
            SetOutput(0, Math.PI);
            return;
        }

        throw new Exception("wtf");
    }

	public override Node Polymorph(PinWireChange change) =>
        PolymorphHelpers.ToNonGenericIfAllDisconnected<Pi>(change);
}