Gimptalk - Premier Gimp Community: The Flexible Pixel Stretch Technique - Gimptalk - Premier Gimp Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

The Flexible Pixel Stretch Technique

#1 User is offline   XyllyX 

  • Newbie
  • Pip
  • Group: Retired Staff
  • Posts: 3
  • Joined: 14-June 05

Posted 08 July 2006 - 03:09 PM

There are at least two tutorials on here about pixel stretch methods. I wish to propose a third.

The other two methods make use of a skinny, 1 pixel wide, selection running from top to bottom of the area you want to pixel stretch. This works very well, but if you have an irregularly shaped area you want to do a pixel stretch of, you can only get part of it in your selection.

This method deals with pixel stretching irregularly shaped areas. With it, you can even do multiple areas at once.

For the purpose of this tutorial I have created the abstract shape below. I wasn't in the mood to go looking for a render that would be suitable for illustrating how this works.

Posted Image

Okay, you've got this weird shape. If you do a skinny rectangular selection, you can only get part of it, as shown below.

Posted Image
Posted Image

So what we do is to create a transparent layer above the one with the shape we want to pixel stretch, and draw a line on it. From here, we can go one of two ways. The simplest is to use our pencil tool with a 1 pixel wide brush and draw a line or lines that follow the shape that we want to "stretch" as below. For the purpose of illustration, I have lowered the opacity on the layer with our shape so as to see the line better.

Posted Image

Now to do this and control where our stretch occurs, we need some guides. We need one at the highest point that the line we drew intersects with the edge of our shape, and one at the lowest, so drag out two guides from the top of the canvas and place them at these points. Also drag out a guide from the left and put it somewhere convenient. Remember the vertical locations of these guides. Mine are at 14 and 129. 129-14=115. We need another guide at the midpoint between the first two. 115/2=57.5 or 57, since we can't split a pixel. There are two ways you can do this, one is to just add 57 to 14 to get 71. Or you can use the measure tool, click on the upper guide intersection (be sure you have snap to guides turned on) and drag down the vertical guide until you get to 57, then click. Now, if you press and hover the measure tool cursor over the place where you clicked, your cursor will change. (I think this looks different in the windows version of Gimp, but it still works the same). Click again. presto, you now have a horizontal guide that is exactly 57 pixels from the upper horizontal guide. The measure tool not only measures distances, but angles. You can also put vertical guides and intersections of guides with this tool as well, in Linux, anyway, will do a vertical guide and will create an intersection, windows is probably the same, but the cursor is different.

Edit 7-9-06:
I just found out about a built-in Gimp command. If you do Image>Guides>New Guides from Selection, it will put the guides in a box around your irregularly shaped selection, You will have four guides, but the top and bottom ones will be right on the high and low points of your shape.

Posted Image
Posted Image
Posted Image
Posted Image

In the next image, notice the readout at the bottom of the window. It shows the distance from the first measure tool click, and the angle as well.

Posted Image
Posted Image
Posted Image


Moving on....

Select the layer with the black line that you drew. Do Layer>Transparency>Alpha to Selection. You now have an irregularly shaped, 1 pixel wide selection. If you now select the layer with the shape, you have a selection that would cut/copy a wavy thin selection out of the middle of the shape.

However, unlike the rectangular pixel stretch technique, you can't use scale to stretch this wavy selection. Weird stuff happens. The scale tool tries to treat the selection as a rectangle enclosing the shape of the wavy line, so if you scale, you get this:

Posted Image

Fencepost's trick of converting the selection to a pattern doesn't work for this, either, since Gimp still wants to make a rectangular box around the selection.

But, if we take the selection and make a BRUSH out of it... Then we can do some stuff.

So, we have our selection derived from the thin line we drew. With the selection active, we click on the layer with our shape to select it, then do Script-Fu>Selection>To Brush. Name the new brush whatever you want. This is kind of a "throw away" brush, since it is unlikely that you will use it for anything else. Make sure that before you save your brush, you set the spacing to one.

Posted Image

Cancel your selection. Now to do some stretching. Create a new transparent layer underneath the shape and select it. With your new brush, click on that middle guide you created. Hold down your shift key to create a straight line and click somewhere further down the guide. Now hold on, you say...I am not getting a nice square edged stretch like I do with a regular pixel stretch.

Posted Image

True. There are two ways you can take care of this. You could do just enough with your new "pixel stretch brush" to make a nice section that you could then use a conventional pixel stretch method to make a new rectangular selection of. Or...you could create a new layer for your "stretch" that is longer than your image size and use it to do your brushing on. Example below.

Posted Image

Since your pixel stretch is now in brush form, that means all the things that are possible with brushes become possible in a pixel stretch. For example, you can make stretches that don't go in straight lines. The one I think is really cool is to use the fade out feature to create some nifty "motion" blur like effects...but without an actual blur. You also have access to all the brush modes. You can even brush with the colors from a gradient...what use would that be? I dunno, that is for somebody else to figure out.

Posted Image
Posted Image
Posted Image
Posted Image

Now, here is another idea. What if we do things differently, same set of ideas, but we get our "stretch brush" with a different method?

Our shape is on a transparent layer. So do Layer>Transparency>Alpha to Selection. Save the selection to a channel. With the selection still active, shrink it by one pixel and save that selection to a channel. Now pick the first channel and do "Channel to Selection". Pick the second channel and do "Subtract from Selection". Now you have a 1 pixel thick selection that surrounds the whole shape. Save that one to a channel.

Posted Image

What can we do with this? Well, if you cut that surround selection in half, for instance with another selection, or with the lasso tool, you could make different pixel stretch brushes. Imagine doing a pixel stretch that uses the edges of a render, rather than an arbitrary section taken from the middle. You could have the pixels stretch one way on the left side of the render, and another way on the right...each with the colors from that edge. In the shots below I show the 1pixel wide channel around the edge of the shape. Then I use the lasso tool in subtract mode to cut the selection in "half". Then I save this half selection to a channel. To get the other half, all I need to do is to go to the original "1 pixel border selection", do Channel to selection, then take the "half selection" channel I just made and do "subtract from selection and save that one to a channel. Now I have two perfectly mating half selections. You could even break those up further if you want.

Posted Image

Now, one final thing with this method...sometimes these weird shapes brush with a sort of "rippled effect", so you may want to brush things more than once, varying your start/end points to sort of even out the ripple. You can also use these brushes with smudge.
0

#2 User is offline   Repsa_Jih 

  • Member
  • PipPip
  • Group: Members
  • Posts: 409
  • Joined: 23-June 06

Posted 09 July 2006 - 11:29 AM

Wow. You rock. Thank you so much for this!
Current
Posted Image
Game Programming FTW:
My own Free RPG in C++
0

#3 User is offline   pwnagebrotice 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 08-July 06

Posted 09 July 2006 - 12:35 PM

Nice pixel stretch tutorial! I was always trying to find renders that went from the top of the screen to the bottom, but not more! Thanks.
Posted Image
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic