当前位置: 首页>>代码示例>>C++>>正文


C++ Simple_window类代码示例

本文整理汇总了C++中Simple_window的典型用法代码示例。如果您正苦于以下问题:C++ Simple_window类的具体用法?C++ Simple_window怎么用?C++ Simple_window使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Simple_window类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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();
}
开发者ID:Kijjakarn,项目名称:Stroustrup-PPP2-Exercises,代码行数:31,代码来源:ch12_ex5.cpp

示例2: 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();
}
开发者ID:Tigrolik,项目名称:git_workspace,代码行数:27,代码来源:main.cpp

示例3: main

int main()
{
  Point t1 {100,100};
  Simple_window win {t1, 600, 400, "My window"};
  
  win.wait_for_button();
}
开发者ID:fanqo,项目名称:PPPCpp,代码行数:7,代码来源:01.cpp

示例4: 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!

}
开发者ID:tol60,项目名称:STROUSTRUP_C11,代码行数:29,代码来源:ch13.5_LineStile.C

示例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();
}
开发者ID:Kijjakarn,项目名称:Stroustrup-PPP2-Exercises,代码行数:25,代码来源:ch14_ex9.cpp

示例6: 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!

}
开发者ID:tol60,项目名称:STROUSTRUP_C11,代码行数:26,代码来源:ch13.6_OpenPolyline.C

示例7: 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;
	}
}
开发者ID:Kijjakarn,项目名称:Stroustrup-PPP2-Exercises,代码行数:27,代码来源:ch13_ex12.cpp

示例8: 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!


}
开发者ID:tol60,项目名称:STROUSTRUP_C11,代码行数:34,代码来源:ch13.13_Ellipse.C

示例9: 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();
}
开发者ID:thelastpolaris,项目名称:Programming-Principles-and-Practice-Using-C-,代码行数:9,代码来源:ex2.cpp

示例10: 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();
}
开发者ID:thelastpolaris,项目名称:Programming-Principles-and-Practice-Using-C-,代码行数:9,代码来源:ex12.cpp

示例11: 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();
}
开发者ID:Tigrolik,项目名称:git_workspace,代码行数:10,代码来源:main.cpp

示例12: 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();
}
开发者ID:fanqo,项目名称:PPPCpp,代码行数:34,代码来源:11.cpp

示例13: main

int main()
{
	using namespace Graph_lib;
	Simple_window win {Point{100, 100}, 800, 600, "Exercise 19"};
	Star s {Point{300, 300}, 100, 20, 8, true};
	s.set_color(Color::green);
	s.set_fill_color(Color::white);
	win.attach(s);

	win.wait_for_button();
}
开发者ID:Kijjakarn,项目名称:Stroustrup-PPP2-Exercises,代码行数:11,代码来源:ch13_ex19.cpp

示例14: main

int main()
{
  using namespace Graph_lib;

  Point tl {100, 100};

  Simple_window win {tl, 600, 400, "My window"};

  win.wait_for_button();// give control to the display engine and thus
                        // display the window on screen 
}
开发者ID:Cocu23,项目名称:cpp-co-learning,代码行数:11,代码来源:firstexample.cpp

示例15: main

int main()
{
    Simple_window win {Point{100, 100}, 600, 600, "Exercise 1"};

    Arc a {Point{200, 200}, 50, 40, 0, 70};
    a.set_color(Color::red);
    a.set_fill_color(Color::white);
    win.attach(a);

    win.wait_for_button();
}
开发者ID:Kijjakarn,项目名称:Stroustrup-PPP2-Exercises,代码行数:11,代码来源:ch13_ex1.cpp


注:本文中的Simple_window类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。