It is currently 04 Jun 2020, 01:31

• Featuring Members' Works (Image Attachments) •
1: member
2: member
3: member
4: member
5: member

GIMP/GL:  Tutorials | Tips | Questions | Interests | Script Requests
Recommendations:  Index | Top 10
Resources:  🡆 Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP

Stroke Paths with Gradient Script for GIMP

Share your Python Fu Scripts/plug-ins for GIMP here
Post Reply
tim
GL Blogger

Stroke Paths with Gradient Script for GIMP

Post#1 by tim » 04 Oct 2017, 23:36


I always knew about Ofnuts's path-inbetweener-0.2.py script.
Always thought it was cool but never really had a chance to use it.
Hopefully now, with this script, people (including me) will use it more.
Now I don't know if such a script already exists, but if it does (I do not know about it). I only thought of this script after writing Stroke Path with Gradient (with miter [sharp edges]) Script for Pegleg44.

This script will stroke all your VISIBLE paths.
stroke_paths_with_gradient.zip
zipped .py file (unzip, put in your GIMP's plug-ins/ folder)
(2.73 KiB) Downloaded 143 times
stroke_paths_with_gradient(2).zip
version 2. Fixed error so that it would work on Linux as well.
(2.8 KiB) Downloaded 169 times

Script Menu Location: Python-Fu/Stroke Paths with Gradient...

Script Option:
stroke_paths_with_gradient_options.jpg
stroke_paths_with_gradient_options.jpg (81.66 KiB) Viewed 3071 times
Instructions:
1. Create multiple paths (using Ofnut's path-inbetween script).
2. Run This Script (Python-Fu/Stroke Paths with Gradient...). Select Gradient/Reverse/Line Width.
3. Hit "OK". It'll stroke all your VISIBLE paths with selected gradient.
4. Also, a recent .svg file entry will be added to your Document History. You can open it (import .svg) by going to Files > Open Recent and click on the first .svg you see.

Example results:
example with start path, end path and a guide path
example with start path, end path and a guide path
stroke_paths_with_gradient_example_01.png (42.05 KiB) Viewed 3071 times
example with start path and end path.
example with start path and end path.
stroke_paths_with_gradient_example_02.png (50.46 KiB) Viewed 3071 times
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         
1

Pegleg44
Forum Member

Post#2 by Pegleg44 » 05 Oct 2017, 00:54


There is a stroke multiple visible paths plug-in that I've been using for a couple of years now. But I will get yours too.

Here it is:

Code: Select all

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# GIMP plugin to stroke all visible paths on separate layers
# (c) Ofnuts 2014
#
#   History:
#
#   v0.0: 2012-06-22: Initial version
#   v0.1: 2013-08-04: Add gradient support
#   v0.2: 2013-08-05: Check that there are some paths to stroke
#   v0.3: 2014-10-25: Add stroke/fill and single/multiple layer options

#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


import math, sys, os
from gimpfu import *

def newLayer(image,name,background):
	layer=gimp.Layer(image,name, image.width, image.height,RGBA_IMAGE, 100., NORMAL_MODE)
	image.add_layer(layer,0)
	pdb.gimp_drawable_fill(layer,background)	
	return layer

def strokeFillVisiblePaths(image,useGradient,fill,single,background,name):
	pdb.gimp_image_undo_group_start(image)
	pdb.gimp_context_push()
	try:
		colors=None
		singleLayer=None
		savedSelection=None
		if single:
			if name=='':
				name='Stroked/Filled paths'
			singleLayer=newLayer(image, name,background)
		if fill and not pdb.gimp_selection_is_empty(image):
			savedSelection=pdb.gimp_selection_save(image)
			
		strokedPaths=[p for p in image.vectors if p.visible]
		if len(strokedPaths) < 2:
			raise Exception("There should be at least two visible paths")
		if useGradient:
			colors=gimp.gradient_get_uniform_samples(gimp.context_get_gradient(),len(strokedPaths))
		for i,path in enumerate(reversed(strokedPaths)):
			if colors:
				pdb.gimp_context_set_foreground(colors[i])
				pdb.gimp_context_set_opacity(100*colors[i][3])
			if singleLayer:
				layer=singleLayer
			else:
				layer=newLayer(image,path.name+' '+name,background)
			if fill:
				pdb.gimp_image_select_item(image,CHANNEL_OP_REPLACE,path)
				pdb.gimp_edit_bucket_fill(layer,FG_BUCKET_FILL,NORMAL_MODE,100.,0.,0,0,0)
			else:
				pdb.gimp_edit_stroke_vectors(layer,path)

		if fill:
			pdb.gimp_selection_none(image)
			if savedSelection:
				pdb.gimp_image_select_item(image,CHANNEL_OP_REPLACE,savedSelection)
				pdb.gimp_image_remove_channel(image,savedSelection)
			
        except Exception as e:
		print e.args[0]
		pdb.gimp_message(e.args[0])

	pdb.gimp_context_pop()
	pdb.gimp_image_undo_group_end(image)
	pdb.gimp_displays_flush()
	return;
	
### Registration
whoiam='\n'+os.path.abspath(sys.argv[0])

register(
	'stroke-fill-visible-paths',
	'Stroke or fill visible paths...'+whoiam,
	'Stroke or fill visible paths',
	'Ofnuts',
	'Ofnuts',
	'2014',
	'Stroke or Fill Multiple Visible Paths',
	'*',
	[
		(PF_IMAGE, 'image', 'Input image', None),
		(PF_OPTION,'useGradient','Color',0,['Foreground color','From gradient']),
		(PF_OPTION,'fill','Stroke/Fill', 0,['Stroke','Fill']),
		(PF_OPTION,'single','Layers',0,['Multiple','Single']),
		(PF_OPTION,'background','Background fill', 1, ['Foreground color','Background color','White','Transparent','Pattern']),
		(PF_STRING,'name','Layer Name or Name suffix', ''),
	],
	[],
	strokeFillVisiblePaths,
	menu='<Image>/HEIGHT TOOLS',
)

main()

0

tim
GL Blogger

Post#3 by tim » 05 Oct 2017, 02:03


Ah, what do you know? one already exists. :D
Or at least very similar.
Well now you have another variation, where you get an .svg just in case you want to use it Inkscape or something.
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         
0

Pat625
Tutorial Creator

Post#4 by Pat625 » 05 Oct 2017, 04:27


Never hurts to have an extra script to choose, Tin!
TinTranStroke Mult.Paths.png
TinTranStroke Mult.Paths.png (347.43 KiB) Viewed 3045 times
TinTranStroke Mult.Paths.Paisley.png
TinTranStroke Mult.Paths.Paisley.png (214.4 KiB) Viewed 3045 times
1

RJKD
Tutorial Creator

Post#5 by RJKD » 05 Oct 2017, 10:22


Thankyou for yet another useful script T. I use 'Fill or stroke visible paths' found under Image, this gives option to use gradient, sorry for such a dumb question but how do the filters differ?
Here's an older image using that script...
Led_Zeppelin3.jpg
Led_Zeppelin3.jpg (113.7 KiB) Viewed 3031 times
This is the script
stroke-visible-paths-0.6.zip
(2.06 KiB) Downloaded 67 times
0

tim
GL Blogger

Post#6 by tim » 05 Oct 2017, 14:33


Ofnuts script allows single layer or multiple layers and uses active brush to stroke the path or fill the path.
My script strokes path like line stroke using svg on a single layer, and you get an .svg file.
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         
0

Pegleg44
Forum Member

Post#7 by Pegleg44 » 05 Oct 2017, 14:58


And Tins script gives the ability to change stroke size and miters the edges which can be useful.
0

RJKD
Tutorial Creator

Post#8 by RJKD » 05 Oct 2017, 16:20


Thankyou T and Pegleg44.
0


GIMP/GL:  Tutorials | Tips | Questions | Interests | Script Requests
Recommendations:  Index | Top 10
Resources:  🡆 Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP

Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 16 guests