[Part I. GIMP基礎功]

[Part II. 一種效果的誕生]
[Part III. Script-Fu的秘密]



22.11 印刷字,修改過程中,須注意的 Python 語法特點

計算出文字所需的長寬
Scheme code
(define text-ext (gimp-text-get-extents-fontname string ...))
(define width (+ (car text-ext) 20 blur-radius))
(define height (+ (list-ref text-ext 1) 20 blur-radius))

Python code
text_ext = pdb.gimp_text_get_extents_fontname(string, ......)
width = text_ext[0] + 20 + blur_radius
height= text_ext[1] + 20 + blur_radius


加減乘除四則運算
Scheme code
(define grey (/ (* density 255) 100))
Python code
grey = (density * 255) / 100

if 條件控制的敘述
Scheme code

(if (> blur-radius 0)
(plug-in-gauss-iir RUN-NONINTERACTIVE img ......)
)

Python code 要注意縮排

if blur_radius > 0:
  pdb.plug_in_gauss_iir(img, ......)


RGB 顏色的指定
Scheme code
(define text-color "black")
(define bg-color "white")

Python code
text_color = (0, 0, 0)
bg_color = (255, 255, 255)