On 10/09/17 12:25,
holm.h...@gmail.com wrote:
>
> Hello,
>
> Calling for ideas : Lines drawn to illustrate wind on
https://www.windy.com/ seems to illustrate
> the flowfield very well.
>
> Any idea how to reproduce such an effect in fltk ?
Several ideas come to mind:
a) If they're not transparent (and just have a fading trail of color),
then you can probably just use fl_point() or small fl_rectf()'s in a grayscale,
along with an Fl_Double_Window.
b) Or, you could try to render the "wind" directly into an rgba image, where the image
is cleared to 0,0,0,0, and then draw the wind lines over the map in white, and just
trail off the opacity channel, e.g. rgba=255,255,255,n, where n varies from 255 to 0
to implement the "fade".
c) Or, you could use opengl (which is probably what they're doing, webgl in their case)
and do fully transparent drawing.
The benefit of techniques (a) and (b) are to /avoid/ opengl, which can sometimes
be picky/weird, or not well supported on some graphics hardware.
Opengl technique (c) should be easier code wise, letting opengl give you access
to opacity rendering (not available with option (a)), and without having to make
your own line renderer code (option (b)), though I imagine that's trivial since
you probably need to render the 'trails' of wind as individual pixels or small boxes.
> Seems like the lines is transparent. Would it be an idea to have a bunch of one-pixel-size images with different transparency and to draw these instead of the line ?? would be slow solution ?
That's perhaps another idea, though might be a bit of overhead to have to redraw
an image all over. But it might be quick enough not to matter.. not sure!
I think option (b) might be better; you allocate an entire alpha image over the map,
and just set the pixels you want in RGBA, and then render that entire image over the
map or whatever the fixed background is.