4

What I need: to draw different sets of icons in the same points of the picture (with the purpose of drawing different network schemes with the same structure). There are A LOT OF Points. Therefore I want to be able to separate the production of the icon and the positions of them in the final picture, i.e. I don't want to draw the icon and then copy and paste it in different points, since I would not be able to change the sets of icons without having to redraw everything.

Attempted Solution: I thought of i) draw the icon and save it as a brush, ii) draw single points with the path tool in the proper positions, iii) stroke the path using the icon brush. Iterate step iii) with different brushes.

Problem: Stroke Path.. does not work with single points. However, if I use short paths instead of single points there is an issue with the spacing: in the path I have sometimes 2 icons, sometimes 1 and sometimes 0.

Am I addressing the issue in the wrong way? Is there a solution?

  • If you add "changing GIMP's source code" to the set of possible solutions, then the answer could be to make stroke work for paths made out of single points. That would move this question to StackOverflow, though. – Michael Schumacher Apr 2 '15 at 18:59
3

So, indeed this can be considered a path-stroking bug - or at least missing feature. Even if GIMP developers can fix it, a new release with the feature implemented could take months.

On the other hand, this kind of thing is more or less easy to do using the script-engines that come along with GIMP. The following 6 lines of code can be pasted as they are in GIMP's Python console (Filters->Python->Console) - They will create a single "1-click-stroke" for each node (not each single node component) on a path, on the topmost layer of the latest open image (rightmost tab). (Change the 0 on the first line to get to other open images, in order, from right to left)

img = gimp.image_list()[0]
for vector in img.vectors:
    for stroke in vector.strokes:
        for i in range(2, len(stroke.points[0]), 6):
            x, y = stroke.points[0][i: i + 2]
            pdb.gimp_paintbrush_default(img.layers[0], 2, [int(x), int(y)])

Of course, to paste this each time you need to perform the task is cumbersome. To create a plug-in from this, follow the example and instructions at http://www.gimp.org/docs/python/ (these lines are to become the function body - and you should register three paramters: PF_IMAGE, PF_DRAWABLE and PF_VECTORS where that example only have "PF_INT"). Save the file with a ".py" extension in the plug-in folder, and for non-windows platforms, mark it as executable (using file properties) )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.