line with arrows?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
vschiavoni
Prole
Posts: 6
Joined: Tue Jul 06, 2010 1:32 pm

line with arrows?

Post by vschiavoni »

Hello
i guess this is kind of a basic question, but i'm really a newbie. How do I attach an arrow to one or both the endings of a line? I guess I need to draw a triangle, but do I need to calculate by hand the coordinates, or is there
around some predefined function that I can add, by specifying the width of the arrow and how log it's supposed to be?

thanks,
valerio
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: line with arrows?

Post by Robin »

vschiavoni wrote:or is there
around some predefined function that I can add, by specifying the width of the arrow and how log it's supposed to be?
Nope, but I can give you a hint on what you need to do:
math.atan2(y, x), math.cos(a) and math.sin(a).
Help us help you: attach a .love.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: line with arrows?

Post by Robin »

I decided to write four arrow implementations, just for the heck of it. Four variants are (open, close) x (one end, two end). I'm sure you can make them much more advanced, for example by using setLineWidth or setLineStyle between draws, but this is the basic idea.
Attachments
arrow.love
(667 Bytes) Downloaded 288 times
Help us help you: attach a .love.
vschiavoni
Prole
Posts: 6
Joined: Tue Jul 06, 2010 1:32 pm

Re: line with arrows?

Post by vschiavoni »

thanks!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 207 guests