我正在尝试开发一个可以在打开的 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()
我还尝试了许多通过谷歌搜索找到的不同方法,包括使用更简单的迭代方法,例如:
for v in gimp.Vectors
但无论我尝试什么,我似乎都无法获得路径迭代的证据。
我在 Windows 10 64 位上使用 gimp 2.10.6。