How are circles drawn? (source link pls)

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
loveme
Prole
Posts: 3
Joined: Tue Jun 20, 2017 10:42 am

How are circles drawn? (source link pls)

Post by loveme »

Hi! I was wondering how circles, lines etc. are drawn in Love, but I can't find it in the source. Could someone who knows where to find it post a link, please? Also, if someone knows, I'd like to know what these algorithms are called.
Thanks a bunch!
User avatar
Beelz
Party member
Posts: 234
Joined: Thu Sep 24, 2015 1:05 pm
Location: New York, USA
Contact:

Re: How are circles drawn? (source link pls)

Post by Beelz »

Code: Select all

if self:hasBeer() then self:drink()
else self:getBeer() end
GitHub -- Website
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How are circles drawn? (source link pls)

Post by zorg »

https://bitbucket.org/rude/love/src/10f ... s.cpp-1757
No idea how it does it internally though.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
loveme
Prole
Posts: 3
Joined: Tue Jun 20, 2017 10:42 am

Re: How are circles drawn? (source link pls)

Post by loveme »

Maybe my question wasn't clear enough. I was wondering how it works under the hood.
zorg wrote: Tue Jun 20, 2017 7:00 pm https://bitbucket.org/rude/love/src/10f ... s.cpp-1757
No idea how it does it internally though.
Thank you for the link!

Well, I guess I still don't know how it works. :P
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: How are circles drawn? (source link pls)

Post by raidho36 »

It constructs a list of vertices, then extrudes them sideways to make a polygon that's shaped like a polyline, and then renders it normally.
alloyed
Citizen
Posts: 80
Joined: Thu May 28, 2015 8:45 pm
Contact:

Re: How are circles drawn? (source link pls)

Post by alloyed »

The actual code you want is at:

https://bitbucket.org/rude/love/src/10f ... s.cpp-1404

so raidho is right, it constructs a polygon, which then gets sent to the GPU as vertex data. The actual numbers just comes from the plain-jane cos/sin method: if you don't understand how this works, this wikipedia link might help:

https://en.wikibooks.org/wiki/Trigonome ... nit_Circle
loveme
Prole
Posts: 3
Joined: Tue Jun 20, 2017 10:42 am

Re: How are circles drawn? (source link pls)

Post by loveme »

Thank you! :)
Post Reply

Who is online

Users browsing this forum: No registered users and 42 guests