开发者

How to draw an arc from radius and inner angle in Silverlight

In a silverlight 3 project I have to draw an arc programatically and I have radius of circle and inner angle of the arc. Could you please direct me to some related开发者_如何转开发 articles.

Thanks in anticipation!

Haris


This seems to be a good article on building arcs dynamically http://codingbandit.com/Blog/blog/dynamically-creating-path-data-in-silverlight-2/

To calculate the points the following formula is used.

x = a + r * cos(θ)
y = b + r * sin(θ)

* r is the radius of the circle
* (a,b) is the center of the circle
* (x,y) is the point on the circumference
* θ is the angle in degrees
* radian = degree * π/180

you have the radius of the circle r and also the angle θ. That should build up the point series.


You're going to want to look at Paths in silverlight and specifically at the ArcSegments section.

ArcSegment Documentation

MSDN Path Geometry Samples


With Expression Blend 4. You could use Arc.

Example:

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
    x:Class="SilverlightApplication1.MainPage"
    Width="640" Height="480">

    <Grid x:Name="LayoutRoot" Background="White">
        <Canvas Margin="101,88,118,125">
            <ed:Arc ArcThickness="0" ArcThicknessUnit="Pixel" EndAngle="90" Fill="#FFF4F4F5" Height="60" Canvas.Left="101" Stretch="None" Stroke="Black" StartAngle="0" Canvas.Top="63" UseLayoutRounding="False" Width="57"/>
        </Canvas>
    </Grid>
</UserControl>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜