Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Stretching a sprite between two points.  (Read 2355 times)

0 Members and 1 Guest are viewing this topic.

Pixel_Outlaw

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Stretching a sprite between two points.
« 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:

TheEnigmist

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Re: Stretching a sprite between two points.
« Reply #1 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.

Pixel_Outlaw

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Stretching a sprite between two points.
« Reply #2 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.