예제 #1
0
        private static IEnumerable <XElement> CreateHexagrams(double centerX, double centerY, double innerRadius, double outerRadius)
        {
            foreach (var hexagram in HexagramLL.HexagramsByInnerTrigram)
            {
                var inner1 = CircleMath.GetPoint(HexagramOffset - hexagram.Lines[0].StartDegree, innerRadius, centerX, centerY);
                var inner2 = CircleMath.GetPoint(HexagramOffset - hexagram.Lines[5].EndDegree, innerRadius, centerX, centerY);
                var outer1 = CircleMath.GetPoint(HexagramOffset - hexagram.Lines[0].StartDegree, outerRadius, centerX, centerY);
                var outer2 = CircleMath.GetPoint(HexagramOffset - hexagram.Lines[5].EndDegree, outerRadius, centerX, centerY);

                var points = new[]
                {
                    new SvgPoint(inner1.X, inner1.Y),
                    new SvgPoint(outer1.X, outer1.Y),
                    new SvgPoint(outer2.X, outer2.Y),
                    new SvgPoint(inner2.X, inner2.Y)
                };


                string color = null;
                switch (hexagram.InnerTrigram)
                {
                case Trigram.Force:     // Heaven
                    color = "#ffb3ff";
                    break;

                case Trigram.Field:     // Earth
                    color = "#80ff80";
                    break;

                case Trigram.Shake:     // Thunder
                    color = "#ffff64";
                    break;

                case Trigram.Gorge:     // Water
                    color = "#4d93ff";
                    break;

                case Trigram.Bound:     // Mountain
                    color = "#cccccc";
                    break;

                case Trigram.Ground:     // Wind
                    color = "#99ffff";
                    break;

                case Trigram.Radiance:     // Fire
                    color = "#ff6666";
                    break;

                case Trigram.Open:     // Swamp
                    color = "#00b3a0";
                    break;
                }

                color = Rgb
                        .Parse(color)
                        .WithSaturation(7 * (hexagram.CircleIndex() % 8))
                        .ToString();

                // var color = HexagramLL.FillColors[hexagram.Number];

                var polygon = SvgBuild
                              .Polygon(points, $"hexagram_{hexagram.Number}")
                              //.AddAttribute("class", "hexagram");
                              .AddAttribute("style", $"fill:{color}");

                yield return(polygon);
            }
        }