It is currently Thu Apr 24, 2014 2:16 pm


Latest GIMP Scripts & Plug-ins

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 60 posts ]  Go to page 1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject: Warped text
PostPosted: Sat Jul 03, 2010 5:43 pm  (#1) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1157
Location: not from Guildford after all
This script was written more as a learning exercise and I'm dubious as to its general utility. However, the crowd here seems somewhat adventurous and exceedingly creative, so I figured I'd see if any of you might not like to experiment a little with it.

http://chiselapp.com/user/saulgoode/repository/script-fu/wiki?name=sg-warp-text

The script will warp text to fit inside a four-point "Bezier patch". The bezier patch is created with the Path Tool, by placing first the upper-left anchor point, then the upper-right, followed by the lower-right, and finally the lower-left. You will probably want to close the path after placing the fourth point so that you can see the left-side curve. Closing a path is accomplished by holding down the CTRL key while clicking on the path's first anchor point.

Attachment:
File comment: The path that describes the target region
bezpatch.png
bezpatch.png [ 15.07 KiB | Viewed 5159 times ]


Once your patch is created, you can run the script (found under "Filters->Distorts->Warp Text...") on any text layer and eventually, after a good deal of huffing and puffing by the script, a new path will be created which is the outline of the text warped to fit within the patch. Basically, you are left just as you would be after doing a "Text along Path" in the Text tool Options dialog -- you are left to your own devices as to stroking the path, selecting from it and filling, etc. The dialog offers the option to warp any path, not just text; but I leave that for extra credit (perhap warping warped text? :) ).

Attachment:
File comment: Text path after warping
SSwarp.png
SSwarp.png [ 26.73 KiB | Viewed 5159 times ]


The fit is by no means perfect (usually mappings to Bezier surfaces entail additional control points inside the "patch"), but it may be useful for some situations. There is a "Padding" control which can be helpful in making sure the warped path doesn't fall outside the Bezier patch region (which is an unfortunate side effect of the shortcuts I took in my mapping algorithm). There is also a "Quality" setting which can range from below "10" (where letters are barely recognizable) to "250"; I don't notice much improvement above "100" and I set the default to "60" as speed versus quality compromise.

Let me know if you can find a use for it, if you find bugs, or if you can think of ways to improve it (I am considering allowing for more than four control points at some point, but that would require some slightly more sophisticated math).
Image


EDIT: This script has now been submitted to the GIMP Plug-in Registry.

_________________
Two of the most common mistakes made by programmers is off-by-one errors.


Last edited by saulgoode on Sun Jul 11, 2010 7:16 pm, edited 2 times in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Profile  
 
 Post subject: Re: Warped text
PostPosted: Sat Jul 03, 2010 6:53 pm  (#2) 
Offline
Administrator
User avatar

Joined: May 22, 2008
Posts: 5833
Location: Somewhere in GIMP
This is a fun script. I tried it with some dingbat hearts and, of course, came up with warped hearts.

Here is some text I played with. As with the hearts, the text came out sideways and mirrored. I need to work more to see what is causing that.

The original text is black, the first text is the brownish gradient and is mirrored and on its side. The orange and black text is after I rotated and flipped the text path.

I like the script and will continue playing with it to see what I come up with. I thought of making the text an animated "pulsing" movement ... done by changing the shape of the path several times. That will come later after I figure out how to make it come out right-side up and not mirrored.

Very cool script, saulgoode. :bigthup I can see using it where you'd want an unusual text formation that can't be done using just text. Band banners where the script is fitted into a frame. Like some of the Grateful Dead Posters I've seen. Kind of on this order http://images.wolfgangsvault.com/images/catalog/detail/FD012-PO.jpg
Image

_________________
Image
There are two major products to come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence.

Image


Top
 Profile  
 
 Post subject: Re: Warped text
PostPosted: Sat Jul 03, 2010 7:38 pm  (#3) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1157
Location: not from Guildford after all
I have updated the script to fix a mistake (that caused the lower curve to be less influential).

As far as the flipped and/or rotated result, that is usually caused by the envelope path's points being in the wrong sequence, though it is possible I have a bug in my code. If you can't figure out what's happening, perhaps you can send me a small example XCF which exhibits the anomaly. My address is my user name @ flashingtwelve.brickfilms.com

_________________
Two of the most common mistakes made by programmers is off-by-one errors.


Top
 Profile  
 
 Post subject: Re: Warped text
PostPosted: Sat Jul 03, 2010 7:49 pm  (#4) 
Offline
Administrator
User avatar

Joined: May 22, 2008
Posts: 5833
Location: Somewhere in GIMP
It could possibly be the sequence of the points. I'm a left-hander and even though I use my right hand for the mouse, it could be that the different direction is carried over to my mouse hand. I'll work with that and see if there's a difference with different directions.

_________________
Image
There are two major products to come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence.

Image


Top
 Profile  
 
 Post subject: Re: Warped text
PostPosted: Sun Jul 04, 2010 12:06 am  (#5) 
Offline
Administrator
User avatar

Joined: May 22, 2008
Posts: 5833
Location: Somewhere in GIMP
It does make a difference where you start the path and which direction you make it.

Upper Left and go CW all comes out fine.
Upper Left and CCW, comes out sideways and mirrored
Upper Right, CW makes it sideways but not mirrored
Upper Right, CCW upright but mirrored.

I deleted the old script and installed the updated one. I also closed and restarted GIMP to make sure the newest script was in effect.

Path was made starting on the lower right and CCW.
Text Came out upside down, mirrored, and turning it 180° corrected it.
Image

These were just for fun and I used the same path on both dingbats.

Image

_________________
Image
There are two major products to come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence.

Image


Top
 Profile  
 
 Post subject: Re: Warped text
PostPosted: Sun Jul 04, 2010 11:00 am  (#6) 
Offline
Administrator
User avatar

Joined: May 22, 2008
Posts: 5833
Location: Somewhere in GIMP
The filter is not very happy with the bottom upward curve in the GIMP text in this one.

Image

_________________
Image
There are two major products to come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence.

Image


Top
 Profile  
 
 Post subject: Re: Warped text
PostPosted: Sun Jul 04, 2010 11:50 am  (#7) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1157
Location: not from Guildford after all
Oregonian wrote:
The filter is not very happy with the bottom upward curve in the GIMP text in this one.

I would suggest checking your side curves; that result can be caused if there is "zig" in one of the sides. If a horizontal line through one of the side curves intersects at more than one point, such as shown below, the result would match what you've shown.

Attachment:
File comment: Overlapping side curve
SSsidepath.png
SSsidepath.png [ 413 Bytes | Viewed 5111 times ]


The "zig" may not even be visible when viewing the path; the overlapping points may lie directly over each other if the control handle for an anchor is located farther away than the other anchor.

If this is not the cause, perhaps you could export your path (available by right clicking on its thumbnail in the Paths Dialog) and provide me with the file (or provide an XCF containing your path).

Thanks for testing the script and providing feedback.

_________________
Two of the most common mistakes made by programmers is off-by-one errors.


Last edited by saulgoode on Sun Jul 04, 2010 12:34 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Warped text
PostPosted: Sun Jul 04, 2010 11:52 am  (#8) 
Offline
Administrator
User avatar

Joined: May 22, 2008
Posts: 5833
Location: Somewhere in GIMP
I did save it as an xcf file thinking you may want to look at it. Here it is.


Attachments:
bottomcurveNG.xcf [116.92 KiB]
Downloaded 172 times

_________________
Image
There are two major products to come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence.

Image
Top
 Profile  
 
 Post subject: Re: Warped text
PostPosted: Sun Jul 04, 2010 12:12 pm  (#9) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1157
Location: not from Guildford after all
Ahh, yes. Thanks.

The problem is indeed caused by the fact that the side curves have more than one X value for a given Y (though not exactly the "zig" I previously suggested).

If you can reposition your anchors to the bottom corners then you will not have that problem.
Attachment:
File comment: Repositioned anchors
SSmoved-anchors.png
SSmoved-anchors.png [ 1.05 KiB | Viewed 5105 times ]


As a general rule (unless one wants the distortion you obtained :) ), a control handle should always lie between its anchor and the adjacent anchor (either the next anchor in the path or the previous, depending on which control handle).

For example, in the above screenshot the control handle which happens to be closest to the lower-left anchor (the open circle) must not below the bottom-left anchor. Likewise, the other control handle shown must be to the right of the lower-left anchor.

Of course, rules can always be disregarded, if you are willing to accept the consequences.

_________________
Two of the most common mistakes made by programmers is off-by-one errors.


Top
 Profile  
 
 Post subject: Re: Warped text
PostPosted: Sun Jul 04, 2010 12:30 pm  (#10) 
Offline
Administrator
User avatar

Joined: May 22, 2008
Posts: 5833
Location: Somewhere in GIMP
I opened up my faulty path xcf file so I could visually see what you were saying about it. Aha! Understand.

Fixed my path.

Image

_________________
Image
There are two major products to come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence.

Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 60 posts ]  Go to page 1, 2, 3, 4, 5, 6  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

* Login  

* Subscribe to Gimp Chat's RSS Feed    * Subscribe to Gimp Chat's Tutorial Feed    * Subscribe to Gimp Chat's G'MIC Feed


Powered by phpBB3 © phpBB Group