コード例 #1
0
        void DrawDual(Tessellation tessellation)
        {
            foreach (var poly in tessellation.Polygons)
            {
                Path path = new Path()
                {
                    Stroke          = new SolidColorBrush(Colors.Yellow),
                    StrokeThickness = 1.0,
                    Data            = new PathGeometry()
                };

                for (int e = 0; e < poly.edges.Count; ++e)
                {
                    if (poly.edges[e].Neighbors.Count == 2)
                    {
                        PathFigure figure = new PathFigure()
                        {
                            IsClosed = false, IsFilled = false
                        };
                        var geodesic = tessellation.GetGeodesicLine(new Edge(poly.edges[e].Neighbors[0], poly.edges[e].Neighbors[1]));
                        figure.StartPoint = geodesic.A;
                        figure.Segments.Add(HyperbolicLineSegment(geodesic));
                        (path.Data as PathGeometry).Figures.Add(figure);
                    }
                }
                this.MyCanvas.Children.Add(path);
            }
        }
コード例 #2
0
        private void Generar_Click(object sender, RoutedEventArgs e)
        {
            var radius = Math.Min(MyCanvas.ActualHeight, MyCanvas.ActualWidth) * 0.5;
            var center = new Point(MyCanvas.ActualWidth * 0.5, MyCanvas.ActualHeight * 0.5);
            var circle = new Circle(center, radius);

            tessellation = new Tessellation(circle);
            tessellation.Tessellate(int.Parse(P.Text), int.Parse(Q.Text), int.Parse(Level.Text));
            Draw(tessellation, EvenBrush, OddBrush);
        }
コード例 #3
0
        void Draw(Tessellation tessellation, Brush evenBrush, Brush oddBrush)
        {
            this.MyCanvas.Children.Clear();
            this.MyCanvas.Children.Add(new Path
            {
                Stroke          = new SolidColorBrush(Colors.LightGray),
                StrokeThickness = 1.0,
                Data            = new EllipseGeometry(tessellation.Disk.Center, tessellation.Disk.Radius, tessellation.Disk.Radius),
            });

            foreach (var poly in tessellation.Polygons)
            {
                Path path = new Path()
                {
                    Stroke          = new SolidColorBrush(Colors.Yellow),
                    StrokeThickness = 1.0,
                };
                if (poly.level % 2 == 0)
                {
                    path.Fill = evenBrush;
                }
                else
                {
                    path.Fill = oddBrush;
                }

                PathFigure figure = new PathFigure()
                {
                    IsClosed = true, IsFilled = true
                };
                for (int e = 0; e < poly.edges.Count; ++e)
                {
                    var geodesic = tessellation.GetGeodesicLine(poly.edges[e]);
                    if (e == 0)
                    {
                        figure.StartPoint = geodesic.A;
                    }
                    figure.Segments.Add(HyperbolicLineSegment(geodesic));
                }
                path.Data = new PathGeometry(new PathFigure[] { figure });
                this.MyCanvas.Children.Add(path);
            }

            if (Dual.IsChecked.HasValue && (bool)Dual.IsChecked)
            {
                DrawDual(tessellation);
            }
        }