本文整理汇总了C++中Simple_window::wait_for_button方法的典型用法代码示例。如果您正苦于以下问题:C++ Simple_window::wait_for_button方法的具体用法?C++ Simple_window::wait_for_button怎么用?C++ Simple_window::wait_for_button使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Simple_window
的用法示例。
在下文中一共展示了Simple_window::wait_for_button方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
Simple_window win {Point{100,200},600,400,"Initials"};
Graph_lib::Line a1 {Point{150,250}, Point{200,100}};
Graph_lib::Line a2 {Point{200,100}, Point{250,250}};
Graph_lib::Line a3 {Point{175,175}, Point{225,175}};
a1.set_style(Graph_lib::Line_style(Graph_lib::Line_style::solid, 4));
a2.set_style(Graph_lib::Line_style(Graph_lib::Line_style::solid, 4));
a3.set_style(Graph_lib::Line_style(Graph_lib::Line_style::solid, 4));
a1.set_color(Graph_lib::Color::dark_blue);
a2.set_color(Graph_lib::Color::dark_blue);
a3.set_color(Graph_lib::Color::dark_blue);
win.attach(a1);
win.attach(a2);
win.attach(a3);
Graph_lib::Line f1 {Point{300,100}, Point{300,250}};
Graph_lib::Line f2 {Point{300,100}, Point{400,100}};
Graph_lib::Line f3 {Point{300,175}, Point{350,175}};
f1.set_style(Graph_lib::Line_style(Graph_lib::Line_style::solid, 4));
f2.set_style(Graph_lib::Line_style(Graph_lib::Line_style::solid, 4));
f3.set_style(Graph_lib::Line_style(Graph_lib::Line_style::solid, 4));
f1.set_color(Graph_lib::Color::dark_green);
f2.set_color(Graph_lib::Color::dark_green);
f3.set_color(Graph_lib::Color::dark_green);
win.attach(f1);
win.attach(f2);
win.attach(f3);
win.wait_for_button();
}
示例2: main
int main ()
{
using namespace Graph_lib; // our graphics facilities are in Graph_lib namespace
constexpr Point pt{100,100}; // to become top left corner of window
Simple_window win {pt, 600, 400,"ch13.5_LineStile"}; // make a simple window, {top_left, width, hight, title}
const int x_size = win.x_max();
const int y_size = win.y_max();
const int x_grid = 80;
const int y_grid = 40;
Lines grid;
for (int x=x_grid; x<x_size; x+=x_grid)
grid.add(Point{x,0},Point{x,y_size}); // vertical line
for (int y=y_grid; y<y_size; y+=y_grid)
grid.add(Point{0,y},Point{x_size,y}); // horizontal line
grid.set_color(Color::red); // set color (chould affect both lines
//grid.set_style(Line_style{Line_style::dot,2});
//grid.set_style(Line_style::dashdot);
grid.set_style(Line_style{Line_style::dashdot,2});
win.attach(grid);
win.wait_for_button(); // display!
}
示例3: main
int main ()
{
using namespace Graph_lib; // our graphics facilities are in Graph_lib namespace
constexpr Point pt{100,100}; // to become top left corner of window
Simple_window win {pt, 600, 400,"ch13.13_Ellipse"}; // make a simple window, {top_left, width, hight, title}
Ellipse e1{Point{200,200},50,50};
Ellipse e2{Point{200,200},100,50};
Ellipse e3{Point{200,200},100,150};
win.attach(e1);
win.attach(e2);
win.attach(e3);
Text t{Point{50,390},"Three ellipses, with a common center, but different-size axes"};
t.set_color(Color::blue);
win.attach(t);
/*
Polygon pgn={
{100,100}, {150,200},{250,250},{300,200}
};
//pgn.add({100,250}); // this point should break it
win.attach(pgn);
*/
win.wait_for_button(); // display!
}
示例4: main
int main()
{
Simple_window win {Point{100, 100}, 800, 600, "Test mark"};
Point c {200, 450};
Ellipse e {c, 150, 100};
win.attach(e);
Axis x {Axis::x, c, 400, 10, "x axis"};
win.attach(x);
Axis y {Axis::y, c, 300, 10, "y axis"};
win.attach(y);
Mark f1 {e.focus1(), 'x'};
win.attach(f1);
Mark f2 {e.focus2(), 'x'};
win.attach(f2);
const double pi {3.14159265359};
int x1 = static_cast<int>(e.major()*cos(pi/6));
int y1 = -static_cast<int>(e.minor()*sin(pi/6));
Point p1 {Point{e.center().x + x1, e.center().y + y1}};
Mark p {p1, 'x'};
win.attach(p);
Line l1 {e.focus1(), p1};
Line l2 {e.focus2(), p1};
win.attach(l1);
win.attach(l2);
win.wait_for_button();
}
示例5: main
int main()
{
using namespace Graph_lib;
Simple_window win {Point{100, 100}, 800, 600, "Exercise 9"};
Checker ck {50};
ck.set_color(Color::green);
Circle c {Point{200, 200}, 30};
c.set_color(Color::black);
c.set_fill_color(Color::white);
Rectangle r {Point{100, 50}, 30, 40};
r.set_color(Color::red);
r.set_fill_color(Color::yellow);
ck.add_shape(c);
ck.add_shape(r);
ck.move(0, 4, 1);
ck.move(1, 5, 3);
win.attach(ck);
win.attach(ck.shape(0));
win.attach(ck.shape(1));
win.wait_for_button();
}
示例6: main
int main()
{
using namespace Graph_lib;
Simple_window win {Point{100, 100}, x_max(), y_max(), "Exercise 5"};
Rectangle r {Point{150, 150}, static_cast<int>(0.75 * x_max()),
static_cast<int>(0.75 * y_max())};
int width = pixels(0.25);
Rectangle b1 {Point{150 - width, 150 - width},
static_cast<int>(0.75 * x_max() + 2 * width), width};
Rectangle b2 {Point{150 - width, static_cast<int>(150 + 0.75 * y_max())},
static_cast<int>(0.75 * x_max() + 2 * width), width};
Rectangle b3 {Point{150 - width, 150},
width, static_cast<int>(0.75 * y_max())};
Rectangle b4 {Point{static_cast<int>(150 + 0.75 * x_max()), 150},
width, static_cast<int>(0.75 * y_max())};
r.set_fill_color(Color::white);
b1.set_fill_color(Color::red);
b2.set_fill_color(Color::red);
b3.set_fill_color(Color::red);
b4.set_fill_color(Color::red);
win.attach(r);
win.attach(b1);
win.attach(b2);
win.attach(b3);
win.attach(b4);
win.wait_for_button();
}
示例7: test_rects
void test_rects(Simple_window &win) {
Rectangle r00 {Point{150, 100}, 200, 100};
Rectangle r11 {Point{50, 50}, Point{250, 150}};
Rectangle r12 {Point{50, 150}, Point{250, 250}};
Rectangle r21 {Point{250, 50}, 200, 100};
Rectangle r22 {Point{250, 150}, 200, 100};
r00.set_color(Color::invisible);
r11.set_color(Color::invisible);
r12.set_color(Color::invisible);
r21.set_color(Color::invisible);
//r22.set_color(Color::invisible);
r00.set_fill_color(Color::yellow);
r11.set_fill_color(Color::blue);
r12.set_fill_color(Color::red);
r21.set_fill_color(Color::green);
r11.move(400, 0);
r11.set_fill_color(Color::white);
win.attach(r00);
win.attach(r11);
win.attach(r12);
win.attach(r21);
win.attach(r22);
win.put_on_top(r00);
win.wait_for_button();
}
示例8: main
int main()
{
Simple_window win {Point{100,100},800,600,"Olympic symbol"};
//Circle 1
Graph_lib::Circle o1 {Point{150,150},50};
o1.set_style(Graph_lib::Line_style(Graph_lib::Line_style::solid,2));
o1.set_color(Graph_lib::Color::blue);
win.attach(o1);
//Circle 2
Graph_lib::Circle o2 {Point{255,150},50};
o2.set_style(Graph_lib::Line_style(Graph_lib::Line_style::solid,2));
o2.set_color(Graph_lib::Color::black);
win.attach(o2);
//Circle 3
Graph_lib::Circle o3 {Point{360,150},50};
o3.set_style(Graph_lib::Line_style(Graph_lib::Line_style::solid,2));
o3.set_color(Graph_lib::Color::red);
win.attach(o3);
//Circle 4
Graph_lib::Circle o4 {Point{200,200},50};
o4.set_style(Graph_lib::Line_style(Graph_lib::Line_style::solid,2));
o4.set_color(Graph_lib::Color::yellow);
win.attach(o4);
//Circle 5
Graph_lib::Circle o5 {Point{305,200},50};
o5.set_style(Graph_lib::Line_style(Graph_lib::Line_style::solid,2));
o5.set_color(Graph_lib::Color::green);
win.attach(o5);
win.wait_for_button();
}
示例9: main
int main ()
{
using namespace Graph_lib; // our graphics facilities are in Graph_lib namespace
constexpr Point pt{100,100}; // to become top left corner of window
Simple_window win {pt, 600, 400,"ch13.6_OpenPolyline"}; // make a simple window, {top_left, width, hight, title}
// did not work:
Open_polyline opl={
{100,100}, {150,200},{250,250},{300,200}
};
win.attach(opl);
/*
Open_polyline opl_two;
opl_two.add({100,100});
opl_two.add({150,200});
opl_two.add({250,250});
opl_two.add({300,200});
win.attach(opl_two);
*/
win.wait_for_button(); // display!
}
示例10: main
int main()
{
int times;
cout << "Number of times to move around the circle: ";
cin >> times;
double radius = 150;
using namespace Graph_lib;
Simple_window win {Point{100, 100}, 800, 600, "Exercise 12"};
Circle c {Point{500, 400}, int(radius)};
c.set_color(Color::white);
c.set_fill_color(Color::green);
win.attach(c);
const double start_angle = 3.141592 * 2 / times;
double angle = 0;
for (int i = 0; i <= times; ++i) {
double x = radius * sin(angle);
double y = radius * cos(angle);
Mark m {Point{int(x + 500), int(y + 400)}, 'x'};
m.set_color(Color::red);
win.attach(m);
win.wait_for_button();
angle += start_angle;
}
}
示例11: main
int main()
{
Point t1 {100,100};
Simple_window win {t1, 600, 400, "My window"};
win.wait_for_button();
}
示例12: exercises
void exercises(Simple_window &win) {
Arc a1 {Point{200, 100}, 100, 50, 45, 210};
Ellipse c1 {Point{200, 100}, 100, 50};
a1.set_color(Color::green);
const Point p1 {500, 10}, p2 {300, 700};
Arrow arr1 {p1, p2, 30, 11}; Arrow arr2 {p2, p1};
arr1.set_color(Color::blue);
const Point p3 {400, 100}, p4 {600, 200};
Arrow arr3 {p3, p4}; Arrow arr4 {p4, p3, 30, 90};
const Point p5 {200, 500}, p6 {600, 500};
Arrow arr5 {p5, p6, 15, 17}; Arrow arr6 {p6, p5};
const Point p7 {700, 200}, p8 {700, 400};
Arrow arr7 {p7, p8}; Arrow arr8 {p8, p7, 50, 198};
arr7.set_color(Color::red);
Box b1 {Point{200, 100}, 100, 50, 0, 0};
b1.set_color(Color::red);
win.attach(b1);
Box b2 {Point{50, 400}, 200, 150, 80, 30};
b2.set_color(Color::red);
win.attach(b2);
Rectangle r {Point{50, 200}, 50, 80};
win.attach(r);
Point pnw {nw(r)}; Mark m1 {pnw, '0'}; win.attach(m1);
Point pn {n(r)}; Mark m11 {pn, '1'}; win.attach(m11);
Point pne {ne(r)}; Mark m2 {pne, '2'}; win.attach(m2);
Point ps {s(r)}; Mark m21 {ps, '3'}; win.attach(m21);
Point psw {sw(r)}; Mark m3 {psw, '4'}; win.attach(m3);
Point pw {w(r)}; Mark m31 {pw, '5'}; win.attach(m31);
Point pse {se(r)}; Mark m4 {pse, '6'}; win.attach(m4);
Point pe {e(r)}; Mark m41 {pe, '7'}; win.attach(m41);
Point pc {center(r)}; Mark m5 {pc, '9'}; win.attach(m5);
constexpr int x0 {70}, y0 {300}, rad {50};
Vector_ref<Regular_polygon> v;
for (int i {0}; i < 8; ++i) {
v.push_back(new Regular_polygon{Point{x0 + i * (rad + rad / 2),
y0 + static_cast<int>(0.5 * rad * pow(-1, i % 2))}, 6, rad});
v[v.size() - 1].set_color(Color::blue);
v[v.size() - 1].set_fill_color(Color::blue);
win.attach(v[v.size() - 1]);
}
Regular_polygon rp1 {Point{150, 600}, 6, 50};
rp1.set_color(Color::cyan);
rp1.set_fill_color(Color::magenta);
win.attach(rp1);
Regular_polygon rp2 {Point{450, 600}, 9, 70};
rp2.set_color(Color::yellow);
rp2.set_fill_color(Color::blue);
win.attach(rp2);
win.attach(c1);
win.attach(a1);
win.attach(arr1); win.attach(arr2); win.attach(arr3); win.attach(arr4);
win.attach(arr5); win.attach(arr6); win.attach(arr7); win.attach(arr8);
win.wait_for_button();
}
示例13: main
int main() {
Simple_window win {x,800,600,"Binary Tree with Triangles"};
Graph_lib::Binary_tree_triangle btt {Point{400,50}, 5, 20, "ad", Graph_lib::Color::Color_type::red};
win.attach(btt);
btt.set_label("Test","rlll");
btt.set_label("Test1","");
btt.set_label("Test2","lrr");
win.wait_for_button();
}
示例14: main
int main()
{
Simple_window win {Point{100,200},600,400,"Rectangle"};
Graph_lib::Rectangle r {Point{250,185},100, 30};
Graph_lib::Text t {Point{280, 205}, "Howdy!"};
win.attach(r);
win.attach(t);
win.wait_for_button();
}
示例15: show_palette
void show_palette(Simple_window &win) {
Vector_ref<Rectangle> vr;
for (int i {0}; i < 16; ++i)
for (int j {0}; j < 16; ++j) {
vr.push_back(new Rectangle{Point{i * 20, j * 20}, 20, 20});
vr[vr.size() - 1].set_fill_color(Color{i * 16 + j});
win.attach(vr[vr.size() - 1]);
}
win.wait_for_button();
}