Python-在GIMP中的路径上附加文本
作者:互联网
我已经几天(使用python-fu)发现了gimp API,实际上我很喜欢它.
但是,有些事情我无法解决:在路径上附加文字.
使用用户界面执行操作非常简单(在工具箱中创建路径>创建文本>单击路径上的文本)…但是,正如您可能期望的那样,当事情变得简单时,我并不喜欢.这就是为什么我尝试使用python做到这一点的原因.
这是我已经设法做的:
>创建一个图层
>在其上添加路径
>创建新文本
>显示整个东西
我现在所要做的就是学习如何使我的文字跟随路径.
帮助将不胜感激.
谢谢
解决方法:
经过数小时在互联网右侧的研究(没有裸露的人),我对我的问题没有发现太多.这就是为什么我决定查看Gimp源代码以了解神奇的“沿路径文字”实际上是如何工作的……而且似乎并没有采取任何措施使该动作可通过pdb使用.
之后,为了确定,我已经在gimp开发人员的邮件列表中询问,然后有人(我不知道是否允许在这里告诉他的名字)回答我:
The “text along
path” function is basically a hack, and was never intended to be a
final product. A proper text-along-path function would allow the path
to be changed and alter the text accordingly. The way that the warped
text is rendered is also less than ideal. Because the plan was always
that the functionality would change, no PDB hook was ever created for
it.
另一个告诉我如何创建自己的“沿路径文字”插件:
However, as far as I know, the Bezier strokes in a path have the following property, applying an affine transform to their control points and handles is equivalent to
applying the same transform to every point of the curve. So you can do something like this:
- determine a “reference path”, that is, a straight path along the text (or running though the middle of it)
- for each stroke iterate the control points, and on each point (“C”):
- determine projection on reference path (distance from origin of reference path) (elt’s call it “R”) and distance to it
- find the corresponding point on the target path (pdb.gimp_path_get_point_at_dist()), “R'”
- find the position of the new control point C’: same distance to target path, on perpendicular
- compute the position of the handles:
- compute dx/dy between H and C
- compute equivalent position H’ from the new control point C’
- apply rotation, centered on C’ with an angle that is the direction of the target path in R’ (as returned by earlier gimp_path_get_point_at_dist()) to produce new handle position (H”)
- repeat for 2nd handle
- add the triplet C’, H”1, H”2 to the new stroke
然后他鼓励我看两个做与矢量相似的插件,分别命名为ribbon-path和slinky,可用于http://gimp-path-tools.sourceforge.net/
我希望(由于这两个家伙)这篇帖子对您有所帮助.
标签:gimp,python,script-fu 来源: https://codeday.me/bug/20191102/1992781.html