SFML community forums

Help => Graphics => Topic started by: Pixel_Outlaw on January 23, 2012, 09:13:47 am

Title: Stretching a sprite between two points.
Post by: Pixel_Outlaw on January 23, 2012, 09:13:47 am
Hello,

I'm trying to draw a texture as a line. The texture is 4x8 pixels. It is a gradient for a laser line effect. It points right but that might be the problem.

http://imageshack.us/photo/my-images/835/linebody.png/

Also I have a rounded end cap texture that must be rotated and placed at the endpoints. It points right but that might be the problem.

http://imageshack.us/photo/my-images/39/linecap.png/

I need a function to rotate and stretch the texture so the edges will touch (x,y) and (x2,y2). Then the end caps are rotated and placed on.

I've messed with this for about 2 hours and between C++'s notion of direction in radians, SFML's notion of direction in degrees, and moving sprite x and y origins. Nothing seems to work.


 :cry:
Title: Re: Stretching a sprite between two points.
Post by: TheEnigmist on January 23, 2012, 12:41:57 pm
Quote from: "Pixel_Outlaw"
Hello,

I'm trying to draw a texture as a line. The texture is 4x8 pixels. It is a gradient for a laser line effect. It points right but that might be the problem.

http://imageshack.us/photo/my-images/835/linebody.png/

Also I have a rounded end cap texture that must be rotated and placed at the endpoints. It points right but that might be the problem.

http://imageshack.us/photo/my-images/39/linecap.png/

I need a function to rotate and stretch the texture so the edges will touch (x,y) and (x2,y2). Then the end caps are rotated and placed on.

I've messed with this for about 2 hours and between C++'s notion of direction in radians, SFML's notion of direction in degrees, and moving sprite x and y origins. Nothing seems to work.


 :cry:


http://www.sfml-dev.org/forum/viewtopic.php?t=6654&postdays=0&postorder=asc&start=0
Maybe you can find useful info there.
Title: Stretching a sprite between two points.
Post by: Pixel_Outlaw on January 23, 2012, 05:03:55 pm
TheEnigmist,


This is not really the same thing. I need to stretch a texture from point a to point b.

Like this.

(http://img687.imageshack.us/img687/7205/helpbs.png)