Ticket #12937: gradienttest.cpp

File gradienttest.cpp, 1.3 KB (added by KapiX, 8 years ago)

Test program

Line 
1#include <Application.h>
2#include <InterfaceKit.h>
3#include <SupportKit.h>
4#include <GroupLayout.h>
5#include <GradientRadial.h>
6
7class View : public BView {
8public:
9 View() : BView("gradients", B_WILL_DRAW) {
10 }
11
12 void Draw(BRect) {
13 BGradientRadial g(BPoint(50, 50), 50.0);
14 g.AddColor((rgb_color) { 0, 0, 0, 255 }, 255.0);
15 g.AddColor((rgb_color) { 255, 255, 255, 0 }, 0.0);
16 SetHighColor(0, 0, 0);
17 BeginLayer(255);
18 // 1, 1
19 FillRect(BRect(10, 10, 90, 90));
20 // 2, 1
21 FillRect(BRect(100, 10, 190, 90), g);
22 EndLayer();
23 BeginLayer(100);
24 // 1, 2
25 FillRect(BRect(10, 100, 90, 190));
26 // 2, 2
27 FillRect(BRect(100, 100, 190, 190), g);
28 EndLayer();
29 }
30};
31
32class App : public BApplication {
33public:
34 App() : BApplication("application/gradtest") {
35 BRect frame(100, 100, 300, 300);
36
37 BWindow* wnd = new BWindow(frame, "gradients", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE);
38 View* view = new View();
39
40 BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 0);
41 wnd->SetLayout(layout);
42 layout->AddView(view);
43 wnd->Show();
44 }
45};
46
47int main() {
48 App* app = new App();
49 app->Run();
50 delete app;
51 return 0;
52}