Android path smooth graffiti effect example

preface

In a recent project, I made a graffiti effect. When my fingers move quickly, there will be broken lines. This article records the stroke optimization. I won't say much now. Let's take a look at the detailed introduction.

Before optimization

optimization

Designed class: paint, path

The path class records the coordinate point collection, determines the line track, and paint determines how to draw

Paint processing

Path processing

There is a concept called Bessel curve used here. Bessel curve formula is a smooth curve drawn according to the coordinates of several arbitrary points. When adding point coordinates to path, use path#quadto (float, float, float) instead of path#lineto (float, float).

Lineto (float, float) adds a new line from the previous point to a specified point

Quadto (float, float) adds a quadratic Bezier curve from the previous point to a specified point

When it is used in the project, it is slightly optimized. The code is as follows:

effect

Is the line at the corner much smoother? Careful children's shoes may find that the whole line feels uneven. This is caused by jitter. We'll talk about this later.

summary

The above is the whole content of this article. I hope the content of this article has a certain reference value for your study or work. If you have any questions, you can leave a message. Thank you for your support for programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>