本文整理汇总了C++中Stroke::get_dab_count方法的典型用法代码示例。如果您正苦于以下问题:C++ Stroke::get_dab_count方法的具体用法?C++ Stroke::get_dab_count怎么用?C++ Stroke::get_dab_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stroke
的用法示例。
在下文中一共展示了Stroke::get_dab_count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void draw(const Stroke& stroke, CL_GraphicContext* gc)
{
CL_OpenGLState state(CL_Display::get_current_window()->get_gc());
state.set_active();
state.setup_2d();
CL_Color color = DrawerProperties::current()->get_color();
const Stroke::Dabs& dabs = stroke.get_interpolated_dabs(DrawerProperties::current()->get_spacing(),
DrawerProperties::current()->get_spacing());
if (dabs.size() >= 2)
{
std::vector<CL_Pointf> normals;
if (stroke.get_dab_count() == 2)
{
normals.push_back(CL_Pointf(1.0f, 1.0f));
normals.push_back(CL_Pointf(1.0f, 1.0f));
}
else if (stroke.get_dab_count() >= 3)
{
for(Stroke::Dabs::size_type i = 0; i < dabs.size()-1; ++i)
{
CL_Pointf normal((dabs[i].pos.y - dabs[i+1].pos.y),
-(dabs[i].pos.x - dabs[i+1].pos.x));
float length = sqrt(normal.x * normal.x + normal.y * normal.y);
normal.x /= length;
normal.y /= length;
normals.push_back(normal);
}
normals.push_back(CL_Pointf(1.0f, 1.0f));
}
float len = DrawerProperties::current()->get_size() * 8.0f;
float len2 = DrawerProperties::current()->get_size() * 16.0f;
glEnable(GL_BLEND);
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glBegin(GL_QUAD_STRIP);
for(unsigned int j = 0; j < dabs.size()-2; ++j)
{
glColor4ub(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha());
glVertex2f(dabs[j].pos.x + normals[j].x * len,
dabs[j].pos.y + normals[j].y * len);
glColor4ub(color.get_red(), color.get_green(), color.get_blue(), 0);
glVertex2f(dabs[j].pos.x + normals[j].x * len2,
dabs[j].pos.y + normals[j].y * len2);
}
glEnd();
glBegin(GL_QUAD_STRIP);
for(unsigned int j = 0; j < dabs.size()-2; ++j)
{
glColor4ub(color.get_red(), color.get_green(), color.get_blue(), 0);
glVertex2f(dabs[j].pos.x - normals[j].x * len2,
dabs[j].pos.y - normals[j].y * len2);
glColor4ub(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha());
glVertex2f(dabs[j].pos.x - normals[j].x * len,
dabs[j].pos.y - normals[j].y * len);
}
glEnd();
glBegin(GL_QUAD_STRIP);
glColor4ub(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha());
for(unsigned int j = 0; j < dabs.size()-2; ++j)
{
glVertex2f(dabs[j].pos.x + normals[j].x * len,
dabs[j].pos.y + normals[j].y * len);
glVertex2f(dabs[j].pos.x - normals[j].x * len,
dabs[j].pos.y - normals[j].y * len);
}
glEnd();
}
}