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


C++ GRectangle::getX方法代码示例

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


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

示例1: getBounds

// JL rewrote to handle transformed case
GRectangle GCompound::getBounds() const {
   double x1, y1, x2, y2;
   x1 = 1E20;
   x2 = -1E20;
   y1 = 1E20;
   y2 = -1E20;
   for (int i = 0; i < contents.size(); i++) {
      GRectangle bounds = contents.get(i)->getBounds();
      GPoint vertices[4];
      vertices[0] = GPoint(bounds.getX(), bounds.getY());
      vertices[1] = GPoint(bounds.getX() + bounds.getWidth(), bounds.getY());
      vertices[2] = GPoint(bounds.getX(), bounds.getY() + bounds.getHeight());
      vertices[3] = GPoint(bounds.getX()+ bounds.getWidth(), bounds.getY() + bounds.getHeight());
      if (transformed) {
          for (int j = 0; j < 4; j++)
             vertices[j] = matrix.image(vertices[j]);
      }
      for (int j = 0; j < 4; j++) {
          double x = vertices[j].getX();
          double y = vertices[j].getY();
          if (x < x1) x1 = x;
          if (y < y1) y1 = y;
          if (x > x2) x2 = x;
          if (y > y2) y2 = y;
      }
   }
   return GRectangle(x + x1, y + y1, x2 - x1, y2 - y1);
}
开发者ID:zmukwa,项目名称:stanford-whittier-cpplib,代码行数:29,代码来源:gobjects.cpp

示例2: getBounds

GRectangle GCompound::getBounds() const {
    if (transformed) return pp->getBounds(this);
    double xMin = +1E20;
    double yMin = +1E20;
    double xMax = -1E20;
    double yMax = -1E20;
    for (int i = 0; i < contents.size(); i++) {
        GRectangle bounds = contents.get(i)->getBounds();
        xMin = min(xMin, bounds.getX());
        yMin = min(yMin, bounds.getY());
        xMax = max(xMax, bounds.getX());
        yMin = min(yMax, bounds.getY());
    }
    return GRectangle(xMin, yMin, xMax - xMin, yMax - yMin);
}
开发者ID:rahulratheesh,项目名称:datastructures,代码行数:15,代码来源:gobjects.cpp

示例3: getBounds

GRectangle GCompound::getBounds() const {
    if (transformed) {
        return stanfordcpplib::getPlatform()->gobject_getBounds(this);
    }
    double xMin = +1E20;
    double yMin = +1E20;
    double xMax = -1E20;
    double yMax = -1E20;
    for (int i = 0; i < contents.size(); i++) {
        GRectangle bounds = contents.get(i)->getBounds();
        xMin = std::min(xMin, bounds.getX());
        yMin = std::min(yMin, bounds.getY());
        xMax = std::max(xMax, bounds.getX());
        yMin = std::max(yMax, bounds.getY());   // JL BUGFIX 2016/10/11
    }
    // JL BUGFIX: shifted anchor point
    return GRectangle(xMin + getX(), yMin + getY(), xMax - xMin, yMax - yMin);
}
开发者ID:jlutgen,项目名称:stanford-cpp-library,代码行数:18,代码来源:gobjects.cpp

示例4: setFrameRectangle

void GArc::setFrameRectangle(const GRectangle& rect) {
    setFrameRectangle(rect.getX(), rect.getY(), rect.getWidth(),
                      rect.getHeight());
}
开发者ID:jlutgen,项目名称:stanford-cpp-library,代码行数:4,代码来源:gobjects.cpp

示例5: setBounds

void GOval::setBounds(const GRectangle& bounds) {
    setLocation(bounds.getX(), bounds.getY());
    setSize(bounds.getWidth(), bounds.getHeight());
}
开发者ID:jlutgen,项目名称:stanford-cpp-library,代码行数:4,代码来源:gobjects.cpp

示例6: repaintRegion

void GDrawingSurface::repaintRegion(const GRectangle& bounds) {
    repaintRegion((int) bounds.getX(), (int) bounds.getY(),
                  (int) bounds.getWidth(), (int) bounds.getHeight());
}
开发者ID:stepp,项目名称:stanford-cpp-library,代码行数:4,代码来源:gdrawingsurface.cpp

示例7: test_contains_and_getBounds


//.........这里部分代码省略.........
    ch->addItem("image");
    ch->addItem("compound");
    ch->addItem("button");
    ch->setSelectedItem("rectangle");
    currObj = rect;

    GButton *endButton = new GButton("End test");
    GButton *fillButton = new GButton("Auto-fill");
    GButton *rotateButton = new GButton("Rotate");
    GButton *scaleButton = new GButton("Scale");

    GCheckBox *compCheckbox = new GCheckBox("compounds");
    compCheckbox->setActionCommand("compounds");
    gw->addToRegion(compCheckbox, "north");
    gw->addToRegion(ch, "north");
    gw->addToRegion(rotateButton, "north");
    gw->addToRegion(scaleButton, "north");
    gw->addToRegion(fillButton, "north");
    gw->addToRegion(endButton, "north");

    while (true) {
        GEvent e = waitForEvent(ACTION_EVENT | MOUSE_EVENT);
        if (!e.isValid())
            continue;
        if (e.getEventClass() == ACTION_EVENT) {
            if (((GActionEvent) e).getActionCommand() == "End test")
                break;
            if (((GActionEvent) e).getActionCommand() == "compounds") {
                bgRect1->setVisible(compCheckbox->isSelected());
                useCompounds = compCheckbox->isSelected();
            }
            if (((GActionEvent) e).getActionCommand() == "Testo") {
                GPoint pt = button->getLocation();
                button->setLocation(pt.getX()-button->getWidth()-10, pt.getY());
                pause(1000);
                button->setLocation(pt);
            }
            if (((GActionEvent) e).getActionCommand() == "Auto-fill") {
                GRectangle bds = currObj->getBounds();
                int xmin = bds.getX();
                int ymin = bds.getY();
                int xmax = bds.getX() + bds.getWidth();
                int ymax = bds.getY() + bds.getHeight();
                int dx = useCompounds ? comp1->getX(): 0;
                int dy = useCompounds ? comp1->getY(): 0;
                for (int y = ymin; y < ymax; y+=1)
                    for (int x = xmin; x < xmax; x+=1) {
                        if (currObj->contains(x, y)) {
                            gw->setColor("red");
                            gw->fillOval(x + dx, y + dy, 1, 1);
                        } else {
                            gw->setColor("green");
                            gw->fillOval(x + dx, y + dy, 1, 1);
                        }
                    }
            }

            if (((GActionEvent) e).getActionCommand() == "Rotate") {
                currObj->rotate(45);
                if (useCompounds) {
                    bgRect1->setBounds(comp1->getBounds());
                }
            }
            if (((GActionEvent) e).getActionCommand() == "Scale") {
                currObj->scale(1.2, 0.8);
                if (useCompounds) {
开发者ID:zmukwa,项目名称:stanford-whittier-cpplib,代码行数:67,代码来源:gobjects-dialog-console-tests.cpp

示例8: fillRect

void GDrawingSurface::fillRect(const GRectangle& bounds) {
    fillRect(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight());
}
开发者ID:stepp,项目名称:stanford-cpp-library,代码行数:3,代码来源:gdrawingsurface.cpp

示例9: drawOval

void GDrawingSurface::drawOval(const GRectangle& bounds) {
    drawOval(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight());
}
开发者ID:stepp,项目名称:stanford-cpp-library,代码行数:3,代码来源:gdrawingsurface.cpp

示例10: setBounds

void GInteractor::setBounds(const GRectangle& rect) {
    setLocation(rect.getX(), rect.getY());
    setSize(rect.getWidth(), rect.getHeight());
}
开发者ID:chuzui,项目名称:courses,代码行数:4,代码来源:ginteractors.cpp

示例11: fillOval

void GWindow::fillOval(const GRectangle & bounds) {
    if (isOpen()) {
        fillOval(bounds.getX(), bounds.getY(), bounds.getWidth(),
                 bounds.getHeight());
    }
}
开发者ID:MoonighT,项目名称:CS106B,代码行数:6,代码来源:gwindow.cpp

示例12: drawRect

void GWindow::drawRect(const GRectangle & bounds) {
    if (isOpen()) {
        drawRect(bounds.getX(), bounds.getY(), bounds.getWidth(),
                 bounds.getHeight());
    }
}
开发者ID:MoonighT,项目名称:CS106B,代码行数:6,代码来源:gwindow.cpp


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