问题描述
我想在WP7上制作一个圆圈。我试图这样做与椭圆类,我发现了很多解决方案,这使一个量表或饼图或某物,但我需要的只是精华。
任何人都可以帮助?
目的是只显示一个圆(或椭圆)的一部分。如同图片中的黄色区域:
这里有一个相当简单的解决问题的办法,虽然它不使用
Ellipse
,它需要一个三角学: < Path Fill =Black
Data =M0,0 L0,-100 A100,100 0 0 1 70.7,-70.7 z/>
Data
属性使用。
- 开始时的M告诉钢笔 M 移动到位置0,0。
- L L 从当前位置(0,0)到0,-100。
- A指示笔绘制椭圆 rc从当前位置到70.7,-70.7(100,100部分确定椭圆的水平和垂直半径,0 0 1部分用于
RotationAngle
,IsLargeArc
和SweepDirection
(顺时针为1,逆时针为0) >
- z指示笔关闭或完成形状(这将导致一条线从70.7,-70.7回到0,0)。
70.7来自哪里?那么,这个特定的弧从具有半径100的圆扫出45度的角度,因此坐标70.7,-70.7由 100 * sin(45)
code> 100 * cos(45)。
I would like to make a sector of a circle on WP7. I tried to do this with the ellipse class and I found a lot of solution, which make a gauge or pie chart or something, but I need just the essence.Could anyone help?
the aim is to show just one part of a circle (or ellipse). Like the yellow area in the picture:
Thanks,Laci
Here's a fairly simple solution to the problem, though it does not use an Ellipse
and it requires a little trigonometry:
<Path Fill="Black"
Data="M0,0 L0,-100 A100,100 0 0 1 70.7,-70.7 z" />
The Data
property uses Path Markup Syntax.
- The "M" at the beginning tells the pen to Move to the location 0,0.
- The "L" tells the pen to draw a Line from the current location (0, 0) to 0,-100.
- The "A" tells the pen to draw an elliptical Arc from the current location to 70.7,-70.7 (the "100,100" portion determines the horizontal and vertical radius of the ellipse and the "0 0 1" portion is for
RotationAngle
,IsLargeArc
, andSweepDirection
(1 for clockwise, 0 for counter-clockwise)). - The "z" tells the pen to close or complete the shape (which will cause a line to be drawn from 70.7,-70.7 back to 0,0).
Where did the 70.7 come from? Well, this particular arc sweeps out an angle of 45 degrees from a circle with radius 100, so the coordinates 70.7,-70.7 are determined by 100 * sin(45)
and 100 * cos(45)
.
这篇关于如何绘制椭圆类的圆扇区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!