使用 .NET 创建手绘效果
我想编写一段代码,创建与 'Balsamiq Mockups' 或 'yUML' 使用 .NET 框架。
谁能告诉我如何使用GDI+实现手绘铅笔效果?
显然可以使用正确的字体来完成文本 - 我的问题是如何渲染线条、方框和圆圈。
谢谢!
I'd like to write a piece of code which creates images similar in style to those rendered by 'Balsamiq Mockups' or 'yUML' using the .NET framework.
Can anybody tell me how to achieve the hand-drawn pencil effect using GDI+?
The text can obviously be done using the right font - my question is how to render the lines, boxes and circles.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GDI+ 最适合绘制直角型图形,但您可以使用它来产生如下效果:
...通过使用 Graphics 对象的 DrawBezier 方法。下面是渲染上图的代码片段:
这种效果的关键是使用大宽度的 Pen(本例中为 7.0F),并将 Graphics 对象的 SmoothingMode 设置为 HighQuality(因为这看起来像默认的 ass)平滑模式)。
编写自定义方法相对容易,您可以在其中指定要以正常 GDI+ 方式绘制的形状(矩形、坐标和半径等),然后您的代码将这些元素的线条转换为贝塞尔坐标,您可以在其中稍微改变物体在每个方向上随机放置几个像素。
GDI+ is best suited for drawing right-angle-type graphics, but you can use it to produce an effect like this:
... by using the DrawBezier method of the Graphics object. Here's the code snippet that renders the above image:
The keys to this effect are using a Pen with a large width (7.0F in this example), and setting the SmoothingMode of your Graphics object to HighQuality (since this looks like ass with the default SmoothingMode).
It would be relatively easy to write custom methods where you specify shapes to be drawn in the normal GDI+ way (rectangles and coordinates and radii and so forth), and then your code translates the lines of these elements into Bezier coordinates where you slightly alter the positions of things randomly by a few pixels in each direction.