简体   繁体   English

如何在具有压力敏感度的绘画程序中进行绘图?

[英]How would I go about drawing in a paint program with pressure sensitivity?

I am writing a paint program of sorts, using C# .Net/WinForms and pressure sensitivity is a must. 我正在使用C#.Net / WinForms编写各种绘画程序,并且必须具有压力敏感性。 I have everything set up and am getting pressure information from the tablet pen. 我已完成所有设置,并从数位板笔获取压力信息。 None of this is an issue. 这都不是问题。

What I am having trouble approaching is, how would I take your typical, simple paint program (ie, 'Scribble') and draw using the pressure data I am getting? 我遇到的麻烦是,如何使用典型的,简单的绘画程序(即“涂抹”)并使用获得的压力数据进行绘制? Scribble-type simple apps track current and previous cursor positions, while drawing is enabled, and draws lines between them. 涂鸦类型的简单应用在启用绘图后会跟踪当前和以前的光标位置,并在它们之间绘制线条。 But each point laid down by capturing cursor positions is drawn between using a fixed width line. 但是,通过捕获光标位置而放置的每个点都是使用固定宽度线绘制的。

Assuming I have all the data I need: xy positions and pen pressure, how would I begin to think about drawing between points that should be different widths? 假设我拥有所有需要的数据:xy位置和笔压力,我将如何开始考虑在宽度不同的点之间进行绘制?

我会将您的总xy位置分解为许多较小的xy位置(可能是一个像素或两个),并相应于笔压力应用宽度。

The easiest way to do it is to keep track of the previous point and the previous size (based on pressure) and then draw a lineto from the previous point to the current point, using the previous size for the line size. 最简单的方法是跟踪先前的点和先前的尺寸(基于压力),然后使用先前的尺寸作为线尺寸从先前的点到当前点绘制一条线。

Even using GDI+ is fast this way, if you make sure not to create new objects in the event handler code. 如果您确保不在事件处理程序代码中创建新的对象,那么即使使用GDI +也是这样的快速方法。

The other way I mentioned is much more advanced (though may yield better results) and I may end up implementing it at a later date, when I do everything vector-based. 我提到的另一种方法要先进得多(尽管可能会产生更好的结果),当我做所有基于矢量的事情时,我可能最终会在以后实现它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM