--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/8bb9ef73-398a-4ca1-ae1d-e248952b6277n%40googlegroups.com.
On 7/15/24 07:34, Gonzalo Garramuño wrote:
I am interested in drawing things with transparency in FLTK, ideally on all platforms. I would like to draw both widgets and shapes.
Hmm, I missed this entire thread because for some reason all
of it was caught by gmail's spam catcher.
Since PNG and SVG supports alpha channels, I've played around
with using Fl_PNG_Image and Fl_SVG_Image to render
graphics/widgets to get smooth antialiased overlays.. some
examples:
What's demonstrated above:[1] Alpha Blending with PNG files
https://www.seriss.com/people/erco/fltk/#AlphaBlend[2] A multicolored bargraph widget
[3] A commercial aircraft altimeter FLTK widget
https://www.seriss.com/people/erco/fltk/#MultiColorBarGraph
https://www.seriss.com/people/erco/fltk/#Altimeter
[4] A working analog Simplex clock using nanoSVG
https://www.seriss.com/people/erco/fltk/#FLTK-Simplex-Clock
[1] PNG files with alpha channel (transparency) lines drawn in GIMP are loaded and overlaid, showing how the alpha channels allow simple smooth compositing.
[2] shows how to make a widget that takes advantage of transparency to render antialiased bar graphs by drawing small PNG images to combine into graphs, similar to the techniques one might use with HTML or with sprites.
[3] shows an attempt at realism to render an analog mechanical altimeter, again using PNGs with transparency to handle shadows and compositing.
[4] uses SVG to render antialiased lines for an analog clock. Since SVG files are basically ASCII commands kinda/sorta similar to PostScript (but without the procedural programming features), the SVG data can be regenerated easily using sprintf() to replace floating point variable values, such as floating point rotation degrees, offsets, opacities, etc.
Perhaps someday fl_draw_image()'s depth argument can be set to 4 to allow for an alpha channel for pixel rendering, but my read of the 1.4.x docs seems to indicate a depth of 4 or above, the "extra" bytes have to be zero, so apparently alpha is not yet supported in fl_draw_image().