2014-05-20 25 views
0

我正在嘗試使用GIMP繪製線條的任務自動化。如何在GIMP Python-fu插件中調用pdb.gimp_pencil

所以我嘗試了迄今爲止沒有運氣的腳本功能。

 

    >>>from pprint import pprint 
    >>>img = gimp.Image(200, 200, RGB) 
    >>>pprint (pdb.gimp_pencil.params) 
    ((16, 'drawable', 'The affected drawable'), 
    (0, 
     'num-strokes', 
     'Number of stroke control points (count each coordinate as 2 points) (num-strokes >= 2)'), 
    (8, 
     'strokes', 
     'Array of stroke coordinates: { s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y }')) 
    >>>pdb.gimp_pencil(img, 4, [0,0,200,200]) 
    Traceback (most recent call last): 
      File "<input>", line 1, in <module> 
    TypeError: wrong parameter type 
 

我找不到在Python傳遞(中風的陣列座標)矢量瘸子

什麼是錯在這裏的任何例子嗎?

回答

0

好吧,我的錯誤,我認爲TypeError是最後一個數組參數。碰巧img不是可繪製的,因此TypeError。

你必須:

  1. 創建圖像
  2. 創建層
  3. 的層添加到圖像
  4. 設置層有源
  5. 獲得圖像
  6. 的活動畫

然後只有你可以在中使用這個drawable方法。

img = gimp.Image(200, 200, RGB) 
layer = gimp.Layer(img, "Test", 200, 200, RGBA_IMAGE, 100, NORMAL_MODE) 
img.add_layer(layer, -1) 
pdb.gimp_image_set_active_layer(img, layer) 
draw = pdb.gimp_image_get_active_drawable(img) 
pdb.gimp_pencil(draw, 4, [0,0,100,100]) 
disp1 = gimp.Display(img)