Your comments

Great! Thank you for your help!

And I also use a mixer node to switch between this Code Node and an Alpha Node with final check on.

got it! thank you very much.

Awesome! Thank you for your great work!

Could you also add clamp to alpha node so that the output alpha is always between 0 and 1?