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


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

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


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

示例2: w_BezierCurve_getControlPoint

int w_BezierCurve_getControlPoint(lua_State *L)
{
	BezierCurve *curve = luax_checkbeziercurve(L, 1);
	int idx = (int) luaL_checknumber(L, 2);

	if (idx > 0) // 1-indexing
		idx--;

	luax_catchexcept(L, [&]() {
		Vector v = curve->getControlPoint(idx);
		lua_pushnumber(L, v.x);
		lua_pushnumber(L, v.y);
	});

	return 2;
}
开发者ID:AntonioModer,项目名称:LoveMore,代码行数:16,代码来源:wrap_BezierCurve.cpp

示例3: drawBezierCurve

void ViewportPainter::drawBezierCurve(BezierCurve & curve) {
    Point2D * beginPoint = curve.getBeginPoint();
    Point2D * endPoint = curve.getEndPoint();
    Point2D * controlPoint = curve.getControlPoint();
    
    // Plus tard dessin de la courbe :
    // this->drawArc(beginPoint->x(),beginPoint->y(),endPoint->x()-beginPoint->x(),endPoint->y()-beginPoint->y(),0*16,360*16);
      
    this->drawLine(beginPoint->x(),beginPoint->y(),endPoint->x(),endPoint->y());
    
    // Dessin du vecteur
    /*this->setPen(QColor(255, 120, 0, 255));
    this->drawPoint(*controlPoint);
    this->drawLine(beginPoint->x(),beginPoint->y(),controlPoint->x(),controlPoint->y());
    // Dessiner la fleche du vecteur
    //this->drawLine(controlPoint->x(),controlPoint->y());
    //this->drawLine(controlPoint->x(),controlPoint->y());
    this->setPen(QColor(0, 0, 0, 255));*/
}
开发者ID:PaulGrandperrin,项目名称:demo-opengl-shootemup,代码行数:19,代码来源:viewportPainter.cpp


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