我正在尝试开发一个可以在打开的SVG文件上运行的脚本。我想迭代所有路径,并用任意颜色填充路径(稍后我将替换这部分代码)。第一步只是在路径上迭代,我似乎不知道该怎么做。我的代码如下-为什么我没有看到任何路径被迭代?在
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from gimpfu import *
def plugin_main(image, layer, path):
vectors_count, vectors = pdb.gimp_image_get_vectors(image)
for n in vectors:
pdb.gimp_image_select_item(image,CHANNEL-OP-REPLACE,n)
foreground = pdb.gimp_context_get_foreground()
pdb.gimp_edit_fill(image.layers[0], foreground)
register(
"create_polygon_art",
"Fills all the paths with the average color within path",
"Fills all the paths with the average color within path",
"Bryton Pilling",
"Bryton Pilling",
"2018",
"<Image>/Filters/Fill all paths with average color",
"RGB*, GRAY*",
[],
[],
plugin_main
)
main()
我还尝试了许多不同的方法,包括使用更简单的迭代方法,比如:
^{pr2}$但不管我做了什么,我似乎都无法得到迭代的证据。在
我在Windows 10 64位上使用gimp 2.10.6。在
这是个陷阱。。。
pdb.gimp_image_get_vectors(image)
返回路径的整数ID列表,但是后面的调用需要一个gimp.Vectors
对象。在image.vectors
实际上是gimp.Vectors
的列表,您可以用更多问题:
gimp-edit-fill
接受颜色源而不是颜色。当你继续你的代码,你将不得不设置前景颜色,并推/弹出上下文CHANNEL-OP-REPLACE
不是有效的Python符号,在Python中应该使用CHANNEL_OP_REPLACE
(带下划线)python脚本的两个集合here和{a2}。在
如果您在Windows下,一些调试脚本的提示here
包含修复程序的代码:
^{pr2}$您可以通过绘制“笔划”使您的代码更加用户友好(这样您就有了一条包含多个笔划的路径)。如果要对笔划进行单独选择,可以将其复制到临时路径。可以在上面集合中的一些脚本中找到此代码。在
相关问题 更多 >
编程相关推荐