简体   繁体   中英

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. 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位置(可能是一个像素或两个),并相应于笔压力应用宽度。

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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