Hi!

Oh I didn't know that drawing outside Widget::draw() is not supported. 
OK, here is what I want to achieve with this:

I want to make a simple animation when I click on a Button.

// Callback of the Button:
void WndMain::cbVisualRun(fltk::Widget* w)
{
        //...
        int hits = m_Field->VisualizeHits(animsize, y1, y2);
        // ...
}

m_Fields is a pointer to my subclass of fltk::Widget. (cDrawField)
The class represents an area with points laying on it.
cDrawfield::draw() first calls fltk::Widget::draw() to clear the 
background and show the box around and then draws a lot of circles into 
the widget. Every "frame" in the animation has this background. The 
animation should (firstly) be a simple line that runs from one point in 
the widget to another point. When the line reaches the end point it 
should stop.
Possibly this animation seems to be a bit stupid, actually it is a bit 
more complicated but that does not change the problem so I tried to keep 
it as simple as possible.

I thought using draw() to draw the backgound of the widget and the line 
in front in the VisualizeHits function would be a good idea, but it 
seems not to :)

// function that displays the animation
int cDrawField::VisualizeHits(float Width, float yBegin, float yEnd)
{
        // ...
        fltk::push_matrix();
        SetMatrix();

        // ...
        float i = 0;
        while(i <= 1.0f)
        {
                sVector p = pos + dir * i;
                sLine l = BuildLine(p-orth, p+orth);
                
                fltk::push_matrix();
                // Draw background
                redraw();
                fltk::flush();
                fltk::pop_matrix();

                // Draw the animated line
                fltk::setcolor(fltk::BLACK);
                fltk::drawline(l.Start.x, l.Start.y, l.End.x, l.End.y);

                i += step;
        }


        fltk::pop_matrix();
        return hits.size();
}

In general, I do not really know, how to make a simple animation. Of 
course I should add time measurement so that it runs on same speed on 
all pcs.
But the prog freezes as long as the animation runs (I could undo this 
with fltk::check() or sth).

So how should one do a simple animation in fltk? possibly I could also 
use OpenGL to disply it, but that seems a bit overkill to me for this 
simple 2D-animation :)
Or would it be a good idea not to have a loop but a fltk::add_timeout 
and fltk::repeat_timeout for simple animations?

Hm, much text, I hope you can help me nethertheless :)
Greetings, Maxi
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to