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


C++ BezierCurve::getNumControlPoints方法代码示例

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


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

示例1: handleEvent

void CurveEditor::handleEvent(Event *event) {

    if(mode == MODE_ADD) {
        if(event->getDispatcher() == bg) {
            if(event->getEventCode() == InputEvent::EVENT_MOUSEDOWN) {
                InputEvent *inputEvent = (InputEvent*)event;
                if(selectedCurve) {
                    Vector2 pos = inputEvent->mousePosition;
                    pos.x = pos.x/610.0;
                    pos.y = 1.0-(pos.y/254.0);

                    BezierCurve *targetCurve = selectedCurve->targetCurve;

                    bool done = false;
                    for(int i=0; i < targetCurve->getNumControlPoints(); i++) {
                        if(pos.x < targetCurve->getControlPoint(i)->p2.x && !done) {
                            targetCurve->insertPoint = targetCurve->getControlPoint(i);
                            done = true;
                        }
                    }

                    targetCurve->addControlPoint2dWithHandles(pos.x-0.1, pos.y, pos.x, pos.y, pos.x + 0.1, pos.y);
                    selectedCurve->updatePoints();
                    selectedCurve->updateCurve();
                }
            }
        }
    }

    if(event->getDispatcher() == selectButton) {
        selectorImage->setPosition(selectButton->getPosition().x - 4, selectButton->getPosition().y - 4);
        setMode(0);
    }

    if(event->getDispatcher() == addButton) {
        selectorImage->setPosition(addButton->getPosition().x - 4, addButton->getPosition().y - 4);
        setMode(1);
    }

    if(event->getDispatcher() == removeButton) {
        selectorImage->setPosition(removeButton->getPosition().x - 4, removeButton->getPosition().y - 4);
        setMode(2);
    }

    if(event->getDispatcher() == treeContainer->getRootNode()) {
        if(event->getEventCode() == UITreeEvent::SELECTED_EVENT) {
            EditCurve *curve = (EditCurve *)treeContainer->getRootNode()->getSelectedNode()->getUserData();
            if(selectedCurve) {
                selectedCurve->Deactivate();
            }
            selectedCurve = curve;
            if(curve) {
                curve->Activate();
                curve->setMode(mode);
            }
        }
    }

    UIWindow::handleEvent(event);
}
开发者ID:reffle,项目名称:Polycode,代码行数:60,代码来源:PolycodeFrame.cpp


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