How to draw a circle divided to thirds in XAML?

前端 未结 2 498
抹茶落季
抹茶落季 2021-02-09 20:22

In my WPF application, I\'d like to draw a circle divided into three equal arcs, like the peace symbol, or a pie chart.

In other words, I\'d like to draw this: http://i.

2条回答
  •  故里飘歌
    2021-02-09 20:59

    There are severals ways in which this can be done, the easiest is probably this:

    
        
            
                
                    
                        
                            
                        
                        
                            
                            
                                
                                    
                                        
                                    
                                
                            
                            
                                
                                    
                                        
                                    
                                
                            
                            
                                
                                    
                                        
                                    
                                
                            
                            
    
                            
                        
                    
                
            
        
    
    

    enter image description here

    The above geometry can be compressed to the following using the geometry mini-language:

    
        
        
        
        
    
    

    This just creates a circle and three lines from the center to the edges, you will need to calculate the points via polar to cartesian conversion.

    Another method would be using ArcSegments, which is a major pain.

    Edit: The dreaded ArcSegment version:

    
        
            
                
                    
    
                        
                            
                                
                            
                            
                                
                                    
                                        
                                            
                                            
                                            
                                        
                                    
                                
                            
                        
    
                        
                            
                                
                            
                            
                                
                                    
                                        
                                            
                                            
                                            
                                        
                                    
                                
                            
                        
    
                        
                            
                                
                            
                            
                                
                                    
                                        
                                            
                                            
                                            
                                        
                                    
                                
                            
                        
    
                    
                
            
        
    
    

    enter image description here

    Compressed geometry:

    
    
    
    

    Keypoint here is that the ArcSegment.Size defines the radii of the resulting ellipse, which hence should be "100,100" since that is the radius of the actual circle.

提交回复
热议问题