在GDI+中绘制带渐变的折线;
我有一个包含多个点的 List
。如何将这些点绘制到位图中,以获得与此相同的效果:
http:// /img291.imageshack.us/img291/4462/outputtz.png
点是已知的,我只需要以某种方式实现这种渐变效果。
请注意,渐变不是径向的,如果将折线解开为直线,您将获得从一端到另一端的简单线性渐变。我只需要沿着线的“断点”扭转这个线性渐变。
我当前的解决方案是单独绘制每条线,同时计算正确的开始颜色和结束颜色< /em> 每条线,因此我可以使用 LinearGradientBrush
,然后使用 DrawLine
。
1) 除了自己计算颜色之外,还有其他解决方案吗?
2) 如何绘制带有圆端的线(如图所示)?我的解决方案是绘制普通线,两端各有一个椭圆,但这些椭圆不会有渐变,所以如果线很短,就没有渐变。
I have a List<Point>
of multiple points. How can I draw these points into a bitmap, to get the same as this:
http://img291.imageshack.us/img291/4462/outputtz.png
Points are known, I just need to achieve this gradient effect somehow.
Please note that the gradient isn't radial, if you untwist the polygonal line to a straight one, you would get simple linear gradient from one end to another. I just need this linear gradient twisted along the line's "breaking points".
My current solution is drawing each line separately, while calculating the proper start-color and end-color for each line, so I can use LinearGradientBrush
and then DrawLine
.
1) Is there any other solution, than calculating the colors myself?
2) How to draw a line with round ends (as on image)? My solution is by drawing ordinary line, with ellipse on each end, but those ellipses won't have gradient, so if the line is VERY short, there is no gradient.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于圆角末端,您可以为您的笔设置此属性,
以便您可以在图像上更改画布笔。
About the rounded ends you can set this property for you Pen
so on your image you can change the canvas pen.