我需要一种算法来渲染柔和的画笔笔触

时间:2022-11-21 10:32:00

I have an array of mouse points, a stroke width, and a softness. I can draw soft circles and soft lines. Which algorithm should I use for drawing my array of points? I want crossed lines to look nice as well as end points.

我有一系列鼠标点,笔触宽度和柔软度。我可以画出柔和的圆圈和柔和的线条。我应该使用哪种算法来绘制点数组?我希望交叉线看起来不错,还有终点。

4 个解决方案

#1


3  

I would definitely choose the Bezier for that purpose, and in particular I will implement the piecewise cubic Bezier - it is truly easy to implement and grasp and it is widely used by 3D Studio max and Photoshop.

我肯定会选择Bezier用于此目的,特别是我将实现分段立方Bezier - 它非常容易实现和掌握,并且它被3D Studio max和Photoshop广泛使用。

Here is a good source for it: http://local.wasp.uwa.edu.au/~pbourke/surfaces_curves/bezier/cubicbezier.html

这是一个很好的来源:http://local.wasp.uwa.edu.au/~pbourke/surfaces_curves/bezier/cubicbezier.html

Assuming that you have an order between the points, in order to set the four control points you should go as follows:

假设您在点之间有订单,为了设置四个控制点,您应该按如下方式进行:

I define the tangent between point P[i] and point P[i+1]

我定义点P [i]和点P [i + 1]之间的切线

  • T1 = (P[i+1] - P[i-1])
  • T1 =(P [i + 1] - P [i-1])

  • T2 = (P[i+2] - P[i])
  • T2 =(P [i + 2] - P [i])

And to create the piecewise between two points I do the following:

为了在两点之间创建分段,我执行以下操作:

  • Control Point Q1: P[i]
  • 控制点Q1:P [i]

  • Control Point Q2: the point lying along the tangent from Q1 => Q1 + 0.3T1
  • 控制点Q2:从Q1 => Q1 + 0.3T1沿切线的点

  • Control Point Q3: the point lying along the tangent to Q4 => Q4 - 0.3T2
  • 控制点Q3:沿着Q4 => Q4 - 0.3T2的切线的点

  • Control Point Q4: P[i+1]
  • 控制点Q4:P [i + 1]

The reason I chose 0.3T is arbitrary in order to give it enough 'strength' but not too much, you can use more elaborated methods that will take care of acceleration (C2 continuity) as well.

我选择0.3T的原因是任意的,为了给它足够的“力量”而不是太多,你可以使用更精细的方法来处理加速(C2连续性)。

Enjoy

#2


2  

Starting from Gooch & Gooch's Non-Photorealistic Rendering, you might find Pham's work useful - see PDF explaining algorithm.

从Gooch&Gooch的非真实感渲染开始,您可能会发现Pham的工作很有用 - 请参阅PDF解释算法。

There's a nice overview article by Tateosian which explains the additional techniques in less detail with pretty pictures.Bezier curve drawing alone doesn't produce the effects you want (depending on how fancy you want to get). However, I'd certainly start with Paul's work and see if just using that to draw with your soft brush is good enough.

Tateosian有一篇很好的概述文章,用漂亮的图片解释了更多细节的附加技术。单独的贝塞尔曲线绘制不会产生你想要的效果(取决于你想要的花哨程度)。但是,我肯定从保罗的工作开始,看看是否只是用它来用你的软刷画画就足够了。

Be warned there are lots of patents in this space, sigh.

请注意,在这个领域有很多专利,感叹。

#3


1  

I think maybe you're looking for a spline algorithm.

我想也许你正在寻找样条算法。

Here is a spline tutorial, which you might find helpfull:

这是一个样条教程,您可能会发现它有用:

[http://www.doc.ic.ac.uk/~dfg/AndysSplineTutorial/index.html]

The subject is also covered in most books on graphics programming.

大多数关于图形编程的书籍都涉及这个主题。

Cheers.

#4


1  

I figured it out - use a very soft gradient circle, draw repeatedly to make a stroke, blend using multiply.

我想通了 - 使用一个非常柔和的渐变圆,重复绘制以制作笔划,使用乘法混合。

#1


3  

I would definitely choose the Bezier for that purpose, and in particular I will implement the piecewise cubic Bezier - it is truly easy to implement and grasp and it is widely used by 3D Studio max and Photoshop.

我肯定会选择Bezier用于此目的,特别是我将实现分段立方Bezier - 它非常容易实现和掌握,并且它被3D Studio max和Photoshop广泛使用。

Here is a good source for it: http://local.wasp.uwa.edu.au/~pbourke/surfaces_curves/bezier/cubicbezier.html

这是一个很好的来源:http://local.wasp.uwa.edu.au/~pbourke/surfaces_curves/bezier/cubicbezier.html

Assuming that you have an order between the points, in order to set the four control points you should go as follows:

假设您在点之间有订单,为了设置四个控制点,您应该按如下方式进行:

I define the tangent between point P[i] and point P[i+1]

我定义点P [i]和点P [i + 1]之间的切线

  • T1 = (P[i+1] - P[i-1])
  • T1 =(P [i + 1] - P [i-1])

  • T2 = (P[i+2] - P[i])
  • T2 =(P [i + 2] - P [i])

And to create the piecewise between two points I do the following:

为了在两点之间创建分段,我执行以下操作:

  • Control Point Q1: P[i]
  • 控制点Q1:P [i]

  • Control Point Q2: the point lying along the tangent from Q1 => Q1 + 0.3T1
  • 控制点Q2:从Q1 => Q1 + 0.3T1沿切线的点

  • Control Point Q3: the point lying along the tangent to Q4 => Q4 - 0.3T2
  • 控制点Q3:沿着Q4 => Q4 - 0.3T2的切线的点

  • Control Point Q4: P[i+1]
  • 控制点Q4:P [i + 1]

The reason I chose 0.3T is arbitrary in order to give it enough 'strength' but not too much, you can use more elaborated methods that will take care of acceleration (C2 continuity) as well.

我选择0.3T的原因是任意的,为了给它足够的“力量”而不是太多,你可以使用更精细的方法来处理加速(C2连续性)。

Enjoy

#2


2  

Starting from Gooch & Gooch's Non-Photorealistic Rendering, you might find Pham's work useful - see PDF explaining algorithm.

从Gooch&Gooch的非真实感渲染开始,您可能会发现Pham的工作很有用 - 请参阅PDF解释算法。

There's a nice overview article by Tateosian which explains the additional techniques in less detail with pretty pictures.Bezier curve drawing alone doesn't produce the effects you want (depending on how fancy you want to get). However, I'd certainly start with Paul's work and see if just using that to draw with your soft brush is good enough.

Tateosian有一篇很好的概述文章,用漂亮的图片解释了更多细节的附加技术。单独的贝塞尔曲线绘制不会产生你想要的效果(取决于你想要的花哨程度)。但是,我肯定从保罗的工作开始,看看是否只是用它来用你的软刷画画就足够了。

Be warned there are lots of patents in this space, sigh.

请注意,在这个领域有很多专利,感叹。

#3


1  

I think maybe you're looking for a spline algorithm.

我想也许你正在寻找样条算法。

Here is a spline tutorial, which you might find helpfull:

这是一个样条教程,您可能会发现它有用:

[http://www.doc.ic.ac.uk/~dfg/AndysSplineTutorial/index.html]

The subject is also covered in most books on graphics programming.

大多数关于图形编程的书籍都涉及这个主题。

Cheers.

#4


1  

I figured it out - use a very soft gradient circle, draw repeatedly to make a stroke, blend using multiply.

我想通了 - 使用一个非常柔和的渐变圆,重复绘制以制作笔划,使用乘法混合。