Converted Processing code to Unity 3D C#