It is currently Thu Apr 25, 2024 5:08 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 70 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Wed Feb 12, 2014 6:43 pm  (#1) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
I don't like GFig (it cannot create paths...) so I use shape-paths, but I don't like entering all that data by hand. It's much easier and faster to indicate where your shape should go with points on your image, so to answer this I wrote here path-to-shape. You can draw:

  • a circle given a center and a point on the circle (if more points: more concentric circles)
  • a circle given two points on a diameter (if more points: more circles with a common point)
  • a regular polygon given a center and a vertex (the line between them is a "circumradius"), the additional points on the stroke tell how many sides/vertices you want.
  • a regular polygon given a center and the middle of a side (the line between them is an "apothem"), the additional points on the stroke tell how many sides/vertices you want.
  • a regular polygon given the two ends of a side, the additional points indicating the number of sides, the third point hinting on which side is the polygon.

Pictures being worth a thousand words:

Attachment:
path-to-shapes-cheatsheet.png
path-to-shapes-cheatsheet.png [ 40.45 KiB | Viewed 6459 times ]


Warnings:

  • Barely debugged. If you aren't too familiar with paths, don't bother for the time being
  • Still some very rough edges, no decent checks of your input
  • Still some questions:
    • Should the result path be made visible or not?
    • Should the source path be made invisible or even deleted or not?
    • Are there other common shapes amenable to this kind of input (I have a "star" in the works)

Once installed, the script is available in the right-click menu of the Path list, under a "Shapes" menu. There are no parameters, so that each way to enter a shape can be assigned a keyboard shortcut.

Available at the usual place.

Enjoy

_________________
Image


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Wed Feb 12, 2014 7:02 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: Aug 16, 2012
Posts: 4271
Location: Göteborg, Sweden
ofnuts: :yes you rock!!!! you're a real path script wizard, thank you for sharing your magic here :)!

_________________


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Wed Feb 12, 2014 7:06 pm  (#3) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
This one is a lot more about trigonometry than about Gimp :) Now where did I keep the aspirin :)

_________________
Image


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Thu Feb 13, 2014 12:53 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Sep 22, 2012
Posts: 2089
Location: US
the more I play with your script the more I'm convinced in its usefulness

the field of application may vary but the first thing that comes to mind is creating design for infographics*



ofnuts wrote:
[*]Still some questions:
  • Should the result path be made visible or not? Yes
  • Should the source path be made invisible or even deleted or not? Visible, don't delete - may need to edit
  • Are there other common shapes amenable to this kind of input (I have a "star" in the works)
[/list]


* therefore, I'd suggest to add two more functions to your script

Image

Your thoughts?


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Thu Feb 13, 2014 2:11 am  (#5) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
Circumcircle is already on my mind (only for a triangle, but the circumcircle for the other ones, when it exists, is the circumcircle obtained with any of 3 vertices). On the other hand the script uses the usual approximation of a circle by a Bézier spline, so there are only 8 points that are really on the circle (every 45°) which means that if I can compute the circle, the curve that will implement it will not, in the general case, go exactly through all three points.

Then this script is more about replacing a clumsy dialog input by a set of points than about computing lines. Computing the common tangent to two random Bézier curves is beyond my abilities, and if I may be able to compute the common tangent between two circles given by two points each, this will be the tangent to the theoretical circles and not to their Bézier approximation. Doing the real tangent by hand will be more efficient.

_________________
Image


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Thu Feb 13, 2014 2:32 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Sep 22, 2012
Posts: 2089
Location: US
ofnuts wrote:
the circumcircle for the other ones, when it exists, is the circumcircle obtained with any of 3 vertices). On the other hand the script uses the usual approximation of a circle by a Bézier spline, so there are only 8 points that are really on the circle (every 45°) which means that if I can compute the circle, the curve that will implement it will not, in the general case, go exactly through all three points.


You're right, there is even a tool in Illustrator - to create a circle by 2 or 3 points, two is the minimum required, three is more than enough for
equilateral polygons, but this is a tool that you drag on canvas and see the outlines immediately. My second example under circumcircle is a perfect square, which is much easier to draw in gimp than equilateral triangle (rectangular select tool> to path).


ofnuts wrote:
Then this script is more about replacing a clumsy dialog input by a set of points than about computing lines. Computing the common tangent to two random Bézier curves is beyond my abilities, and if I may be able to compute the common tangent between two circles given by two points each, this will be the tangent to the theoretical circles and not to their Bézier approximation. Doing the real tangent by hand will be more efficient.


Yeah, I suspected that might be too difficult. Well, whoever wants an insane precision can always use the CAD tools :hehe


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Sat Feb 15, 2014 8:43 am  (#7) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
Hardened the code and added a couple of things. See version 0.1.

The new cheatsheet:

Attachment:
path-to-shapes-cheatsheet.png
path-to-shapes-cheatsheet.png [ 79.36 KiB | Viewed 6222 times ]

_________________
Image


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Sat Feb 15, 2014 8:50 am  (#8) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Nice Ofnuts. And thanks for the cheat sheet. :)

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Mon Feb 17, 2014 7:27 am  (#9) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
@K1TesseraEna: eventually computing tangents isn't that hard. I have cornered the tangents from a point, tangents between circles come next. These lines are indeed useful to create nice and clean figures:

Attachment:
TangentsFromPoint.png
TangentsFromPoint.png [ 10.33 KiB | Viewed 6156 times ]


Question about the interface:

1) There are many tangents: from a point you have two (unless the point is in the circle), between two circles there are four in the general case (two if they intersect, none if one is included in the other). So, would it be useful to distinguish the tangents by producing them on distinct paths, those unneeded being more easily ignored/erased than if they were strokes in the same path?

2) Unlike the other shapes, that use paths completely created for that purpose, tangents apply to pre-existing paths so circles and points will usually be in different paths. So how is the second path specified? In a usual dialog or more implicitly (linked or visible path)?

_________________
Image


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Mon Feb 17, 2014 3:44 pm  (#10) 
Offline
GimpChat Member
User avatar

Joined: Mar 18, 2011
Posts: 283
Location: Lusaka, Zambia
Please, where do I save the .py file and can I access the path-shape from Gimp?


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Mon Feb 17, 2014 4:17 pm  (#11) 
Offline
GimpChat Member
User avatar

Joined: May 10, 2013
Posts: 1389
Location: FInland
josephbupe wrote:
Please, where do I save the .py file and can I access the path-shape from Gimp?

You put it in /User/.gimp-2.8/plug-ins/ folder
It is under Filters?/Vectors/Shapes. I always edit the menu entries of scripts and plugins with notepad++

You can also find every plugin and script from Help/Plug-in browser.


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Mon Feb 17, 2014 4:21 pm  (#12) 
Offline
GimpChat Member
User avatar

Joined: Mar 18, 2011
Posts: 283
Location: Lusaka, Zambia
Quote:
You put it in /User/.gimp-2.8/plug-ins/ folder


Thanx I will try again.

Quote:
You can also find every plugin and script from Help/Plug-in browser.


Oh! can I launch plug-ins from within the plug-in-browser too?


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Mon Feb 17, 2014 6:49 pm  (#13) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
josephbupe wrote:
Please, where do I save the .py file and can I access the path-shape from Gimp?


Like most of my paths related scripts, it is accessed via the right-click pop-up menu in the Path list. It should better stay there because that way it can be applied to any path without making this path the active one.

_________________
Image


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Tue Feb 18, 2014 12:52 am  (#14) 
Offline
GimpChat Member
User avatar

Joined: Mar 18, 2011
Posts: 283
Location: Lusaka, Zambia
Thank you ofnuts.


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Tue Feb 18, 2014 2:28 am  (#15) 
Offline
GimpChat Member
User avatar

Joined: Sep 22, 2012
Posts: 2089
Location: US
ofnuts wrote:
@K1TesseraEna: eventually computing tangents isn't that hard. I have cornered the tangents from a point, tangents between circles come next. These lines are indeed useful to create nice and clean figures:

Question about the interface:

1) There are many tangents: from a point you have two (unless the point is in the circle), between two circles there are four in the general case (two if they intersect, none if one is included in the other). So, would it be useful to distinguish the tangents by producing them on distinct paths, those unneeded being more easily ignored/erased than if they were strokes in the same path?

2) Unlike the other shapes, that use paths completely created for that purpose, tangents apply to pre-existing paths so circles and points will usually be in different paths. So how is the second path specified? In a usual dialog or more implicitly (linked or visible path)?


Considering the peculiarities of how paths in gimp are handled [we can 'group' separate paths by merging them but there's no way to ungroup or select elements of a complex path, other than copy/paste and delete duplicate shapes anchor by anchor], I think it would be more useful to create all possible tangents for any given number of curves and points (if any) in visible paths, with each tangent as an individual path. The redundant paths could be deleted/made_invisible, the necessary ones could be transform-locked or merged [as in Merge_Visible] - if there is a need to isolate or treat them as a single object [using Inkscape, Illustrator terminology].
BTW, I'd suggest to do the same for the current circles creation in your script, each circle as a separate path.

If there are no common tangents between any given curves or curve/point pair [e.g. encircled curve/point, two parallel arcs, etc.], then the script should issue a warning/error_message - 'no common tangents were found' or something like that.

I like new additions especially a rectangle with rounded corners :bigthup


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Tue Feb 18, 2014 2:45 am  (#16) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
K1TesseraEna wrote:
there's no way to ungroup or select elements of a complex path, other than copy/paste and delete duplicate paths anchor by anchor


Welcome to delete-strokes.py, one of the oldest scripts in my collection and its not so young kid brother decompose-strokes.py :)

_________________
Image


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Tue Feb 18, 2014 2:56 am  (#17) 
Offline
GimpChat Member
User avatar

Joined: Sep 22, 2012
Posts: 2089
Location: US
ofnuts wrote:
K1TesseraEna wrote:
there's no way to ungroup or select elements of a complex path, other than copy/paste and delete duplicate paths anchor by anchor


Welcome to delete-strokes.py, one of the oldest scripts in my collection and its not so young kid brother decompose-strokes.py :)


:hehe these are useful scripts Ofnuts, I just wonder how come these simple operations are still not the build-in features of the gimp path tool? :roll:


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Tue Feb 18, 2014 4:51 am  (#18) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
Well, as someone puts it, I'm making Gimp look like Inkscape, one script at a time :) In other words, those who use paths that much should look at Inkscape. One of these days I will :)

_________________
Image


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Tue Feb 18, 2014 5:43 am  (#19) 
Offline
GimpChat Member
User avatar

Joined: Sep 22, 2012
Posts: 2089
Location: US
ofnuts wrote:
Well, as someone puts it, I'm making Gimp look like Inkscape, one script at a time :) In other words, those who use paths that much should look at Inkscape. One of these days I will :)


well....Inkscape thinks differently, and gimp's path tool will never look alike.
I did say here a long time ago that if people like you, with EO paths expertise, turned to Inkscape it would have been a much better tool because, frankly, it has a lot of room for improvement. I do all my vectors in Illustrator. It is superior to CorelDraw and IS, hands down. If you can write in javascript, Ai is a fruitful soil for scripting.


Top
 Post subject: Re: path-to-shape: the hidden son of Gfig and shape-paths
PostPosted: Tue Feb 18, 2014 4:14 pm  (#20) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
OK, new version with the tangents at the usual place:

Attachment:
InnerOuterTangents.png
InnerOuterTangents.png [ 17.46 KiB | Viewed 1810 times ]


Both tangent entries assume that the first stroke on the target path can be see as a circle: 2 point is a circle by center and radius, 3 points or more is a circumcircle (this case also covers circles produced by the circle entries...).

Then either:

- there is another path "linked": each stroke it contains is used to determine tangents. For the point to circle, every point in the stroke(s) is used to compute a pair of tangents, for the circle to circle, each stroke is interpreted as a circle depending on number of points, as above.

- there is no linked path: the script uses other strokes in the same path (but nothing in Gimp guarantees that the order of strokes is preserved, so getting the circle in 1st position may be difficult.

The output is two (point to circle) or four (circle to circle) paths, where the strokes are grouped by type/side. inner/outer and left/right.

Enjoy

_________________
Image


Top
Post new topic Reply to topic  [ 70 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Path: reduce the number of nodes while keeping the shape

9

No new posts Attachment(s) HN: Draw shape - Create paths draw shapes simultaneously and easily

31

No new posts Attachment(s) Words to shape

2

No new posts how to transfer one shape onto another

3

No new posts Attachment(s) Shape 3D Plugin

2



* Login  



Powered by phpBB3 © phpBB Group