Page 1 of 1
How are circles drawn? (source link pls)
Posted: Tue Jun 20, 2017 10:53 am
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!
Re: How are circles drawn? (source link pls)
Posted: Tue Jun 20, 2017 6:25 pm
by Beelz
Re: How are circles drawn? (source link pls)
Posted: Tue Jun 20, 2017 7:00 pm
by zorg
Re: How are circles drawn? (source link pls)
Posted: Tue Jun 20, 2017 7:24 pm
by loveme
Maybe my question wasn't clear enough. I was wondering how it works under the hood.
Thank you for the link!
Well, I guess I still don't know how it works.
Re: How are circles drawn? (source link pls)
Posted: Tue Jun 20, 2017 9:05 pm
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.
Re: How are circles drawn? (source link pls)
Posted: Wed Jun 21, 2017 12:15 am
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
Re: How are circles drawn? (source link pls)
Posted: Wed Jun 21, 2017 6:51 am
by loveme
Thank you!