It is currently Thu Mar 28, 2024 8:57 am


All times are UTC - 5 hours [ DST ]



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

Joined: Apr 23, 2010
Posts: 1553
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 16290 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 16290 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.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Last edited by saulgoode on Sun Jul 11, 2010 6: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
 Post subject: Re: Warped text
PostPosted: Sat Jul 03, 2010 5:53 pm  (#2) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
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
World War IV will be fought with sticks and stones. - Albert Einstein


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

Joined: Apr 23, 2010
Posts: 1553
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

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Warped text
PostPosted: Sat Jul 03, 2010 6:49 pm  (#4) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
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
World War IV will be fought with sticks and stones. - Albert Einstein


Top
 Post subject: Re: Warped text
PostPosted: Sat Jul 03, 2010 11:06 pm  (#5) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
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
World War IV will be fought with sticks and stones. - Albert Einstein


Top
 Post subject: Re: Warped text
PostPosted: Sun Jul 04, 2010 10:00 am  (#6) 
Offline
Retired Staff
User avatar

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

Image

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


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

Joined: Apr 23, 2010
Posts: 1553
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 16242 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.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


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

Top
 Post subject: Re: Warped text
PostPosted: Sun Jul 04, 2010 10:52 am  (#8) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
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 541 times

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein
Top
 Post subject: Re: Warped text
PostPosted: Sun Jul 04, 2010 11:12 am  (#9) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
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 16236 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.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Warped text
PostPosted: Sun Jul 04, 2010 11:30 am  (#10) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
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
World War IV will be fought with sticks and stones. - Albert Einstein


Top
 Post subject: Re: Warped text
PostPosted: Sun Jul 04, 2010 1:57 pm  (#11) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
COOL!
Its a text to envelope effect!...pretty much.
I have been waiting for a script like this.
I have been doing all my envelope effects in InkScape, but no longer. =)
Can't wait to see this script developed more.It's neat to watch it working.

Image

Image

very nice

thanks saulgoode. =)

_________________
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: Warped text
PostPosted: Sun Jul 04, 2010 2:07 pm  (#12) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
Rod, those are great. It's a cool script, isn't it? I like it.

It looks like it's perfect for your envelope effect. :bigthup

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


Top
 Post subject: Re: Warped text
PostPosted: Sun Jul 04, 2010 2:33 pm  (#13) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Yes it is, i love it! =)
I cant wait to be able to use more node points.

_________________
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: Warped text
PostPosted: Sun Jul 04, 2010 8:01 pm  (#14) 
Offline
GimpChat Member
User avatar

Joined: Apr 08, 2010
Posts: 5420
Location: Northwest Ohio
This will be perfect for the psychedelic poster tutorial I ran across the other week. Using curve bend for the text produced less than great results, but this script looks like it would do the job!


Top
 Post subject: Re: Warped text
PostPosted: Mon Jul 05, 2010 6:33 am  (#15) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
I know this script is real cool, and should be implemented in GIMPS program package imo.
It is very, very handy. =)

_________________
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: Warped text
PostPosted: Mon Jul 05, 2010 10:32 am  (#16) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Once again, thanks for all of the feedback. It is really appreciated.

I have made a few minor changes to the script and have updated the file (still at the same location). You should replace the original file with this substitute.

  • Named the warped path based on the name of the original envelope path so that it will be easier to keep track of multiple separate shapes (as Oregonian demonstrated).
  • Script should work on grayscale and Indexed images now.
  • There is now no need to have a layer active to run the script. When using an "alternate path", a text layer is not needed and the script can now be run if a channel is the active drawable (previously the menu command was grayed out). Of course, if you don't check the "Use alternate path" box and the active drawable is not a text layer, you will receive an error.

There is a problem that I need to solve before I can implement additional curve points: when points are added between the last anchor of a path and the first, the added point sometimes becomes the new first point. :gaah I will likely post more on this later and seek advice, but that enhancement is on the back burner for a while.

If Rod doesn't mind, I will use his idea of the yellow stripes to describe how the "Use alternate path" option might sometimes be used for creating warped fill patterns.

After warping the text to its envelope, create a new layer and fill the warped region with black. Then...
  1. Do an "Alpha to selection" on the original text layer.
  2. With the Rectangle Select Tool, click on the selection (you should see the resize box appear with handles in the four corners). Then move the mouse pointer to the top center of the selection so that the center resize handle appears (do not press the mouse button). With the mouse pointer hovering over the top center resize handle, hit the left cursor button on your keyboard (the marching ants should switch to marching around the rectangle, instead of the text) and then click the mouse inside the selection or hit the ENTER key to accept the selection. (This step effectively converts a selection to its bounding box.)
  3. Save your selection to a channel (for later use).
  4. Perform a "Select->All".
  5. Activate the Quickmask (the Select All means that you will be rendering on a white channel).
  6. Use "Filters->Render->Patterns->Grid" to create horizontal black lines (you need to unlink the Width spinners, set the Vertical width to "0", and set the Horizontal width to one-half the Spacing value).
  7. Use the Rotate Tool to rotate the grid diagonally ("-45" degrees).
  8. Exit Quickmask. You should now have a selection of diagonal strips covering most of your image (but not the corners owing to rotation).
  9. Activate the rectangle selection channel you saved earlier (it should already be active, but make sure if it isn't).
  10. Hold down the CTRL+SHIFT keys and click on the red square "Channel to Selection" button at the bottom of the Channels Dialog. (Your selection should now be the intersection of the diagonals within the previously defined rectangle.)
  11. Perform a "Select->To path". This is the "alternate path" which you will be warping.
  12. Go to the Paths Dialog and activate your original envelope path.
  13. Run the Warp Text script, specifying that an alternate path should be used and choosing the saved selection from the dropdown.
  14. After the script has finished, click on the red square "Path to Selection" button on the bottom of the Paths Dialog.
  15. Activate the warped text path, hold down the CTRL+SHIFT keys, and click on that same "Path to Selection" button.

This selection can now be used to fill the warped black layer with warped yellow stripes.
Attachment:
File comment: Final result
ex-warped-lines.png
ex-warped-lines.png [ 12.47 KiB | Viewed 4120 times ]

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Last edited by saulgoode on Mon Jul 05, 2010 8:09 pm, edited 4 times in total.

Top
 Post subject: Re: Warped text
PostPosted: Mon Jul 05, 2010 11:37 am  (#17) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
Man, I didn't think I could do all that but I did! I'm not very familiar with channels but I sure didn't want to add another path to the mix so went ahead on the channel.

I think my envelope could have used some curves but it's too late for this image. I think I goofed up on the stripes. They were still in the shape of the envelope instead of the warped text so I filled the orange stripes on a separate layer, did alpha to selection on the warped text, inverted and deleted on the stripes layer.

That's a really cool way to warp the stripes, saulgoode! Kudos! Brilliant use of the Quickmask.

Image

Question: What does Ctrl + Shift + Path/Channel to selection do differently from just clicking on the to selection button in those?

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


Top
 Post subject: Re: Warped text
PostPosted: Mon Jul 05, 2010 12:29 pm  (#18) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Oregonian wrote:
Man, I didn't think I could do all that but I did! I'm not very familiar with channels but I sure didn't want to add another path to the mix so went ahead on the channel.

I think there may be some misunderstanding. While my update now permits the script to be run while a channel is active, the channel is not actually used (and an alternate path must be selected). This is just a matter of how GIMP disables commands in the menus based on the type of the active drawable, and while the script doesn't need either a layer or a channel if an alternate path is used, I didn't want the user to have to switch dialog boxes just so the script's command wouldn't be grayed out in the menus.

Oregonian wrote:
Question: What does Ctrl + Shift + Path/Channel to selection do differently from just clicking on the to selection button in those?

As you know, clicking on the button (with no modifier keys) replaces the current selection (if any) with the shape of the highlighted Channel or Path. Holding SHIFT down while clicking will ADD the shape of the channel or path to the current selection. Holding CTRL while clicking SUBTRACTs the highlighted channel or path from the current selection.

And to your question, holding down both CTRL and SHIFT while clicking on the red button will INTERSECT the highlighted channel or path with the current selection. This means that if a region (even a single pixel) is selected in the channel (or path) AND also appears in the current selection then that region will appear in the resulting selection.

In the following image, the red square represents the selection before clicking on the button, the blue square represents the shape of the channel or path, and the green shape on the right shows the result. Note that these modifier keys provide the same functionality commonly available in the selection tools (as described in section 2.1 of the GIMP Users Manual).

Attachment:
SSmodkeys.png
SSmodkeys.png [ 3.47 KiB | Viewed 4112 times ]

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Warped text
PostPosted: Mon Jul 05, 2010 1:20 pm  (#19) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
Ah! Thanks for that explanation. Now I understand where I went wrong on the first one. I think I did not do c + s + to selection. This one was done correctly.

Image

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


Top
 Post subject: Re: Warped text
PostPosted: Mon Jul 05, 2010 1:34 pm  (#20) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
That looks great, Oregonian! I'm glad you've got things sussed and appreciate your perseverance.

Going off topic a bit, I've been to about a dozen Grateful Dead shows and the ones in Eugene were by far my favorites. What a scene!

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


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

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) GEGL Text Style Collection - plugin with many fancy text styles

11

No new posts Attachment(s) manipulate a portion of text inside a text layer using python-fu

2

No new posts script to load text file and create text layer

6

No new posts Attachment(s) GEGL ROCK TEXT 2 - Advance rock text plugin -requires Gimp 2.10.32+

8

No new posts Attachment(s) Colorful Pattern from Text (Text Pattern) Plug-in

32



* Login  



Powered by phpBB3 © phpBB Group