Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / Where is draw_circle? / Procedural shapes
- - By jlnr (dev) Date 2010-11-03 16:22
Since everybody seems to look for draw_circle along with draw_triangle, draw_quad etc.…

Gosu offers lines, triangles and quads because that is what OpenGL gives us. There is no single right way to draw a circle in OpenGL. It's fun to be clever and use trigonometry and Gosu::draw_line/Gosu::draw_triangle. In practice, a precomputed circle image is usually much more efficient, yet rendering a circle in Photoshop feels painfully unsophisticated.

At least for debug purposes, I propose the following pure-Ruby workaround. The Circle object mimics an RMagick image by implementing #columns, #rows and #to_blob. I think this is a pretty nice way to procedurally fake primitives without pulling another library in :) With the new Image#save, you can even cache the results.

(No anti-aliasing etc., but at least the "Gosu::Image from RMagick" interface is now documented somewhere. ;))
Parent - - By ippa Date 2010-11-04 15:29
Chingu got this lil draw_circle gfxhelper (constructed by shawn24):

.. prob. not the best performence but works well.
Parent - By jlnr (dev) Date 2010-11-04 16:35
In turn, it has no associated loading/preparation time. It's all about trade-offs with these annoying circles. ;)
Up Topic Gosu / Gosu Exchange / Where is draw_circle? / Procedural shapes

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill