[Part I. GIMP基礎功]

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

29.8 熔岩圖,修改過程中,須注意的 Python 語法特點

  • 經過這樣的轉碼練習,發現電路圖 circuit.scm 、熔岩圖 lava.scm ,寫碼的技巧,有許多雷同之處 ,才發現這兩者都是 Adrian Likins 的作品。
  • 因此,修改 lava.scm 須注意的 Python 語法特點可參考「28.8 節」。


電路圖、熔岩圖,都有「計算出選取區域的長寬」

Scheme code
(set! selection-bounds (gimp-selection-bounds image))
(set! select-offset-x (cadr selection-bounds))
(set! select-offset-y (caddr selection-bounds))
(set! select-width (- (cadr (cddr selection-bounds)) select-offset-x))
(set! select-height (- (caddr (cddr selection-bounds)) select-offset-y))



Python code
selection_bounds = pdb.gimp_selection_bounds(image)
select_offset_x = selection_bounds[1]
select_offset_y = selection_bounds[2]
select_width = selection_bounds[3] - select_offset_x
select_height = selection_bounds[4] - select_offset_y