10 #include "bcwindowbase.h"
12 #include "bcsignals.h"
19 /*c++ -g -I/mnt1/build5/cinelerra-5.1/guicast x.C \
20 /mnt1/build5/cinelerra-5.1/guicast/x86_64/libguicast.a \
21 -DHAVE_GL -DHAVE_XFT -I/usr/include/freetype2 -lGL -lX11 -lXext \
22 -lXinerama -lXv -lpng -lfontconfig -lfreetype -lXft -pthread */
24 void wheel(VFrame *dst, float cx, float cy, float rad, int bg_color)
26 int color_model = dst->get_color_model();
27 int bpp = BC_CModels::calculate_pixelsize(color_model);
28 int bg_r = (bg_color>>16) & 0xff;
29 int bg_g = (bg_color>> 8) & 0xff;
30 int bg_b = (bg_color>> 0) & 0xff;
31 int w = dst->get_w(), h = dst->get_h();
32 unsigned char **rows = dst->get_rows();
33 for( int y=0; y<h; ++y ) {
34 unsigned char *row = rows[y];
35 for( int x=0; x<w; ++x,row+=bpp ) {
36 int dx = cx-x, dy = cy-y;
37 float d = sqrt(dx*dx + dy*dy);
40 float h = TO_DEG(atan2(cx-x, cy-y));
42 float s = d / rad, v = 255;
43 HSV::hsv_to_rgb(r, g, b, h, s, v);
46 r = bg_r; g = bg_g; b = bg_b;
48 row[0] = r; row[1] = g; row[2] = b;
53 class TestWindowGUI : public BC_Window
59 TestWindowGUI(int x, int y, int w, int h);
62 void draw(int ww, int wh) {
64 wfrm = new VFrame(ww,wh,BC_RGB888);
65 float wr = bmin(ww, wh)/2.25;
66 int bg = get_bg_color();
67 wheel(wfrm, ww/2,wh/2, wr, bg);
71 int resize_event(int w, int h) {
72 BC_WindowBase::resize_event(w, h);
79 TestWindowGUI(int x, int y, int w, int h)
80 : BC_Window("test", x,y, w,h, 100,100)
83 set_bg_color(0x885533);
96 class TestWindow : public Thread
100 TestWindow(int x, int y, int w, int h)
102 gui = new TestWindowGUI(x,y, w,h);
103 gui->lock_window("init");
104 gui->resize_event(w, h);
105 gui->unlock_window();
108 ~TestWindow() { delete gui; }
109 void run() { gui->run_window(); }
110 void close_window() { gui->close(0); }
114 int main(int ac, char **av)
117 signals.initialize();
118 BC_WindowBase::init_resources(1.);
119 TestWindow test_window(100, 100, 256, 256);