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


C++ Simple_window::y_max方法代码示例

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


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

示例1: 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

示例2: test_grid

void test_grid(Simple_window &win) {
    static const int x_size {win.x_max()}, y_size {win.y_max()};
    constexpr int x_grid {80}, 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});
    for (int y {y_grid}; y < y_size; y += y_grid)
        grid.add(Point{0, y}, Point{x_size, y});
    grid.set_color(Color::yellow);
    grid.set_style(Line_style{Line_style::dash, 2});

    win.attach(grid);
    win.wait_for_button();
}
开发者ID:Tigrolik,项目名称:git_workspace,代码行数:14,代码来源:main.cpp

示例3: drill

void drill(Simple_window &win) {
    static const int x_size {win.x_max()}, y_size {win.y_max()};
    constexpr int num_x {8}, num_y {8};
    const int x_grid {x_size / num_x}, y_grid {y_size / num_y};
    Lines grid;
    for (int x {x_grid}; x < x_size; x += x_grid)
        grid.add(Point{x, 0}, Point{x, y_size});
    for (int y {y_grid}; y < y_size; y += y_grid)
        grid.add(Point{0, y}, Point{x_size, y});
    Vector_ref<Rectangle> vr;
    for (int i {0}; i < num_x; ++i) {
        vr.push_back(new Rectangle{Point{x_grid * i, y_grid * i},
                x_grid, y_grid});
        vr[vr.size() - 1].set_fill_color(Color::red);
        win.attach(vr[vr.size() - 1]);
    }
    grid.set_color(Color::yellow);
    grid.set_style(Line_style{Line_style::dash, 2});
    win.attach(grid);

    Image img1 {Point{x_grid * 2, 0}, "../snow_cpp.gif", Suffix::gif};
    img1.set_mask(Point{0, 0}, 200, 200);
    Image img2 {Point{0, y_grid * 4}, "../snow_cpp.gif", Suffix::gif};
    img2.set_mask(Point{0, 0}, 200, 200);
    Image img3 {Point{x_grid * 3, y_grid * 6}, "../snow_cpp.gif", Suffix::gif};
    img3.set_mask(Point{0, 0}, 200, 200);

    win.attach(img1);
    win.attach(img2);
    win.attach(img3);

    for (int i {0}; i < num_x; ++i) {
        for (int j {0}; j < num_y; ++j) {
            Image img4 {Point{x_grid * i, y_grid * j}, "img.jpg", Suffix::jpg};
            img4.set_mask(Point{0, 0}, 100, 100);
            win.attach(img4);
            win.wait_for_button();
        }
    }

    win.wait_for_button();
}
开发者ID:Tigrolik,项目名称:git_workspace,代码行数:42,代码来源:main.cpp


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