Esempio n. 1
0
        public static void drawCaps(NvgContext vg, float x, float y, float width)
        {
            int i;

            LineCap[] caps      = new[] { LineCap.Butt, LineCap.Round, LineCap.Square };
            float     lineWidth = 8.0f;

            vg.Save();

            vg.BeginPath();
            vg.Rect(x - lineWidth / 2, y, width + lineWidth, 40);
            vg.FillColor(new Color(255, 255, 255, 32));
            vg.Fill();

            vg.BeginPath();
            vg.Rect(x, y, width, 40);
            vg.FillColor(new Color(255, 255, 255, 32));
            vg.Fill();

            vg.StrokeWidth(lineWidth);
            for (i = 0; i < 3; i++)
            {
                vg.LineCap(caps[i]);
                vg.StrokeColor(new Color(0, 0, 0, 255));
                vg.BeginPath();
                vg.MoveTo(x, y + i * 10 + 5);
                vg.LineTo(x + width, y + i * 10 + 5);
                vg.Stroke();
            }

            vg.Restore();
        }
Esempio n. 2
0
        public static void drawScissor(NvgContext vg, float x, float y, float t)
        {
            vg.Save();

            // Draw first rect and set scissor to it's area.
            vg.Translate(x, y);
            vg.Rotate(NvgUtility.DegToRad(5));
            vg.BeginPath();
            vg.Rect(-20, -20, 60, 40);
            vg.FillColor(new Color(255, 0, 0, 255));
            vg.Fill();
            vg.Scissor(-20, -20, 60, 40);

            // Draw second rectangle with offset and rotation.
            vg.Translate(40, 0);
            vg.Rotate(t);

            // Draw the intended second rectangle without any scissoring.
            vg.Save();
            vg.ResetScissor();
            vg.BeginPath();
            vg.Rect(-20, -10, 60, 30);
            vg.FillColor(new Color(255, 128, 0, 64));
            vg.Fill();
            vg.Restore();

            // Draw second rectangle with combined scissoring.
            vg.IntersectScissor(-20, -10, 60, 30);
            vg.BeginPath();
            vg.Rect(-20, -10, 60, 30);
            vg.FillColor(new Color(255, 128, 0, 255));
            vg.Fill();

            vg.Restore();
        }
Esempio n. 3
0
        public static void drawDropDown(NvgContext vg, string text, float x, float y, float w, float h)
        {
            Paint bg;
            float cornerRadius = 4.0f;

            bg = vg.LinearGradient(x, y, x, y + h, new Color(255, 255, 255, 16), new Color(0, 0, 0, 16));
            vg.BeginPath();
            vg.RoundedRect(x + 1, y + 1, w - 2, h - 2, cornerRadius - 1);
            vg.FillPaint(bg);
            vg.Fill();

            vg.BeginPath();
            vg.RoundedRect(x + 0.5f, y + 0.5f, w - 1, h - 1, cornerRadius - 0.5f);
            vg.StrokeColor(new Color(0, 0, 0, 48));
            vg.Stroke();

            vg.FontSize(20.0f);
            vg.FontFace("sans");
            vg.FillColor(new Color(255, 255, 255, 160));
            vg.TextAlign(Alignment.Left | Alignment.Middle);
            vg.Text(x + h * 0.3f, y + h * 0.5f, text);

            vg.FontSize(h * 1.3f);
            vg.FontFace("icons");
            vg.FillColor(new Color(255, 255, 255, 64));
            vg.TextAlign(Alignment.Center | Alignment.Middle);
            vg.Text(x + w - h * 0.5f, y + h * 0.5f, ICON_CHEVRON_RIGHT);
        }
Esempio n. 4
0
        public static void drawButton(NvgContext vg, string preicon, string text, float x, float y, float w, float h, Color col)
        {
            Paint bg;
            float cornerRadius = 4.0f;
            float tw = 0, iw = 0;

            bg = vg.LinearGradient(x, y, x, y + h, new Color(255, 255, 255, isBlack(col) ? 16 : 32), new Color(0, 0, 0, isBlack(col) ? 16 : 32));
            vg.BeginPath();
            vg.RoundedRect(x + 1, y + 1, w - 2, h - 2, cornerRadius - 1);
            if (!isBlack(col))
            {
                vg.FillColor(col);
                vg.Fill();
            }
            vg.FillPaint(bg);
            vg.Fill();

            vg.BeginPath();
            vg.RoundedRect(x + 0.5f, y + 0.5f, w - 1, h - 1, cornerRadius - 0.5f);
            vg.StrokeColor(new Color(0, 0, 0, 48));
            vg.Stroke();

            vg.FontSize(20.0f);
            vg.FontFace("sans-bold");
            Bounds bounds = new Bounds();

            tw = vg.TextBounds(0, 0, text, ref bounds);
            if (!string.IsNullOrEmpty(preicon))
            {
                vg.FontSize(h * 1.3f);
                vg.FontFace("icons");
                iw  = vg.TextBounds(0, 0, preicon, ref bounds);
                iw += h * 0.15f;
            }

            if (!string.IsNullOrEmpty(preicon))
            {
                vg.FontSize(h * 1.3f);
                vg.FontFace("icons");
                vg.FillColor(new Color(255, 255, 255, 96));
                vg.TextAlign(Alignment.Left | Alignment.Middle);
                vg.Text(x + w * 0.5f - tw * 0.5f - iw * 0.75f, y + h * 0.5f, preicon);
            }

            vg.FontSize(20.0f);
            vg.FontFace("sans-bold");
            vg.TextAlign(Alignment.Left | Alignment.Middle);
            vg.FillColor(new Color(0, 0, 0, 160));
            vg.Text(x + w * 0.5f - tw * 0.5f + iw * 0.25f, y + h * 0.5f - 1, text);
            vg.FillColor(new Color(255, 255, 255, 160));
            vg.Text(x + w * 0.5f - tw * 0.5f + iw * 0.25f, y + h * 0.5f, text);
        }
Esempio n. 5
0
        public static void drawWindow(NvgContext vg, string title, float x, float y, float w, float h)
        {
            float cornerRadius = 3.0f;
            Paint shadowPaint;
            Paint headerPaint;

            vg.Save();
            //	ClearState(vg);

            // Window
            vg.BeginPath();
            vg.RoundedRect(x, y, w, h, cornerRadius);
            vg.FillColor(new Color(28, 30, 34, 192));
            //	vg.FillColor(new Color(0,0,0,128));
            vg.Fill();

            // Drop shadow
            shadowPaint = vg.BoxGradient(x, y + 2, w, h, cornerRadius * 2, 10, new Color(0, 0, 0, 128), new Color(0, 0, 0, 0));
            vg.BeginPath();
            vg.Rect(x - 10, y - 10, w + 20, h + 30);
            vg.RoundedRect(x, y, w, h, cornerRadius);
            vg.PathWinding(Solidity.Hole);
            vg.FillPaint(shadowPaint);
            vg.Fill();

            // Header
            headerPaint = vg.LinearGradient(x, y, x, y + 15, new Color(255, 255, 255, 8), new Color(0, 0, 0, 16));
            vg.BeginPath();
            vg.RoundedRect(x + 1, y + 1, w - 2, 30, cornerRadius - 1);
            vg.FillPaint(headerPaint);
            vg.Fill();
            vg.BeginPath();
            vg.MoveTo(x + 0.5f, y + 0.5f + 30);
            vg.LineTo(x + 0.5f + w - 1, y + 0.5f + 30);
            vg.StrokeColor(new Color(0, 0, 0, 32));
            vg.Stroke();

            vg.FontSize(18.0f);
            vg.FontFace("sans-bold");
            vg.TextAlign(Alignment.Center | Alignment.Middle);

            vg.FontBlur(2);
            vg.FillColor(new Color(0, 0, 0, 128));
            vg.Text(x + w / 2, y + 16 + 1, title);

            vg.FontBlur(0);
            vg.FillColor(new Color(220, 220, 220, 160));
            vg.Text(x + w / 2, y + 16, title);

            vg.Restore();
        }
Esempio n. 6
0
        public static void drawLabel(NvgContext vg, string text, float x, float y, float w, float h)
        {
            vg.FontSize(18.0f);
            vg.FontFace("sans");
            vg.FillColor(new Color(255, 255, 255, 128));

            vg.TextAlign(Alignment.Left | Alignment.Middle);
            vg.Text(x, y + h * 0.5f, text);
        }
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            base.OnPaint(sender, e);

            e.BeginPath();
            e.Circle(ClientLocation.X + 7, ClientLocation.Y + 7, 7);

            e.FillColor(Checked ? NanoVg.Rgba(ActiveColor) : NanoVg.Rgba(0xFF475054));
            e.Fill();

            e.StrokeColor(NanoVg.Rgba(0xFF192025));
            e.Stroke();

            e.FillColor(NanoVg.Rgba(ForeColor));
            e.FontFace(Font.Family);
            e.FontSize(Font.Size);
            e.TextAlign(NvgAlign.Left | NvgAlign.Middle);
            e.Text(ClientLocation.X + 18, ClientLocation.Y + 7.5f, Text);
        }
Esempio n. 8
0
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            base.OnPaint(sender, e);

            e.BeginPath();
            e.RoundedRect(ClientLocation.X, ClientLocation.Y, Size.Width, Size.Height, 2);

            e.FillColor(Checked ? NanoVg.Rgba(ActiveColor) : NanoVg.Rgba(0xFF475054));
            e.Fill();

            e.StrokeColor(NanoVg.Rgba(0xFF192025));
            e.Stroke();

            e.FillColor(NanoVg.Rgba(ForeColor));
            e.FontFace(Font.Family);
            e.FontSize(Font.Size);
            e.TextAlign(NvgAlign.Left | NvgAlign.Middle);
            e.Text(ClientLocation.X + Size.Width + 4, ClientLocation.Y + Size.Height / 2f, Text);
        }
Esempio n. 9
0
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            float x = Location.X;
            float y = Location.Y;

            e.BeginPath();
            e.Rect(x, y, Width, Height);
            e.FillColor(NanoVg.Rgba(255, 255, 255, 64));
            e.Fill();

            x += FrameWidth;
            y += FrameWidth;

            var usableWidth  = Width - 2 * FrameWidth;
            var usableHeight = Height - 2 * FrameWidth;


            var i    = 0;
            var hPos = 0f;

            e.FontSize(15);
            e.FontFace("sans");
            e.TextAlign(NvgAlign.Left | NvgAlign.Top);

            foreach (var pair in _profiles)
            {
                var perc     = pair.Value.Average.GetAverage() / _totalTime;
                var barWidth = perc * usableWidth;

                e.FillColor(NanoVg.Rgba(Colors[i % Colors.Length]));

                e.BeginPath();
                e.Rect(x + hPos, y, barWidth, usableHeight);
                e.Fill();

                e.Text(x + hPos, y + Height + 15 * i, $"{perc:N2} {pair.Key}");

                hPos += barWidth;
                i++;
            }

            base.OnPaint(sender, e);
        }
Esempio n. 10
0
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            base.OnPaint(sender, e);

            e.FillColor(NanoVg.Rgba(ForeColor));
            e.FontFace(Font.Family);
            e.FontSize(Font.Size);
            e.TextAlign(NvgAlign.Left | NvgAlign.Top);
            e.Text(ClientLocation.X, ClientLocation.Y, Text);
        }
Esempio n. 11
0
        public static void drawEditBox(NvgContext vg, string text, float x, float y, float w, float h)
        {
            drawEditBoxBase(vg, x, y, w, h);

            vg.FontSize(20.0f);
            vg.FontFace("sans");
            vg.FillColor(new Color(255, 255, 255, 64));
            vg.TextAlign(Alignment.Left | Alignment.Middle);
            vg.Text(x + h * 0.3f, y + h * 0.5f, text);
        }
Esempio n. 12
0
        public virtual void Render(Flat6Engine engine, NvgContext context, FrameEventArgs e)
        {
            _fpsGraph.UpdateGraph((float)engine.Window.RenderTime);

            context.FillColor(NanoVg.Rgba(255, 255, 255, 255));
            context.FontFace("engine_mono");
            context.FontSize(18);
            context.TextAlign(NvgAlign.Top | NvgAlign.Left);

            _fpsGraph.RenderGraph(context, 3, 3);
            _tpsGraph.RenderGraph(context, 3, 45);
        }
Esempio n. 13
0
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            base.OnPaint(sender, e);

            e.BeginPath();
            e.Circle(ClientLocation.X + Size.Width / 2f, ClientLocation.Y + Size.Height / 2f, Size.Width / 2f);

            e.FillColor(Lit ? NanoVg.Rgba(ActiveColor) : NanoVg.Rgba(0xFF475054));
            e.Fill();

            e.StrokeColor(NanoVg.Rgba(0xFF192025));
            e.Stroke();
        }
Esempio n. 14
0
        public static void drawCheckBox(NvgContext vg, string text, float x, float y, float w, float h)
        {
            Paint bg;

            vg.FontSize(18.0f);
            vg.FontFace("sans");
            vg.FillColor(new Color(255, 255, 255, 160));

            vg.TextAlign(Alignment.Left | Alignment.Middle);
            vg.Text(x + 28, y + h * 0.5f, text);

            bg = vg.BoxGradient(x + 1, y + (int)(h * 0.5f) - 9 + 1, 18, 18, 3, 3, new Color(0, 0, 0, 32), new Color(0, 0, 0, 92));
            vg.BeginPath();
            vg.RoundedRect(x + 1, y + (int)(h * 0.5f) - 9, 18, 18, 3);
            vg.FillPaint(bg);
            vg.Fill();

            vg.FontSize(40);
            vg.FontFace("icons");
            vg.FillColor(new Color(255, 255, 255, 128));
            vg.TextAlign(Alignment.Center | Alignment.Middle);
            vg.Text(x + 9 + 2, y + h * 0.5f, ICON_CHECK);
        }
Esempio n. 15
0
        public static void drawEditBoxNum(NvgContext vg,
                                          string text, string units, float x, float y, float w, float h)
        {
            float uw;

            drawEditBoxBase(vg, x, y, w, h);

            Bounds bounds = new Bounds();

            uw = vg.TextBounds(0, 0, units, ref bounds);

            vg.FontSize(18.0f);
            vg.FontFace("sans");
            vg.FillColor(new Color(255, 255, 255, 64));
            vg.TextAlign(Alignment.Right | Alignment.Middle);
            vg.Text(x + w - h * 0.3f, y + h * 0.5f, units);

            vg.FontSize(20.0f);
            vg.FontFace("sans");
            vg.FillColor(new Color(255, 255, 255, 128));
            vg.TextAlign(Alignment.Right | Alignment.Middle);
            vg.Text(x + w - uw - h * 0.5f, y + h * 0.5f, text);
        }
Esempio n. 16
0
        public static void drawSearchBox(NvgContext vg, string text, float x, float y, float w, float h)
        {
            Paint bg;
            float cornerRadius = h / 2 - 1;

            // Edit
            bg = vg.BoxGradient(x, y + 1.5f, w, h, h / 2, 5, new Color(0, 0, 0, 16), new Color(0, 0, 0, 92));
            vg.BeginPath();
            vg.RoundedRect(x, y, w, h, cornerRadius);
            vg.FillPaint(bg);
            vg.Fill();

            /*	vg.BeginPath();
             *      vg.RoundedRect(x+0.5f,y+0.5f, w-1,h-1, cornerRadius-0.5f);
             *      vg.StrokeColor(new Color(0,0,0,48));
             *      vg.Stroke();*/

            vg.FontSize(h * 1.3f);
            vg.FontFace("icons");
            vg.FillColor(new Color(255, 255, 255, 64));
            vg.TextAlign(Alignment.Center | Alignment.Middle);
            vg.Text(x + h * 0.55f, y + h * 0.55f, ICON_SEARCH);


            vg.FontSize(20.0f);
            vg.FontFace("sans");
            vg.FillColor(new Color(255, 255, 255, 32));

            vg.TextAlign(Alignment.Left | Alignment.Middle);
            vg.Text(x + h * 1.05f, y + h * 0.5f, text);

            vg.FontSize(h * 1.3f);
            vg.FontFace("icons");
            vg.FillColor(new Color(255, 255, 255, 32));
            vg.TextAlign(Alignment.Center | Alignment.Middle);
            vg.Text(x + w - h * 0.55f, y + h * 0.55f, ICON_CIRCLED_CROSS);
        }
Esempio n. 17
0
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            base.OnPaint(sender, e);

            e.BeginPath();
            e.RoundedRect(ClientLocation.X, ClientLocation.Y, Size.Width, Size.Height, 2);

            e.StrokeColor(NanoVg.Rgba(43, 51, 55, 255));
            e.Stroke();

            e.FillColor(NanoVg.Rgba(ForeColor));
            e.FontFace(Font.Family);
            e.FontSize(Font.Size);
            e.TextAlign(NvgAlign.Baseline | NvgAlign.Left);
            e.Text(ClientLocation.X, ClientLocation.Y - 3, Text);
        }
Esempio n. 18
0
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            base.OnPaint(sender, e);

            e.BeginPath();
            e.RoundedRect(ClientLocation.X, ClientLocation.Y, Size.Width, Size.Height, 2);

            if (Active)
            {
                e.FillPaint(e.LinearGradient(ClientLocation.X, ClientLocation.Y, ClientLocation.X,
                                             ClientLocation.Y + Size.Height, NanoVg.Rgba(0xFF323B40), NanoVg.Rgba(0xFF323B40)));
            }
            else
            {
                e.FillPaint(e.LinearGradient(ClientLocation.X, ClientLocation.Y, ClientLocation.X,
                                             ClientLocation.Y + Size.Height, NanoVg.Rgba(0xFF50595E), NanoVg.Rgba(0xFF2B3337)));
            }
            e.Fill();

            e.StrokeColor(NanoVg.Rgba(0xFF192025));
            e.Stroke();

            e.BeginPath();
            e.RoundedRect(ClientLocation.X + 1, ClientLocation.Y + 1, Size.Width - 2, Size.Height - 2, 1);

            if (Active)
            {
                e.StrokeColor(NanoVg.Rgba(0xFF293034));
            }
            else
            {
                e.StrokePaint(e.LinearGradient(ClientLocation.X, ClientLocation.Y, ClientLocation.X,
                                               ClientLocation.Y + Size.Height, NanoVg.Rgba(0xFF6E757B), NanoVg.Rgba(0xFF323B40)));
            }
            e.Stroke();

            e.FillColor(NanoVg.Rgba(ForeColor));
            e.FontFace(Font.Family);
            e.FontSize(Font.Size);
            e.TextAlign(NvgAlign.Center | NvgAlign.Middle);
            e.Text(ClientLocation.X + Size.Width / 2, ClientLocation.Y + Size.Height / 2, Text);
        }
Esempio n. 19
0
        public static void drawSlider(NvgContext vg, float pos, float x, float y, float w, float h)
        {
            Paint bg, knob;
            float cy = y + (int)(h * 0.5f);
            float kr = (int)(h * 0.25f);

            vg.Save();
            //	ClearState(vg);

            // Slot
            bg = vg.BoxGradient(x, cy - 2 + 1, w, 4, 2, 2, new Color(0, 0, 0, 32), new Color(0, 0, 0, 128));
            vg.BeginPath();
            vg.RoundedRect(x, cy - 2, w, 4, 2);
            vg.FillPaint(bg);
            vg.Fill();

            // Knob Shadow
            bg = vg.RadialGradient(x + (int)(pos * w), cy + 1, kr - 3, kr + 3, new Color(0, 0, 0, 64), new Color(0, 0, 0, 0));
            vg.BeginPath();
            vg.Rect(x + (int)(pos * w) - kr - 5, cy - kr - 5, kr * 2 + 5 + 5, kr * 2 + 5 + 5 + 3);
            vg.Circle(x + (int)(pos * w), cy, kr);
            vg.PathWinding(Solidity.Hole);
            vg.FillPaint(bg);
            vg.Fill();

            // Knob
            knob = vg.LinearGradient(x, cy - kr, x, cy + kr, new Color(255, 255, 255, 16), new Color(0, 0, 0, 16));
            vg.BeginPath();
            vg.Circle(x + (int)(pos * w), cy, kr - 1);
            vg.FillColor(new Color(40, 43, 48, 255));
            vg.Fill();
            vg.FillPaint(knob);
            vg.Fill();

            vg.BeginPath();
            vg.Circle(x + (int)(pos * w), cy, kr - 0.5f);
            vg.StrokeColor(new Color(0, 0, 0, 92));
            vg.Stroke();

            vg.Restore();
        }
Esempio n. 20
0
        public void Render(Matrix4 model, Matrix4 view, Matrix4 projection)
        {
            _framebuffer.Use();
            GL.PushMatrix();

            GL.Clear(ClearBufferMask.ColorBufferBit |
                     ClearBufferMask.DepthBufferBit |
                     ClearBufferMask.StencilBufferBit);

            GL.Color3(Color.White);

            // Set up uniforms
            _uTint.Value          = TintColor;
            _uLightPos.Value      = LightPosition;
            _uMatModel.Value      = model;
            _uMatView.Value       = view;
            _uMatProjection.Value = projection;
            _uSamples.Value       = _framebuffer.Samples;
            _uTexRandom.Value     = 1;

            GL.ActiveTexture(TextureUnit.Texture1);
            GL.BindTexture(TextureTarget.Texture2D, _texRandom);

            // Engage shader, render, disengage
            _shaderModel.Use(_uTint, _uLightPos, _uMatModel, _uMatView, _uMatProjection, _uSamples, _uTexRandom);

            foreach (var chunk in Chunks)
            {
                chunk?.Draw();
            }

            _shaderScreen.Release();

            // Render the ocean
            GL.Color3(Color.MediumBlue);

            var waterLevel = _generator.GetWaterLevel();

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadMatrix(ref projection);
            GL.MatrixMode(MatrixMode.Modelview);
            var mat = view * model;

            GL.LoadMatrix(ref mat);

            GL.Begin(PrimitiveType.Quads);
            GL.Normal3(Vector3.UnitY);
            GL.Vertex3(-1, waterLevel - 0.4, -1);
            GL.Vertex3(SideLength * 16 - 1, waterLevel - 0.4, -1);
            GL.Vertex3(SideLength * 16 - 1, waterLevel - 0.4, SideLength * 16 - 1);
            GL.Vertex3(-1, waterLevel - 0.4, SideLength * 16 - 1);
            GL.End();

            GL.PopMatrix();
            _framebuffer.Release();

            _framebufferUi.Use();
            GL.ClearColor(0, 0, 0, 0);
            GL.Clear(ClearBufferMask.ColorBufferBit |
                     ClearBufferMask.DepthBufferBit |
                     ClearBufferMask.StencilBufferBit);

            _nvg.BeginFrame(_window.Width, _window.Height, 1);
            _nvg.Save();

            _nvg.FillColor(NanoVg.Rgba(255, 255, 255, 255));
            _nvg.FontFace("sans");
            _nvg.FontSize(18);
            _nvg.TextAlign(NvgAlign.Top | NvgAlign.Left);

            _perfGraphFps.RenderGraph(_nvg, 4, 4);

            _nvg.Restore();

            _ui.Render(this, _nvg);

            _nvg.EndFrame();
            _framebufferUi.Release();

            _uWidth.Value     = _window.Width;
            _uHeight.Value    = _window.Height;
            _uTexColor.Value  = 0;
            _uTexUi.Value     = 1;
            _uSamples.Value   = _framebuffer.Samples;
            _uSamplesUi.Value = _framebufferUi.Samples;

            _shaderScreen.Use(_uWidth, _uHeight, _uTexColor, _uTexUi, _uSamples, _uSamplesUi);
            DrawFullscreenQuad(_framebuffer.TextureId, _framebufferUi.TextureId);
            _shaderScreen.Release();
        }
Esempio n. 21
0
        public static void drawParagraph(NvgContext vg, float x, float y, float width, float height, float mx, float my)
        {
            TextRow[]       rows   = new TextRow[3];
            GlyphPosition[] glyphs = new GlyphPosition[100];
            string          text   = "This is longer chunk of text.\n  \n  Would have used lorem ipsum but she    was busy jumping over the lazy dog with the fox and all the men who came to the aid of the party.";
            StringSegment   start;
            int             nrows, i, nglyphs, j, lnum = 0;
            float           lineh;
            float           caretx, px;
            Bounds          bounds = new Bounds();
            float           a;
            float           gx = 0, gy = 0;
            int             gutter = 0;

            for (i = 0; i < rows.Length; ++i)
            {
                rows[i] = new TextRow();
            }

            vg.Save();

            vg.FontSize(18.0f);
            vg.FontFace("sans");
            vg.TextAlign(Alignment.Left | Alignment.Top);

            float ascender, descender;

            vg.TextMetrics(out ascender, out descender, out lineh);

            // The text break API can be used to fill a large buffer of rows,
            // or to iterate over the text just few lines (or just one) at a time.
            // The "next" variable of the last returned item tells where to continue.
            start = text;
            while (true)
            {
                nrows = vg.TextBreakLines(start, width, rows, out start);

                if (nrows <= 0)
                {
                    break;
                }
                for (i = 0; i < nrows; i++)
                {
                    TextRow row = rows[i];
                    var     hit = mx > x && mx < (x + width) && my >= y && my < (y + lineh);

                    vg.BeginPath();
                    vg.FillColor(new Color(255, 255, 255, hit ? 64 : 16));
                    vg.Rect(x, y, row.Width, lineh);
                    vg.Fill();

                    vg.FillColor(new Color(255, 255, 255, 255));
                    vg.Text(x, y, row.Str);

                    if (hit)
                    {
                        caretx  = (mx < x + row.Width / 2) ? x : x + row.Width;
                        px      = x;
                        nglyphs = vg.TextGlyphPositions(x, y, row.Str, glyphs);
                        for (j = 0; j < nglyphs; j++)
                        {
                            float x0  = glyphs[j].X;
                            float x1  = (j + 1 < nglyphs) ? glyphs[j + 1].X : x + row.Width;
                            float gx2 = x0 * 0.3f + x1 * 0.7f;
                            if (mx >= px && mx < gx2)
                            {
                                caretx = glyphs[j].X;
                            }
                            px = gx2;
                        }
                        vg.BeginPath();
                        vg.FillColor(new Color(255, 192, 0, 255));
                        vg.Rect(caretx, y, 1, lineh);
                        vg.Fill();

                        gutter = lnum + 1;
                        gx     = x - 10;
                        gy     = y + lineh / 2;
                    }
                    lnum++;
                    y += lineh;
                }
            }

            if (gutter > 0)
            {
                string txt = gutter.ToString();
                vg.FontSize(13.0f);
                vg.TextAlign(Alignment.Right | Alignment.Middle);

                vg.TextBounds(gx, gy, txt, ref bounds);

                vg.BeginPath();
                vg.FillColor(new Color(255, 192, 0, 255));
                vg.RoundedRect((int)bounds.b1 - 4, (int)bounds.b2 - 2,
                               (int)(bounds.b3 - bounds.b1) + 8,
                               (int)(bounds.b4 - bounds.b2) + 4,
                               ((int)(bounds.b4 - bounds.b2) + 4) / 2 - 1);
                vg.Fill();

                vg.FillColor(new Color(32, 32, 32, 255));
                vg.Text(gx, gy, txt);
            }

            y += 20.0f;

            vg.FontSize(13.0f);
            vg.TextAlign(Alignment.Left | Alignment.Top);
            vg.TextLineHeight(1.2f);

            vg.TextBoxBounds(x, y, 150, "Hover your mouse over the text to see calculated caret position.", ref bounds);

            // Fade the tooltip out when close to it.
            gx = (float)Math.Abs((mx - (bounds.b1 + bounds.b3) * 0.5f) / (bounds.b1 - bounds.b3));
            gy = (float)Math.Abs((my - (bounds.b2 + bounds.b4) * 0.5f) / (bounds.b2 - bounds.b4));
            a  = maxf(gx, gy) - 0.5f;
            a  = clampf(a, 0, 1);
            vg.GlobalAlpha(a);

            vg.BeginPath();
            vg.FillColor(new Color(220, 220, 220, 255));
            vg.RoundedRect(bounds.b1 - 2, bounds.b2 - 2, (int)(bounds.b3 - bounds.b1) + 4, (int)(bounds.b4 - bounds.b2) + 4, 3);
            px = (int)((bounds.b3 + bounds.b1) / 2);
            vg.MoveTo(px, bounds.b2 - 10);
            vg.LineTo(px + 7, bounds.b2 + 1);
            vg.LineTo(px - 7, bounds.b2 + 1);
            vg.Fill();

            vg.FillColor(new Color(0, 0, 0, 220));
            vg.TextBox(x, y, 150, "Hover your mouse over the text to see calculated caret position.");

            vg.Restore();
        }
Esempio n. 22
0
        public static void drawThumbnails(NvgContext vg, float x, float y, float w, float h, int[] images, float t)
        {
            float cornerRadius = 3.0f;
            Paint shadowPaint, imgPaint, fadePaint;
            float ix, iy, iw, ih;
            float thumb = 60.0f;
            float arry = 30.5f;
            int   imgw, imgh;
            float stackh = (images.Length / 2) * (thumb + 10) + 10;
            int   i;
            float u = (1 + (float)Math.Cos(t * 0.5f)) * 0.5f;
            float u2 = (1 - (float)Math.Cos(t * 0.2f)) * 0.5f;
            float scrollh, dv;

            vg.Save();
            //	ClearState(vg);

            // Drop shadow
            shadowPaint = vg.BoxGradient(x, y + 4, w, h, cornerRadius * 2, 20, new Color(0, 0, 0, 128), new Color(0, 0, 0, 0));
            vg.BeginPath();
            vg.Rect(x - 10, y - 10, w + 20, h + 30);
            vg.RoundedRect(x, y, w, h, cornerRadius);
            vg.PathWinding(Solidity.Hole);
            vg.FillPaint(shadowPaint);
            vg.Fill();

            // Window
            vg.BeginPath();
            vg.RoundedRect(x, y, w, h, cornerRadius);
            vg.MoveTo(x - 10, y + arry);
            vg.LineTo(x + 1, y + arry - 11);
            vg.LineTo(x + 1, y + arry + 11);
            vg.FillColor(new Color(200, 200, 200, 255));
            vg.Fill();

            vg.Save();
            vg.Scissor(x, y, w, h);
            vg.Translate(0, -(stackh - h) * u);

            dv = 1.0f / (float)(images.Length - 1);

            for (i = 0; i < images.Length; i++)
            {
                float tx, ty, v, a;
                tx  = x + 10;
                ty  = y + 10;
                tx += (i % 2) * (thumb + 10);
                ty += (i / 2) * (thumb + 10);
                vg.ImageSize(images[i], out imgw, out imgh);
                if (imgw < imgh)
                {
                    iw = thumb;
                    ih = iw * (float)imgh / (float)imgw;
                    ix = 0;
                    iy = -(ih - thumb) * 0.5f;
                }
                else
                {
                    ih = thumb;
                    iw = ih * (float)imgw / (float)imgh;
                    ix = -(iw - thumb) * 0.5f;
                    iy = 0;
                }

                v = i * dv;
                a = clampf((u2 - v) / dv, 0, 1);

                if (a < 1.0f)
                {
                    drawSpinner(vg, tx + thumb / 2, ty + thumb / 2, thumb * 0.25f, t);
                }

                imgPaint = vg.ImagePattern(tx + ix, ty + iy, iw, ih, 0.0f / 180.0f * (float)Math.PI, images[i], a);
                vg.BeginPath();
                vg.RoundedRect(tx, ty, thumb, thumb, 5);
                vg.FillPaint(imgPaint);
                vg.Fill();

                shadowPaint = vg.BoxGradient(tx - 1, ty, thumb + 2, thumb + 2, 5, 3, new Color(0, 0, 0, 128), new Color(0, 0, 0, 0));
                vg.BeginPath();
                vg.Rect(tx - 5, ty - 5, thumb + 10, thumb + 10);
                vg.RoundedRect(tx, ty, thumb, thumb, 6);
                vg.PathWinding(Solidity.Hole);
                vg.FillPaint(shadowPaint);
                vg.Fill();

                vg.BeginPath();
                vg.RoundedRect(tx + 0.5f, ty + 0.5f, thumb - 1, thumb - 1, 4 - 0.5f);
                vg.StrokeWidth(1.0f);
                vg.StrokeColor(new Color(255, 255, 255, 192));
                vg.Stroke();
            }
            vg.Restore();

            // Hide fades
            fadePaint = vg.LinearGradient(x, y, x, y + 6, new Color(200, 200, 200, 255), new Color(200, 200, 200, 0));
            vg.BeginPath();
            vg.Rect(x + 4, y, w - 8, 6);
            vg.FillPaint(fadePaint);
            vg.Fill();

            fadePaint = vg.LinearGradient(x, y + h, x, y + h - 6, new Color(200, 200, 200, 255), new Color(200, 200, 200, 0));
            vg.BeginPath();
            vg.Rect(x + 4, y + h - 6, w - 8, 6);
            vg.FillPaint(fadePaint);
            vg.Fill();

            // Scroll bar
            shadowPaint = vg.BoxGradient(x + w - 12 + 1, y + 4 + 1, 8, h - 8, 3, 4, new Color(0, 0, 0, 32), new Color(0, 0, 0, 92));
            vg.BeginPath();
            vg.RoundedRect(x + w - 12, y + 4, 8, h - 8, 3);
            vg.FillPaint(shadowPaint);
            //	vg.FillColor(new Color(255,0,0,128));
            vg.Fill();

            scrollh     = (h / stackh) * (h - 8);
            shadowPaint = vg.BoxGradient(x + w - 12 - 1, y + 4 + (h - 8 - scrollh) * u - 1, 8, scrollh, 3, 4, new Color(220, 220, 220, 255), new Color(128, 128, 128, 255));
            vg.BeginPath();
            vg.RoundedRect(x + w - 12 + 1, y + 4 + 1 + (h - 8 - scrollh) * u, 8 - 2, scrollh - 2, 2);
            vg.FillPaint(shadowPaint);
            //	vg.FillColor(new Color(0,0,0,128));
            vg.Fill();

            vg.Restore();
        }
Esempio n. 23
0
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            int i;

            float x = Location.X;
            float y = Location.Y;

            e.BeginPath();
            e.Rect(x, y, Width, Height);
            e.FillColor(NanoVg.Rgba(255, 255, 255, 64));
            e.Fill();

            e.BeginPath();

            if (Fill)
            {
                e.MoveTo(x, y + Height);
            }
            else
            {
                var v0 = _values[_head % HistoryCount];
                v0 = F6Math.RemapClamp(v0, Min, Max, 0, Height);
                e.MoveTo(x, y + Height - v0);
            }

            for (i = 0; i < HistoryCount; i++)
            {
                var v  = _values[(_head + i) % HistoryCount];
                var vx = x + (float)i / (HistoryCount - 1) * Width;
                var vy = y + Height - F6Math.RemapClamp(v, Min, Max, 0, Height);
                e.LineTo(vx, vy);
            }

            if (Fill)
            {
                e.LineTo(x + Width, y + Height);
                e.FillColor(NanoVg.Rgba(Color));
                e.Fill();
            }
            else
            {
                e.StrokeColor(NanoVg.Rgba(Color));
                e.Stroke();
            }

            var avgY = F6Math.RemapClamp(_avg, Min, Max, 0, Height);

            e.BeginPath();
            e.MoveTo(x, y + Height - avgY);
            e.LineTo(x + Width, y + Height - avgY);
            e.StrokeColor(NanoVg.Rgba(255, 255, 255, 128));
            e.Stroke();

            e.FontFace(FontFamily);

            if (Title != null)
            {
                e.FontSize(14.0f);
                e.TextAlign(NvgAlign.Left | NvgAlign.Top);
                e.FillColor(NanoVg.Rgba(240, 240, 240, 192));
                e.Text(x + 3, y + 1, Title);
            }

            e.FontSize(16.0f);
            e.TextAlign(NvgAlign.Right | NvgAlign.Top);
            e.FillColor(NanoVg.Rgba(240, 240, 240, 255));
            var str = string.Format(Number, _avg.ToString(NumberFormatStyle));

            e.Text(x + Width - 3, y + 1, str);

            if (Unit != null)
            {
                e.FontSize(15.0f);
                e.TextAlign(NvgAlign.Right | NvgAlign.Bottom);
                e.FillColor(NanoVg.Rgba(240, 240, 240, 160));
                e.Text(x + Width - 3, y + Height - 1, Unit);
            }

            base.OnPaint(sender, e);
        }
Esempio n. 24
0
        public static void drawGraph(NvgContext vg, float x, float y, float w, float h, float t)
        {
            Paint bg;

            float[] samples = new float[6];
            float[] sx      = new float[6], sy = new float[6];
            float   dx      = w / 5.0f;
            int     i;

            samples[0] = (1 + (float)Math.Sin(t * 1.2345f + (float)Math.Cos(t * 0.33457f) * 0.44f)) * 0.5f;
            samples[1] = (1 + (float)Math.Sin(t * 0.68363f + (float)Math.Cos(t * 1.3f) * 1.55f)) * 0.5f;
            samples[2] = (1 + (float)Math.Sin(t * 1.1642f + (float)Math.Cos(t * 0.33457) * 1.24f)) * 0.5f;
            samples[3] = (1 + (float)Math.Sin(t * 0.56345f + (float)Math.Cos(t * 1.63f) * 0.14f)) * 0.5f;
            samples[4] = (1 + (float)Math.Sin(t * 1.6245f + (float)Math.Cos(t * 0.254f) * 0.3f)) * 0.5f;
            samples[5] = (1 + (float)Math.Sin(t * 0.345f + (float)Math.Cos(t * 0.03f) * 0.6f)) * 0.5f;

            for (i = 0; i < 6; i++)
            {
                sx[i] = x + i * dx;
                sy[i] = y + h * samples[i] * 0.8f;
            }

            // Graph background
            bg = vg.LinearGradient(x, y, x, y + h, new Color(0, 160, 192, 0), new Color(0, 160, 192, 64));
            vg.BeginPath();
            vg.MoveTo(sx[0], sy[0]);
            for (i = 1; i < 6; i++)
            {
                vg.BezierTo(sx[i - 1] + dx * 0.5f, sy[i - 1], sx[i] - dx * 0.5f, sy[i], sx[i], sy[i]);
            }
            vg.LineTo(x + w, y + h);
            vg.LineTo(x, y + h);
            vg.FillPaint(bg);
            vg.Fill();

            // Graph line
            vg.BeginPath();
            vg.MoveTo(sx[0], sy[0] + 2);
            for (i = 1; i < 6; i++)
            {
                vg.BezierTo(sx[i - 1] + dx * 0.5f, sy[i - 1] + 2, sx[i] - dx * 0.5f, sy[i] + 2, sx[i], sy[i] + 2);
            }
            vg.StrokeColor(new Color(0, 0, 0, 32));
            vg.StrokeWidth(3.0f);
            vg.Stroke();

            vg.BeginPath();
            vg.MoveTo(sx[0], sy[0]);
            for (i = 1; i < 6; i++)
            {
                vg.BezierTo(sx[i - 1] + dx * 0.5f, sy[i - 1], sx[i] - dx * 0.5f, sy[i], sx[i], sy[i]);
            }
            vg.StrokeColor(new Color(0, 160, 192, 255));
            vg.StrokeWidth(3.0f);
            vg.Stroke();

            // Graph sample pos
            for (i = 0; i < 6; i++)
            {
                bg = vg.RadialGradient(sx[i], sy[i] + 2, 3.0f, 8.0f, new Color(0, 0, 0, 32), new Color(0, 0, 0, 0));
                vg.BeginPath();
                vg.Rect(sx[i] - 10, sy[i] - 10 + 2, 20, 20);
                vg.FillPaint(bg);
                vg.Fill();
            }

            vg.BeginPath();
            for (i = 0; i < 6; i++)
            {
                vg.Circle(sx[i], sy[i], 4.0f);
            }
            vg.FillColor(new Color(0, 160, 192, 255));
            vg.Fill();
            vg.BeginPath();
            for (i = 0; i < 6; i++)
            {
                vg.Circle(sx[i], sy[i], 2.0f);
            }
            vg.FillColor(new Color(220, 220, 220, 255));
            vg.Fill();

            vg.StrokeWidth(1.0f);
        }
Esempio n. 25
0
        public static void drawEyes(NvgContext vg, float x, float y, float w, float h, float mx, float my, float t)
        {
            Paint gloss, bg;
            float ex = w * 0.23f;
            float ey = h * 0.5f;
            float lx = x + ex;
            float ly = y + ey;
            float rx = x + w - ex;
            float ry = y + ey;
            float dx, dy, d;
            float br    = (ex < ey ? ex : ey) * 0.5f;
            float blink = 1 - (float)(Math.Pow(Math.Sin(t * 0.5f), 200) * 0.8f);

            bg = vg.LinearGradient(x, y + h * 0.5f, x + w * 0.1f, y + h, new Color(0, 0, 0, 32), new Color(0, 0, 0, 16));
            vg.BeginPath();
            vg.Ellipse(lx + 3.0f, ly + 16.0f, ex, ey);
            vg.Ellipse(rx + 3.0f, ry + 16.0f, ex, ey);
            vg.FillPaint(bg);
            vg.Fill();

            bg = vg.LinearGradient(x, y + h * 0.25f, x + w * 0.1f, y + h, new Color(220, 220, 220, 255), new Color(128, 128, 128, 255));
            vg.BeginPath();
            vg.Ellipse(lx, ly, ex, ey);
            vg.Ellipse(rx, ry, ex, ey);
            vg.FillPaint(bg);
            vg.Fill();

            dx = (mx - rx) / (ex * 10);
            dy = (my - ry) / (ey * 10);
            d  = (float)Math.Sqrt(dx * dx + dy * dy);
            if (d > 1.0f)
            {
                dx /= d;
                dy /= d;
            }
            dx *= ex * 0.4f;
            dy *= ey * 0.5f;
            vg.BeginPath();
            vg.Ellipse(lx + dx, ly + dy + ey * 0.25f * (1 - blink), br, br * blink);
            vg.FillColor(new Color(32, 32, 32, 255));
            vg.Fill();

            dx = (mx - rx) / (ex * 10);
            dy = (my - ry) / (ey * 10);
            d  = (float)Math.Sqrt(dx * dx + dy * dy);
            if (d > 1.0f)
            {
                dx /= d;
                dy /= d;
            }
            dx *= ex * 0.4f;
            dy *= ey * 0.5f;
            vg.BeginPath();
            vg.Ellipse(rx + dx, ry + dy + ey * 0.25f * (1 - blink), br, br * blink);
            vg.FillColor(new Color(32, 32, 32, 255));
            vg.Fill();

            gloss = vg.RadialGradient(lx - ex * 0.25f, ly - ey * 0.5f, ex * 0.1f, ex * 0.75f, new Color(255, 255, 255, 128), new Color(255, 255, 255, 0));
            vg.BeginPath();
            vg.Ellipse(lx, ly, ex, ey);
            vg.FillPaint(gloss);
            vg.Fill();

            gloss = vg.RadialGradient(rx - ex * 0.25f, ry - ey * 0.5f, ex * 0.1f, ex * 0.75f, new Color(255, 255, 255, 128), new Color(255, 255, 255, 0));
            vg.BeginPath();
            vg.Ellipse(rx, ry, ex, ey);
            vg.FillPaint(gloss);
            vg.Fill();
        }
Esempio n. 26
0
        public static void RenderGraph(NvgContext vg, float x, float y)
        {
            int         i;
            string      str;
            var         avg = GetGraphAverage();
            const float w   = 200;
            const float h   = 35;

            vg.BeginPath();
            vg.Rect(x, y, w, h);
            vg.FillColor(NanoVg.Rgba(0, 0, 0, 128));
            vg.Fill();

            vg.BeginPath();
            vg.MoveTo(x, y + h);
            if (_style == (int)GraphRenderStyle.Fps)
            {
                for (i = 0; i < GraphHistoryCount; i++)
                {
                    var   v = 1.0f / (0.00001f + _values[(_head + i) % GraphHistoryCount]);
                    float vx, vy;
                    if (v > 80.0f)
                    {
                        v = 80.0f;
                    }
                    vx = x + (float)i / (GraphHistoryCount - 1) * w;
                    vy = y + h - v / 80.0f * h;
                    vg.LineTo(vx, vy);
                }
            }
            else if (_style == (int)GraphRenderStyle.Percent)
            {
                for (i = 0; i < GraphHistoryCount; i++)
                {
                    var   v = _values[(_head + i) % GraphHistoryCount] * 1.0f;
                    float vx, vy;
                    if (v > 100.0f)
                    {
                        v = 100.0f;
                    }
                    vx = x + (float)i / (GraphHistoryCount - 1) * w;
                    vy = y + h - v / 100.0f * h;
                    vg.LineTo(vx, vy);
                }
            }
            else
            {
                for (i = 0; i < GraphHistoryCount; i++)
                {
                    var   v = _values[(_head + i) % GraphHistoryCount] * 1000.0f;
                    float vx, vy;
                    if (v > 20.0f)
                    {
                        v = 20.0f;
                    }
                    vx = x + (float)i / (GraphHistoryCount - 1) * w;
                    vy = y + h - v / 20.0f * h;
                    vg.LineTo(vx, vy);
                }
            }
            vg.LineTo(x + w, y + h);
            vg.FillColor(NanoVg.Rgba(255, 192, 0, 128));
            vg.Fill();

            vg.FontFace("sans");

            if (_name[0] != '\0')
            {
                vg.FontSize(14.0f);
                vg.TextAlign(NvgAlign.Left | NvgAlign.Top);
                vg.FillColor(NanoVg.Rgba(240, 240, 240, 192));
                vg.Text(x + 3, y + 1, _name);
            }

            if (_style == (int)GraphRenderStyle.Fps)
            {
                vg.FontSize(18.0f);
                vg.TextAlign(NvgAlign.Right | NvgAlign.Top);
                vg.FillColor(NanoVg.Rgba(240, 240, 240, 255));
                str = $"{1.0f / avg:0.00} FPS";
                vg.Text(x + w - 3, y + 1, str);

                vg.FontSize(15.0f);
                vg.TextAlign(NvgAlign.Right | NvgAlign.Bottom);
                vg.FillColor(NanoVg.Rgba(240, 240, 240, 160));
                str = $"{avg * 1000.0f:0.00} ms";
                vg.Text(x + w - 3, y + h - 1, str);
            }
            else if (_style == (int)GraphRenderStyle.Percent)
            {
                vg.FontSize(18.0f);
                vg.TextAlign(NvgAlign.Right | NvgAlign.Top);
                vg.FillColor(NanoVg.Rgba(240, 240, 240, 255));
                str = $"{avg * 1.0f:0.0} %";
                vg.Text(x + w - 3, y + 1, str);
            }
            else
            {
                vg.FontSize(18.0f);
                vg.TextAlign(NvgAlign.Right | NvgAlign.Top);
                vg.FillColor(NanoVg.Rgba(240, 240, 240, 255));
                str = $"{avg * 1000.0f:0.00} ms";
                vg.Text(x + w - 3, y + 1, str);
            }
        }
Esempio n. 27
0
        public void Render(NvgContext vg, float x, float y)
        {
            int    i;
            float  avg, w, h;
            string str;

            avg = GetAverage();

            w = 200;
            h = 35;

            vg.BeginPath();
            vg.Rect(x, y, w, h);
            vg.FillColor(new Color(0, 0, 0, 128));
            vg.Fill();

            vg.BeginPath();
            vg.MoveTo(x, y + h);
            if (_style == Style.GRAPH_RENDER_FPS)
            {
                for (i = 0; i < _values.Length; i++)
                {
                    float v = 1.0f / (0.00001f + _values[(_head + i) % _values.Length]);
                    float vx, vy;
                    if (v > 80.0f)
                    {
                        v = 80.0f;
                    }
                    vx = x + ((float)i / (_values.Length - 1)) * w;
                    vy = y + h - ((v / 80.0f) * h);
                    vg.LineTo(vx, vy);
                }
            }
            else if (_style == Style.GRAPH_RENDER_PERCENT)
            {
                for (i = 0; i < _values.Length; i++)
                {
                    float v = _values[(_head + i) % _values.Length] * 1.0f;
                    float vx, vy;
                    if (v > 100.0f)
                    {
                        v = 100.0f;
                    }
                    vx = x + ((float)i / (_values.Length - 1)) * w;
                    vy = y + h - ((v / 100.0f) * h);
                    vg.LineTo(vx, vy);
                }
            }
            else
            {
                for (i = 0; i < _values.Length; i++)
                {
                    float v = _values[(_head + i) % _values.Length] * 1000.0f;
                    float vx, vy;
                    if (v > 20.0f)
                    {
                        v = 20.0f;
                    }
                    vx = x + ((float)i / (_values.Length - 1)) * w;
                    vy = y + h - ((v / 20.0f) * h);
                    vg.LineTo(vx, vy);
                }
            }
            vg.LineTo(x + w, y + h);
            vg.FillColor(new Color(255, 192, 0, 128));
            vg.Fill();

            if (!string.IsNullOrEmpty(_name))
            {
                vg.FontSize(14.0f);
                vg.TextAlign(Alignment.Left | Alignment.Top);
                vg.FillColor(new Color(240, 240, 240, 192));
                vg.Text(x + 3, y + 1, _name);
            }

            if (_style == Style.GRAPH_RENDER_FPS)
            {
                vg.FontSize(18.0f);
                vg.TextAlign(Alignment.Right | Alignment.Top);
                vg.FillColor(new Color(240, 240, 240, 255));
                str = string.Format("{0:0.00} FPS", 1.0f / avg);
                vg.Text(x + w - 3, y + 1, str);

                vg.FontSize(15.0f);
                vg.TextAlign(Alignment.Right | Alignment.Bottom);
                vg.FillColor(new Color(240, 240, 240, 160));
                str = string.Format("{0:0.00} ms", avg * 1000.0f);
                vg.Text(x + w - 3, y + h - 1, str);
            }
            else if (_style == Style.GRAPH_RENDER_PERCENT)
            {
                vg.FontSize(18.0f);
                vg.TextAlign(Alignment.Right | Alignment.Top);
                vg.FillColor(new Color(240, 240, 240, 255));
                str = string.Format("{0:0.00} %%", avg);
                vg.Text(x + w - 3, y + 1, str);
            }
            else
            {
                vg.FontSize(18.0f);
                vg.TextAlign(Alignment.Right | Alignment.Top);
                vg.FillColor(new Color(240, 240, 240, 255));
                str = string.Format("{0:0.00} ms", avg * 1000.0f);
                vg.Text(x + w - 3, y + 1, str);
            }
        }