Example #1
0
        static void Test6_Plotter()
        {
            var harmonicity = HarmonicityUtils.CreateHarmonicity(null); // default

            var viewport = new Torec.Drawing.Viewport(1200, 600, 0, 1200, 1, -1);
            var image    = new Torec.Drawing.Image(viewport);

            var r0      = new Rational(1);
            var r1      = new Rational(2);
            var handler = new HandlerPipe <RationalInfo>(
                new RangeRationalHandler(r0, r1, false, true),
                new Samples.RationalPrinter(),
                new RationalPlotter(image, harmonicity)
                );

            Debug.WriteLine("Iterate {0} range {1}-{2}", harmonicity.GetType().Name, r0, r1);

            var limits = new RationalGenerator.Limits {
                dimensionCount = 7, rationalCount = 50, distance = -1
            };

            new RationalIterator(harmonicity, limits, null, handler).Iterate();

            image.Show(svg: true);
            //image.Show(svg: false);
        }
Example #2
0
        internal static void DrawGrid()
        {
            string harmonicityName = "Euler Barlow Tenney Narrow".Split()[0];

            Rational[] subgroup = Rational.ParseRationals("2.3.5");

            /*
             * var harmonicity = HarmonicityUtils.CreateHarmonicity(harmonicityName);
             * foreach (string s in "5/6 4/3".Split()) {
             *  Rational r = Rational.Parse(s);
             *  Debug.WriteLine("{0} d:{1} h:{2}",
             *      r, harmonicity.GetDistance(r), harmonicity.GetHarmonicity(r)
             *  );
             * }
             */

            var viewport = new Torec.Drawing.Viewport(1600, 1200, -1, 1, -3, 3);
            var image    = new Torec.Drawing.Image(viewport);

            var drawer = new Rationals.Drawing.GridDrawer();

            // configure drawer
            drawer.SetBounds(viewport.GetUserBounds());
            // below like UpdateDrawerFully()
            drawer.SetSubgroup(0, subgroup, null);
            drawer.SetGeneration(harmonicityName, 200);
            drawer.SetSlope(new Rational(3, 2), 2.0f);
            //
            drawer.SetEDGrids(Rationals.Drawing.GridDrawer.EDGrid.Parse("12edo"));
            drawer.SetPointRadius(1.0f);

            // generate grid items
            drawer.UpdateItems();

            // make image elements from grid items
            drawer.DrawGrid(image);

            // render/show svg
            image.Show(svg: true);
        }