gpt4 book ai didi

android - 如何在 android 中为绘画创建这种类型的画笔

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:30:50 25 4
gpt4 key购买 nike

可能重复How to make custom brush for canvas in android?

你好 friend ,

我太卡了,无法为绘画应用创建这种类型的画笔,但没有找到与此相关的任何内容。

我是绘画/ Canvas 的新手,所以对于我已经完成的基础知识我没有这方面的知识,但是对于像创建画笔这样的效果我没有任何关于如何创建/实现它的知识。有人有这方面的示例或代码吗?

我的应用程序需要这种类型的画笔,简单的一个例子需要理解:

enter image description here

谢谢。

最佳答案

我想没有简单的方法。我找到了 this discussion尤其是以下帖子很有趣:

Professional Computer Graphics is never easy. That's why there are so few people really tackling it. To make things worse, professional techniques are rarely published. I don't know how much effort you desire to make to get it, but I will give you some light. So, if you want, you can study, develop and get it the best way. If it seem too hard for you, let it here as a curiosity.

The professional way to make calligraphic brushes nowadays is like that:

The master curve is smooth because it's drawn based on spline(s). To get the more professional result, construct two splines: one using the points you got (for example, from mouse events) lying over the spline and another using the points like the spline control points. So the curve you draw is the curve generated from the interpolation of these two splines. This way, you have a "master curve" to draw.

You should also have a "master thickness" on which a variation must be applied. This thickness variation is calculated according to the result you want. The more common kind of calligraphic brush is just like in the image you linked: the curved regions usually are thinner than the straight ones. It's the more usual type because most designers get this kind of result when drawing with a tablet, so programs emulate this behavior. This effect in particular is usually calculated using a function based on the second derivate of the master spline. The thickness variation amplitude can be a configurable value.

The thin and sharp curve tips are made in a extra calculation. Sometimes it can be a good idea smoothing even the thickness variations with splines or some kind of "ceil function".

If you made everything right, you have a thick (and of course closed) curve in your hands. Draw it using the best filling algorithm you can develop. Use anti-aliasing if you are able to.

All these techniques can be calculated in real time while the user moves the mouse. The more points you get, the more calculations you make, but it works well because most calculations you already made are still valid. Usually you just need to reconstruct a small (last) part.

One last suggestion: never make 2D smoothing using function regression methods, unless your points really represent a function (so you need to keep the "math meaning" of the points as much as possible). I can not imagine a slower way to smooth points that have no special semantics. The only exception is when you have very very sparse points and the input order doesn't matter, but it's not the case when somebody is drawing with brushes.

关于android - 如何在 android 中为绘画创建这种类型的画笔,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8924734/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com