예제 #1
0
        void vkvgDraw()
        {
            using (vkvg.Context ctx = new vkvg.Context(vkvgSurf)) {
                ctx.Operator = vkvg.Operator.Clear;
                ctx.Paint();
                ctx.Operator = vkvg.Operator.Over;

                ctx.LineWidth = 1;
                ctx.SetSource(0.1, 0.1, 0.1, 0.3);
                ctx.Rectangle(5.5, 5.5, 400, 250);
                ctx.FillPreserve();
                ctx.Flush();
                ctx.SetSource(0.8, 0.8, 0.8);
                ctx.Stroke();

                ctx.FontFace = "mono";
                ctx.FontSize = 10;
                int x = 16;
                int y = 40, dy = 16;
                ctx.MoveTo(x, y);
                ctx.ShowText(string.Format($"fps:     {fps,5} "));
                ctx.MoveTo(x + 200, y - 0.5);
                ctx.Rectangle(x + 200, y - 8.5, 0.1 * fps, 10);
                ctx.SetSource(0.1, 0.9, 0.1);
                ctx.Fill();
                ctx.SetSource(0.8, 0.8, 0.8);
                y += dy;
                ctx.MoveTo(x, y);
                ctx.ShowText(string.Format($"Exposure:{matrices.exposure,5} "));
                y += dy;
                ctx.MoveTo(x, y);
                ctx.ShowText(string.Format($"Gamma:   {matrices.gamma,5} "));
                if (results == null)
                {
                    return;
                }

                y += dy * 2;
                ctx.MoveTo(x, y);
                ctx.ShowText("Pipeline Statistics");
                ctx.MoveTo(x - 2, 2.5 + y);
                ctx.LineTo(x + 160, 2.5 + y);
                ctx.Stroke();
                y += 4;
                x += 20;

                for (int i = 0; i < statPool.RequestedStats.Length; i++)
                {
                    y += dy;
                    ctx.MoveTo(x, y);
                    ctx.ShowText(string.Format($"{statPool.RequestedStats[i].ToString(),-30} :{results[i],12:0,0} "));
                }

                y += dy;
                ctx.MoveTo(x, y);
                ctx.ShowText(string.Format($"{"Elapsed microsecond",-20} :{timestampQPool.ElapsedMiliseconds:0.0000} "));
            }
        }
예제 #2
0
        void drawingThread()
        {
            int threadId = activeThreads;

            activeThreads++;
            //Console.WriteLine ($"Drawing thread strart {Thread.CurrentThread.ManagedThreadId}");
            lock (vkvgSurf) {
                using (vkvg.Context ctx = new vkvg.Context(vkvgSurf)) {
                    //Console.WriteLine ($"{threadId}:draw");

                    for (int i = 0; i < iterations; i++)
                    {
                        float x1 = (float)(rnd.NextDouble() * Width);
                        float y1 = (float)(rnd.NextDouble() * Height);
                        float x2 = (float)(rnd.NextDouble() * Width) + 1.0f;
                        float y2 = (float)(rnd.NextDouble() * Height) + 1.0f;
                        randomize_color(ctx);
                        ctx.MoveTo(x1, y1);
                        ctx.LineTo(x2, y2);
                        ctx.Stroke();
                    }
                }
            }

            //Console.WriteLine ($"Drawing thread end {Thread.CurrentThread.ManagedThreadId}");
            activeThreads--;

            //Console.WriteLine ($"{threadId}:signal");
            countdown.Signal();
        }
예제 #3
0
파일: curve.cs 프로젝트: jpbruyere/vkvg.net
        public override void Update()
        {
            using (vkvg.Context ctx = new vkvg.Context(vkvgSurf))
            {
                ctx.SetSource(1, 1, 1);
                ctx.Paint();


                ctx.LineWidth = 6;
                ctx.SetSource(0.1, 0.1, 0.1, 0.8);

                ctx.MoveTo(points [0]);
                ctx.CurveTo(points [1].X, points [1].Y, points [2].X, points [2].Y, points [3].X, points [3].Y);
                ctx.Stroke();

                ctx.LineWidth = 1;
                ctx.SetSource(0.2, 0.2, 0.2, 1);

                ctx.MoveTo(points[0]);
                ctx.LineTo(points[1]);
                ctx.MoveTo(points[2]);
                ctx.LineTo(points[3]);
                ctx.Stroke();

                ctx.SetSource(0.5, 0.5, 1, 0.9);
                for (int i = 0; i < points.Length; i++)
                {
                    if (i == curPoint)
                    {
                        continue;
                    }
                    ctx.Arc(points[i].X, points [i].Y, cpRadius, 0, Math.PI * 2.0);
                }
                ctx.FillPreserve();
                ctx.Stroke();

                if (curPoint < 0)
                {
                    return;
                }

                ctx.SetSource(1, 0.4, 0.4, 0.9);
                ctx.Arc(points [curPoint].X, points [curPoint].Y, selRadius, 0, Math.PI * 2.0);
                ctx.FillPreserve();
                ctx.Stroke();
            }
        }
예제 #4
0
파일: main.cs 프로젝트: Svengali/vk.net
        //void vkvgDrawSVG () {
        //	using (vkvg.Surface svgSurf = new vkvg.Surface (vkvgDev, 300, 300)) {
        //		using (vkvg.Context ctx = new vkvg.Context (svgSurf)) {
        //			IntPtr nsvg = IntPtr.Zero;

        //			using (Stream nsvgStream = Crow.Interface.StaticGetStreamFromPath ("../../../samples/data/tiger.svg")) {
        //				using (StreamReader sr = new StreamReader (nsvgStream)) {
        //					nsvg = vkvgDev.LoadSvgFragment (sr.ReadToEnd ());
        //				}
        //			}


        //			ctx.SetSource (0.8f, 0.8f, 0.8f);
        //			ctx.Paint ();

        //			ctx.Scale (0.2f, 0.2f);
        //			ctx.RenderSvg (nsvg, null);

        //			vkvgDev.DestroySvg (nsvg);
        //		}

        //		//svgSurf.WriteToPng ("/mnt/data/test.png");

        //		using (vkvg.Context ctx = new vkvg.Context (vkvgSurf)) {
        //			ctx.SetSourceSurface (svgSurf, 0, 0);
        //			ctx.Paint ();
        //		}
        //	}
        //}
        #region fps print
        void vkvgDraw1()
        {
            using (vkvg.Context ctx = new vkvg.Context(vkvgSurf)) {
                //ctx.SetSource (1.0, 0.1, 0.1, 0.2);
                //ctx.Paint ();

                //ctx.Rectangle (50, 50, 200, 200);
                //ctx.Rectangle (50, 50, 250, 250);
                //clearAndClip (ctx);
                ////ctx.Rectangle (60, 60, 200, 200);
                ////clearAndClip (ctx);

                //ctx.LineWidth = 1;
                //ctx.SetSource (1.0, 0.1, 0.1, 0.2);
                //ctx.Rectangle (5.5, 5.5, 400, 250);
                //ctx.FillPreserve ();
                //ctx.Flush ();
                ctx.SetSource(0.8, 0.8, 0.8);
                //ctx.Stroke ();

                ctx.FontFace = "mono";
                ctx.FontSize = 8;
                int x = 10;
                int y = 10, dy = 14;
                for (int j = 0; j < 10; j++)
                {
                    for (int i = 0; i < 50; i++)
                    {
                        ctx.Save();
                        string           text = string.Format($"fps: {fps,5}");
                        vkvg.TextExtents te   = ctx.TextExtents(text);
                        vkvg.FontExtents fe   = ctx.FontExtents;

                        ctx.Rectangle(x, y, te.XAdvance + 1.0f, fe.Height);
                        clearAndClip(ctx);
                        ctx.SetSource(0.1, 0.2, 0.8);
                        ctx.Fill();
                        ctx.SetSource(0.8, 0.8, 0.8);
                        ctx.MoveTo(x, (float)y + fe.Ascent);
                        ctx.ShowText(text);
                        y += dy;
                        ctx.Restore();
                    }
                    ctx.Flush();
                    x += 100;
                    y  = 10;
                }
            }
        }
예제 #5
0
        static void DrawRoundedRectangle(vkvg.Context gr, double x, double y, double width, double height, double radius)
        {
            if ((radius > height / 2) || (radius > width / 2))
            {
                radius = Math.Min(height / 2, width / 2);
            }

            gr.MoveTo(x, y + radius);
            gr.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
            gr.LineTo(x + width - radius, y);
            gr.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0);
            gr.LineTo(x + width, y + height - radius);
            gr.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
            gr.LineTo(x + radius, y + height);
            gr.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
            gr.ClosePath();
        }
예제 #6
0
        public override void Update()
        {
            using (vkvg.Context ctx = new vkvg.Context(vkvgSurf))
            {
                ctx.Clear();

                for (int i = 0; i < iterations; i++)
                {
                    float x1 = (float)(rnd.NextDouble() * Width);
                    float y1 = (float)(rnd.NextDouble() * Height);
                    float x2 = (float)(rnd.NextDouble() * Width) + 1.0f;
                    float y2 = (float)(rnd.NextDouble() * Height) + 1.0f;
                    randomize_color(ctx);
                    ctx.MoveTo(x1, y1);
                    ctx.LineTo(x2, y2);
                    ctx.Stroke();
                }
            }
        }
예제 #7
0
        void recurseDraw(vkvg.Context ctx, int step)
        {
            step++;

            ctx.SetSource(1.0, 0.0, 0.0);
            ctx.FontFace = "droid";
            ctx.FontSize = 10;

            ctx.Save();

            ctx.Translate(20, 20);
            ctx.Rectangle(step, step, 600, 600);
            ctx.ClipPreserve();
            ctx.SetSource(1f / step, 1f / step, 1f / step);
            ctx.FillPreserve();
            ctx.SetSource(0, 0, 0);
            ctx.Stroke();

            if (step < 5)
            {
                recurseDraw(ctx, step);
            }

            ctx.Restore();

            ctx.Rectangle(step + 50, step + 1, 100, 12);
            ctx.Operator = vkvg.Operator.Clear;
            ctx.Fill();
            ctx.Operator = vkvg.Operator.Over;
            ctx.SetSource(1.0, 0.0, 0.0);
            ctx.MoveTo(step + 30, step + 12);
            ctx.ShowText($"fps: {fps}");


            ctx.Operator = vkvg.Operator.Clear;
            ctx.Rectangle(step, step, 20, 20);
            ctx.Fill();
            ctx.Operator = vkvg.Operator.Over;

            ctx.SetSource(1f / step, 0f, 0f);
            ctx.Rectangle(step + 2, step + 2, 16, 16);
            ctx.Fill();
        }
예제 #8
0
파일: texts.cs 프로젝트: jpbruyere/vkvg.net
        public override void Update()
        {
            using (vkvg.Context ctx = new vkvg.Context(vkvgSurf))
            {
                ctx.Clear();

                ctx.FontFace = "mono";

                for (int i = 0; i < iterations; i++)
                {
                    float x = 0.8f * (float)(rnd.NextDouble() * Width) + 10f;
                    float y = 0.9f * (float)(rnd.NextDouble() * Height) + 10f;
                    uint  s = (uint)(rnd.NextDouble() * 80) + 1;
                    randomize_color(ctx);
                    ctx.FontSize = s;
                    ctx.MoveTo(x, y);
                    ctx.ShowText("This is a test string!");
                }
            }
        }
예제 #9
0
        void vkvgDraw()
        {
            using (vkvg.Context ctx = new vkvg.Context(vkvgSurf)) {
                ctx.Operator = vkvg.Operator.Clear;
                ctx.Paint();
                ctx.Operator = vkvg.Operator.Over;

                ctx.LineWidth = 1;
                ctx.SetSource(0.1, 0.1, 0.1, 0.8);
                ctx.Rectangle(5.5, 5.5, 320, 300);
                ctx.FillPreserve();
                ctx.Flush();
                ctx.SetSource(0.8, 0.8, 0.8);
                ctx.Stroke();

                ctx.FontFace = "mono";
                ctx.FontSize = 8;
                int x = 16;
                int y = 40, dy = 16;
                ctx.MoveTo(x, y);
                ctx.ShowText(string.Format($"fps:     {fps,5} "));
                ctx.MoveTo(x + 200, y - 0.5);
                ctx.Rectangle(x + 200, y - 8.5, 0.1 * fps, 10);
                ctx.SetSource(0.1, 0.9, 0.1);
                ctx.Fill();
                ctx.SetSource(0.8, 0.8, 0.8);
                y += dy;
                ctx.MoveTo(x, y);
                ctx.ShowText(string.Format($"Exposure:{pbrPipeline.matrices.exposure,5} "));
                y += dy;
                ctx.MoveTo(x, y);
                ctx.ShowText(string.Format($"Gamma:   {pbrPipeline.matrices.gamma,5} "));
                y += dy;
                ctx.MoveTo(x, y);
                ctx.ShowText(string.Format($"Light pos:   {lightPos.ToString()} "));

#if PIPELINE_STATS
                if (results == null)
                {
                    return;
                }

                y += dy * 2;
                ctx.MoveTo(x, y);
                ctx.ShowText("Pipeline Statistics");
                ctx.MoveTo(x - 2, 4.5 + y);
                ctx.LineTo(x + 160, 4.5 + y);
                ctx.Stroke();
                y += 4;
                x += 20;

                for (int i = 0; i < statPool.RequestedStats.Length; i++)
                {
                    y += dy;
                    ctx.MoveTo(x, y);
                    ctx.ShowText(string.Format($"{statPool.RequestedStats[i].ToString(),-30} :{results[i],12:0,0} "));
                }

                /*y += dy;
                 * ctx.MoveTo (x, y);
                 * ctx.ShowText (string.Format ($"{"Elapsed microsecond",-20} :{timestampQPool.ElapsedMiliseconds:0.0000} "));*/
#endif
                y += dy;
                ctx.MoveTo(x, y);
                ctx.ShowText(string.Format($"{"Debug draw (numpad 0->6)",-30} : {currentDebugView.ToString ()} "));
                y += dy;
                ctx.MoveTo(x, y);
                ctx.ShowText(string.Format($"{"Debug Prefil Face: (f)",-30} : {pbrPipeline.envCube.debugFace.ToString ()} "));
                y += dy;
                ctx.MoveTo(x, y);
                ctx.ShowText(string.Format($"{"Debug Prefil Mip: (m)",-30} : {pbrPipeline.envCube.debugMip.ToString ()} "));
            }
        }