本文整理汇总了C++中Path2D::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ Path2D::resize方法的具体用法?C++ Path2D::resize怎么用?C++ Path2D::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path2D
的用法示例。
在下文中一共展示了Path2D::resize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
DollarRecognizer::Path2D CTemplateRecorder::OutputTriangleCC()
{
Path2D path;
path.resize(32);
//设置3个关键点,每条边长度为100,左下角在(0,0)
/* path[0].x = 0.0f;
path[0].y = 0.0f;
//右下角则为 (100,0)
path[10].x = 100.0f;
path[10].y = 0.0f;
//计算上顶点
kmVec2 vec;
kmVec2Fill(&vec,100.0f,0.0f);
//逆时针旋转60度则为上顶点
kmVec2 upPoint;
kmVec2 center;
kmVec2Fill(¢er,0.0f,0.0f);
kmVec2RotateBy(&upPoint,&vec,60.0f,¢er);
path[21].x = upPoint.x;
path[21].y = upPoint.y;
//底边插入9个点
kmVec2 dir;
dir.x = (path[10].x - path[0].x)/10.0f;
dir.y = (path[10].y - path[0].y)/10.0f;
for(int i =1;i<10;++i)
{
path[i].x = path[0].x + i*dir.x;
path[i].y = path[0].y + i*dir.y;
}
//右边插入10个点
dir.x = (path[21].x - path[10].x)/11.0f;
dir.y = (path[21].y - path[10].y)/11.0f;
for(int i =11;i<21;++i)
{
int j = i - 10;
path[i].x = path[10].x + j*dir.x;
path[i].y = path[10].y + j*dir.y;
}
//在左侧边插入10个点
dir.x = (path[0].x - path[21].x)/11.0f;
dir.y = (path[0].y - path[21].y)/11.0f;
for(int i =22;i<32;++i)
{
int j = i - 21;
path[i].x = path[21].x + j*dir.x;
path[i].y = path[21].y + j*dir.y;
} */
return path;
}
示例2: OutputRectange
//use 40 point
Path2D CTemplateRecorder::OutputRectange()
{
Path2D path;
path.resize(40);
int curIndex = 0;
//left edge
//four points
//left bottom 0,0
//left top 0,100
//right top 100,100
//right bottom 100,0
for(int i=0;i<10;++i) //left bottom to left top
{
path[curIndex].x = 0.0f;
path[curIndex].y = i*10.0f;
curIndex ++;
}
for(int i=0;i<10;++i) //left top to right top
{
path[curIndex].x = i*10.0f;
path[curIndex].y = 100.0f;
curIndex ++;
}
for(int i=0;i<10;++i) //right top to right bottom
{
path[curIndex].x = 100.0f;
path[curIndex].y = 100.0f - i*10.0f;
curIndex ++;
}
for(int i=0;i<10;++i)
{
path[curIndex].x = 100.0f - i*10.0f;
path[curIndex].y = 0.0f;
curIndex ++;
}
return path;
}