首页 > 代码库 > 基于TouchVG和muParser实现了函数图像绘图

基于TouchVG和muParser实现了函数图像绘图

用了三天基于TouchVG和muParser实现了iOS上的函数图像绘图,绘图代码(跨平台)如下:

static void createFuncShapes(MgView *view) {
    MgShape *sp = view->createShapeCtx(MgFuncShape::Type());
    ((MgFuncShape*)sp->shape())->setExpr("10*t,10*ln(t*t+1)*sin(t)", MgFuncShape::kExprXY,
                                         -6, 6, 0.1f);
    view->shapes()->addShapeDirect(sp);
    view->regenAppend(sp->getID());

    sp = view->createShapeCtx(MgFuncShape::Type());
    ((MgFuncShape*)sp->shape())->setExpr("10*t,10*exp(t)-t*sin(t)*cos(t)", MgFuncShape::kExprXY,
                                         -6, 6, 0.1f);
    view->shapes()->addShapeDirect(sp);
    view->regenAppend(sp->getID());

    view->setCommand("line", "{‘points‘:[-70,0,70,0,0,-40,0,40]}");
}

绘图效果:

func

基于TouchVG和muParser实现了函数图像绘图