Esempio n. 1
0
        /// <summary>
        /// Draw marker at the x,y position in the division units
        /// </summary>
        /// <param name="text"></param>
        /// <param name="color"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="scale">Vertical scale</param>
        /// <param name="position">Vertical position</param>
        /// <param name="clampPosition">If label does not fit on screen render it with blinking</param>
        public void DrawLabel(string text, float x, float y, Color color, bool clampPosition = false)
        {
            var pxX      = oscSettings.GetPixelPositionIntX(x);
            var pxY      = oscSettings.GetPixelPositionIntY(y);
            var isNotFit = !oscSettings.TestPixelInsideScreenY(pxY);

            if (isNotFit)
            {
                // if the label outside it modify name
                if (clampPosition)
                {
                    pxY   = oscSettings.ClampPixelInsideScreenY(pxY);
                    text += '!';                     // mark it clamped
                }
                else
                {
                    return;                     // do not render label outside
                }
            }
            // Render little cross hor. and vert. lines.
            OscUtils.PlotLine(screenTexture, pxX, pxY, pxX + 16, pxY, color);
            OscUtils.PlotLine(screenTexture, pxX, pxY - 8, pxX, pxY + 8, color);
            // Render text (if text is not fit move it below the line)
            const int CHAR_HEIGHT = 8;
            const int CHAR_OFFSET = 2;

            if (pxY < oscSettings.textureSize.y - (CHAR_HEIGHT + CHAR_OFFSET))
            {
                // fit on screen
                OscFont.DrawText(screenTexture, text, pxX + 1, pxY + CHAR_OFFSET, color);
            }
            else
            {
                // does not fit on screen
                OscFont.DrawText(screenTexture, text, pxX + 1, pxY - (CHAR_HEIGHT + CHAR_OFFSET), color);
            }
        }