ultimatepp/examples/TimerAnimate/main.cpp
cxl 8f5af08a9d .examples
git-svn-id: svn://ultimatepp.org/upp/trunk@14048 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2020-02-20 09:36:45 +00:00

43 lines
798 B
C++

#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct MyApp : TopWindow {
double phase = 0;
TimeCallback tm;
void PaintCircle(Draw& w, int sc) {
sc /= 2;
int pp = int(phase * sc);
w.DrawEllipse(int(sc - pp), int(sc - pp), int(2 * pp), int(2 * pp), SBlue());
}
virtual void Paint(Draw& w) {
Size sz = GetSize();
w.DrawRect(sz, SWhite());
PaintCircle(w, min(sz.cx, sz.cy));
}
MyApp() {
tm.Set(-10, [=] {
phase = msecs() % 2000 / 2000.0;
for(int pass = 0; pass < 2; pass++) {
int sc = pass ? 32 : 16;
ImageDraw iw(sc, sc);
iw.DrawRect(0, 0, sc, sc, White());
PaintCircle(iw, sc);
if(pass)
LargeIcon(iw);
else
Icon(iw);
}
Refresh();
});
}
};
GUI_APP_MAIN
{
MyApp().Run();
}