C# 在Windows Phone 7上创建具有软边的图形
我正在尝试在我的WindowsPhone7应用程序中绘制图表。我面临的问题是,图有尖锐的边,但我需要有一个带软边的图 我使用以下代码使边缘变软:C# 在Windows Phone 7上创建具有软边的图形,c#,.net,silverlight,windows-phone-7,graph,C#,.net,Silverlight,Windows Phone 7,Graph,我正在尝试在我的WindowsPhone7应用程序中绘制图表。我面临的问题是,图有尖锐的边,但我需要有一个带软边的图 我使用以下代码使边缘变软: Polyline chartPolyline = new Polyline(); chartPolyline.Points = graphPointsCollection; // graphPointsCollection is collection of points chartPolyline.Stroke = borderBrush; chart
Polyline chartPolyline = new Polyline();
chartPolyline.Points = graphPointsCollection; // graphPointsCollection is collection of points
chartPolyline.Stroke = borderBrush;
chartPolyline.StrokeThickness = 3;
chartPolyline.StrokeLineJoin = PenLineJoin.Round;
chartPolyline.StrokeDashCap = PenLineCap.Round;
chartPolyline.StrokeStartLineCap = PenLineCap.Round;
chartPolyline.StrokeEndLineCap = PenLineCap.Round;
但产出仍有明显优势。哪里出错了?对于平滑曲线,您可以使用,例如贝塞尔曲线:
string PathFormatter = "<PathGeometry xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"> "
+ "<PathGeometry.Figures>"
+ "<PathFigure StartPoint=\"{0},{1}\">"
+ "<PathFigure.Segments>"
+ "<PathSegmentCollection>"
+ "<BezierSegment Point1=\"{2},{3}\" Point2=\"{4},{5}\" Point3=\"{6},{7}\" />"
+ "</PathSegmentCollection>"
+ "</PathFigure.Segments>"
+ "</PathFigure>"
+ "</PathGeometry.Figures>"
+ "</PathGeometry>";
double p1x = x1 * 0.67 + x2 * 0.33;
double p1y = y1;
double p2x = x1 * 0.33 + x2 * 0.67;
double p2y = y2;
string data = String.Format(PathFormatter, x1, y1, p1x, p1y, p2x, p2y, x2, y2);
Graphic.Children.Add(new Path()
{
Data = (PathGeometry)XamlReader.Load(data),
Stroke = new SolidColorBrush(color),
StrokeThickness = 4,
VerticalAlignment = System.Windows.VerticalAlignment.Bottom,
Height = 368,
CacheMode = new BitmapCache(),
//Margin = new Thickness(0, 0, 0, 0),
HorizontalAlignment = System.Windows.HorizontalAlignment.Left
});
string路径格式化程序=“”
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ "";
双p1x=x1*0.67+x2*0.33;
双p1y=y1;
双p2x=x1*0.33+x2*0.67;
双p2y=y2;
字符串数据=string.Format(路径格式化程序,x1,y1,p1x,p1y,p2x,p2y,x2,y2);
Graphic.Children.Add(新路径()
{
Data=(PathGeometry)XamlReader.Load(数据),
笔划=新的SolidColorBrush(颜色),
冲程厚度=4,
垂直对齐=System.Windows.VerticalAlignment.Bottom,
高度=368,
CacheMode=新的位图缓存(),
//余量=新厚度(0,0,0,0),
HorizontalAlignment=System.Windows.HorizontalAlignment.Left
});
有任何响应吗?。。。我真的被卡住了。你的代码有一个输出图像(但厚度为9):。我看到柔软的边缘。你想实现什么?感谢Ku6opr试用代码,我的问题是角度,所有角度都是“角度”:)我想在直线弯曲的地方有曲线。我的意思是稍微弯曲一下就可以了。。