I want to create a simple graph maker in WP7.
The goal is to draw a texture line between two vectors what the user defines with touch. I already made the rotation, and it is working, but not correctly, because it doesn't calculate the line's texture height, and because of that, there are too many overlapping textures. So it does draw the line, but too many of them.
How could I calculate it correctly?
Here is the code:
public void DrawLine(Vector2 st,Vector2 dest,NodeUnit EdgeParent,NodeUnit EdgeChild)
{
float d = Vector2.Distance(st, dest);
float rotate = (float)(Math.Atan2(st.Y - dest.Y, st.X - dest.X));
direction = new Vector2(((dest.X - st.X) / (float)d), (dest.Y - st.Y) / (float)d);
Vector2 _pos = st;
World.TheHive.Add(new LineHiveMind(linetexture, _pos, rotate, EdgeParent, EdgeChild,new List<LineUnit>()));
for (int i = 0; i < d; i++)
{
World.TheHive.Last()._lines.Add(new LineUnit(linetexture, _pos, rotate, EdgeParent, EdgeChild));
_pos += direction;
}
}
d is for the Distance of the st (Starting node) and dest (Destination node)
rotate is for rotation
direction calculates the direction between the starting and the destination node
_pos is for starting position changing
Thanks for any suggestions/help!