FlatRedBall.Camera.IsTextInView C# (CSharp) Method

IsTextInView() public method

public IsTextInView ( Text text ) : bool
text Text
return bool
        public bool IsTextInView(Text text)
        {
            if(this.CameraCullMode == Graphics.CameraCullMode.UnrotatedDownZ)
            {
                float cameraLeft = this.AbsoluteLeftXEdgeAt(text.Z);
                float cameraRight = this.AbsoluteRightXEdgeAt(text.Z);
                float cameraTop = this.AbsoluteTopYEdgeAt(text.Z);
                float cameraBottom = this.AbsoluteBottomYEdgeAt(text.Z);

                float textVerticalCenter = text.VerticalCenter;
                float textHorizontalCenter = text.HorizontalCenter;

                float longestCenterToEdge
                    = (float)(System.Math.Max(text.Width, text.Height) * 1.42f/2.0f);


                float textLeft = textHorizontalCenter - longestCenterToEdge;
                float textRight = textHorizontalCenter + longestCenterToEdge;
                float textTop = textVerticalCenter + longestCenterToEdge;
                float textBottom = textVerticalCenter - longestCenterToEdge;

                return textRight > cameraLeft &&
                    textLeft < cameraRight &&
                    textBottom < cameraTop &&
                    textTop > cameraBottom;                
            }


            return true;
        }