gpt4 book ai didi

scheme - gimp 脚本-fu : drawing a simple line

转载 作者:行者123 更新时间:2023-12-02 04:10:35 24 4
gpt4 key购买 nike

我正在尝试使用 gimp 脚本绘制一条线。在以下脚本中:我创建一个新图像 512x512,并尝试绘制一条对角线 (0,0)->(512,512)。但图像 (tmp.xcf) 保持透明。

我做错了什么?

(define (drawdiagonal W H)
(let* (
(img 0)
(bg 0)
(points (cons-array 4 'double) )
)
(set! img (car (gimp-image-new W H 0)))
(gimp-image-undo-group-start img)
(gimp-context-push)
(set! bg (car (gimp-layer-new img W H RGBA-IMAGE "background" 100 NORMAL-MODE)))
(gimp-image-add-layer img bg 0)
(gimp-drawable-set-visible bg TRUE)
(gimp-image-set-active-layer img bg)
(gimp-context-set-brush-size 10.0)
(gimp-context-set-opacity 100)
(gimp-context-set-paint-mode NORMAL-MODE)
(gimp-context-set-foreground '(255 127 0))
(gimp-selection-all img)

(aset points 0 0)
(aset points 1 0)
(aset points 2 W)
(aset points 3 H)
(gimp-paintbrush-default bg 4 points)

(gimp-context-pop)
(gimp-image-undo-group-end img)

(gimp-xcf-save 1 img img "tmp.xcf" "tmp.xcf")
(display "DONE")
)
)

(drawdiagonal 512 512) (gimp-quit 0)

用法:

cat test.scm | gimp -i  -b -

最佳答案

看来你大部分都失踪了:

(gimp-context-set-brush "Some brush")

此外,第三个参数(第二个img)应该是一个可绘制的:

(gimp-xcf-save 1 img img "tmp.xcf"  "tmp.xcf")

PS:帮自己一个忙,用 Python 编写脚本。请参阅here举个例子。

编辑 Gimp 2.10 后的版本:现在有一个 API 可以在“Line”模式下描边路径,这是获得干净结果的最佳方式。相关调用是:

pdb.gimp_context_set_stroke_method(STROKE_LINE)
pdb.gimp_context_set_line_cap_style(...)
pdb.gimp_context_set_line_join_style(...)
pdb.gimp_context_set_line_miter_limit(...)
pdb.gimp_context_set_line_width(width)
pdb.gimp_drawable_edit_stroke_item(drawable, path)

关于scheme - gimp 脚本-fu : drawing a simple line,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49056476/

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