I'm trying to write a sort of wrapper library for GIMP to make my generative art projects easier, but i'm having a problem interfacing with gimpfu from a my wrapper module. The following plugin code runs fine, and displays an image with horizontal lines drawn across it:
from gimpfu import *
from basicObjects import *
def newFilt() :
img = gimp.Image(500, 500, RGB)
background = gimp.Layer(img, "Background", 500, 500,RGB_IMAGE, 100, NORMAL_MODE)
img.add_layer(background, 1)
background.fill(BACKGROUND_FILL)
pdb.gimp_context_set_brush('1. Pixel')
pdb.gimp_context_set_brush_size(2)
for i in range(100):
Line= line([(0,5*i),(500,5*i)])
pdb.gimp_pencil(background,Line.pointcount,Line.printpoints())
gimp.Display(img)
gimp.displays_flush()
register(
"python_fu_render",
"new Image",
"Filters",
"Brendan",
"Brendan",
"2016",
"Render",
"",
[],
[],
newFilt, menu="<Image>/File/Create")
main()
the 'line' class is defined in basicObjects, and is functioning as expected, however if I try to replace 'pdb.gimp_pencil(background,Line.pointcount,Line.printpoints())' with 'Line.draw(background)', and add a draw() function to the line class, as such:
from gimfu import *
class line:
"""creates a line object and defines functions specific to lines """
def __init__(self, points):
self.points = points
self.pointcount = len(points)*2
def printpoints(self):
"""converts point array in form [(x1,y1),(x2,y1)] to [x1,y1,x2,y2] as nessecary for gimp pdb calls"""
output=[]
for point in self.points:
output.append(point[0])
output.append(point[1])
return output
def draw(self,layer):
pdb.gimp_pencil(layer,self.pointcount,self.printpoints())
the image is not rendered, and there is no messages displayed in the gimp error console.How can I make a pdb call from an external file? Would making the wrapper a separate plug-in help somehow?