C#画笔Pen使用路径绘制图形的方法
程序员文章站
2023-11-21 15:46:04
本文实例讲述了c#画笔pen使用路径绘制图形的方法。分享给大家供大家参考。具体实现方法如下:
using system;
using system.collec...
本文实例讲述了c#画笔pen使用路径绘制图形的方法。分享给大家供大家参考。具体实现方法如下:
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.text; using system.windows.forms; using system.drawing.drawing2d; namespace windowsapplication2 { public partial class form10 : form { public form10() { initializecomponent(); } graphicspath get(rectangle rect, int radius) { int diameter = 2 * radius; rectangle arcrect = new rectangle(rect.location, new size(diameter, diameter)); graphicspath path = new graphicspath(); path.addarc(arcrect, 180, 90); arcrect.x=rect.right-diameter; path.addarc(arcrect, 270, 90); arcrect.y = rect.bottom - diameter; path.addarc(arcrect, 0, 90); arcrect.x = rect.left; path.addarc(arcrect, 90, 90); path.closefigure(); return path; } private void button1_click(object sender, eventargs e) { graphics g = this.creategraphics(); int width = this.clientrectangle.width; int height = this.clientrectangle.height; rectangle rect = new rectangle(10, 10, width - 20, height - 20); graphicspath path = get(rect, width / 10); g.fillpath(brushes.red, path); g.drawpath(pens.yellow, path); } } }
希望本文所述对大家的c#程序设计有所帮助。