示例#1
0
        public void DrawShapes()
        {
            var doc = new PlotlyDocumentBuilder();

            using (var dc = doc.CreateShapes2DContext())
            {
                dc.DrawCircle((2, 2), 7, System.Drawing.Color.Red);
            }

            AttachmentInfo.From("Drawing.html").WriteAllText(doc.ToHtml());
        }
示例#2
0
        public void DrawVolumes()
        {
            var scene = new Record3D();

            scene.DrawPivot(System.Numerics.Matrix4x4.Identity, 2);
            scene.DrawCube(System.Numerics.Matrix4x4.CreateTranslation(5, 0, 0), Color.Red, Color.Green, Color.Blue);
            scene.DrawCube(System.Numerics.Matrix4x4.CreateTranslation(7, 0, 0), (Color.Black, 0.1f));

            var doc = new PlotlyDocumentBuilder().Draw(scene);

            AttachmentInfo.From("Drawing.html").WriteAllText(doc.ToHtml());
        }
示例#3
0
        public void DrawLines()
        {
            var doc = new PlotlyDocumentBuilder();

            using (var dc = doc.CreateTraces2DContext())
            {
                dc.DrawLines(15, (System.Drawing.Color.Red, System.Drawing.Color.Blue, 13), (1, 1), (2, 2), (3, 8), (4, 7));

                dc.DrawCircle((5, 4), 10, System.Drawing.Color.Red);
                dc.DrawCircle((7, 4), 50, System.Drawing.Color.Blue);
                dc.DrawCircle((8, 5), 20, System.Drawing.Color.Green);
                dc.DrawCircle((9, 6), 30, System.Drawing.Color.Black);

                dc.DrawPolygon((System.Drawing.Color.Red, System.Drawing.Color.Blue, 13), (1.1f, 1), (2, 1), (1.5f, 3), (1.1f, 2));

                dc.DrawPolygon(System.Drawing.Color.Yellow, (1.1f, 10), (2, 10), (1.5f, 30), (1.1f, 20));
            }

            AttachmentInfo.From("Drawing.html").WriteAllText(doc.ToHtml());
        }
示例#4
0
        public static string AttachToCurrentTest(this Record3D batch, string filePath)
        {
            var ainfo = NUnit.Framework.AttachmentInfo.From(filePath);

            if (filePath.ToLower().EndsWith(".stl"))
            {
                throw new NotImplementedException();

                /*
                 * var mb = new Backends.STLMeshBuilder();
                 * batch.DrawTo(mb);
                 * var wfcontent = mb.ToAsciiSTL();
                 * System.IO.File.WriteAllText(filePath, wfcontent);
                 * NUnit.Framework.TestContext.AddTestAttachment(filePath);
                 * return;
                 */
            }

            if (filePath.ToLower().EndsWith(".html"))
            {
                var html = PlotlyDocumentBuilder.ConvertToHtml(batch);
                ainfo.WriteAllText(html);
            }

            if (filePath.ToLower().EndsWith(".InteropDrawing"))
            {
            }

            if (filePath.ToLower().EndsWith(".gltf") || filePath.ToLower().EndsWith(".glb") || filePath.ToLower().EndsWith(".obj"))
            {
                var model = GltfSceneBuilder
                            .Convert(batch)
                            .ToGltf2();

                ainfo.WriteObject(f => model.Save(f));
            }

            return(filePath);
        }