如何在c#图形中绘制一个玫瑰花结? [英] How to draw a rosette in c# graphics?

查看:82
本文介绍了如何在c#图形中绘制一个玫瑰花结?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待用c#图形做一个玫瑰花结......

这就是我想要实现的目标:

https://upload.wikimedia.org/wikipedia/commons/thumb/a/ a4 / Academ_rosette.svg / 630px-Academ_rosette.svg.png [ ^ ],当然不是圈外的行。

如果有人可以给我一些代码行并告诉我这是怎么做的,我会很感激的。 :)

解决方案

这看起来只有7个相同大小的圆圈,可以使用 System.Drawing.Graphics.DrawEllipse <绘制/ code>:

http://msdn.microsoft.com /en-us/library/a3fd63x2.aspx [ ^ ]。



您可能会看到圆形区域修剪线条时出现问题。其中一个实现方法是使用属性 System.Drawing.Graphics.Clip

http://msdn.microsoft.com/en-us/library/system.drawing.graphics.clip.aspx [ ^ ]。



你需要设置一个适当大小的椭圆形区域并位于中心的剪裁区域。为此,请从适当的 GraphicPath 中创建 Region 的实例:

http://msdn.microsoft.com/en-us/library/yhfywt1c.aspx [<一个href =http://msdn.microsoft.com/en-us/library/yhfywt1c.aspxtarget =_ blanktitle =New Window> ^ ],

http://msdn.microsoft.com/en-us/library/system。 drawing.drawing2d.graphicspath.aspx [ ^ ]。



获取的实例System.Drawing.Drawing2D.GraphicsPath 你需要,用它的构造函数创建一个并为它添加一个椭圆:

http://msdn.microsoft.com/en-us/library/tcy13d48.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/21sfy33s.aspx [ ^ ]。



-SA

I am looking forward to make a rosette using c# graphics...
Here is what I''m trying to achieve:
https://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Academ_rosette.svg/630px-Academ_rosette.svg.png[^], of course not the lines outside the circle.
If someone can give me some lines of code and show me how this is done, I''ll appreciate it. :)

解决方案

This looks nothing more than 7 circles of the same size, which can be drawn using System.Drawing.Graphics.DrawEllipse:
http://msdn.microsoft.com/en-us/library/a3fd63x2.aspx[^].

You might see some problem in clipping of the lines by the round area. One of the method to achieve that is using the property System.Drawing.Graphics.Clip:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.clip.aspx[^].

You need to set a clip region by some region of elliptic shape of appropriate size and positioned in the center. To do so, create an instance of Region out of appropriate GraphicPath:
http://msdn.microsoft.com/en-us/library/yhfywt1c.aspx[^],
http://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.graphicspath.aspx[^].

To obtain the instance of System.Drawing.Drawing2D.GraphicsPath you need, create one with its constructor and add an ellipse to it:
http://msdn.microsoft.com/en-us/library/tcy13d48.aspx[^],
http://msdn.microsoft.com/en-us/library/21sfy33s.aspx[^].

—SA


这篇关于如何在c#图形中绘制一个玫瑰花结?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆