示例#1
0
void DrawPath::renderRecent() const
{
    int i = getNumElements();
    if (i < 2)
        return;
    glGetError();
    glBegin (GL_LINES);
    const DrawPoint *dp = getPointerToElement(i - 1), *dp2 =
            getPointerToElement(i - 2);
    glVertex2f(dp->x(), dp->y());
    printf("%f %f\n", dp->x(), dp->y());
    glVertex2f(dp2->x(), dp2->y());
    printf("%f %f\n", dp2->x(), dp2->y());
    glEnd();
    assert(!glGetError());
}
示例#2
0
void DrawPath::render(const int rmode, bool useAlpha) const
{

    bool normal = (rmode == 0 || rmode == 1);

    if (_inMotion)
    {
        glPushMatrix();
        glTranslatef(_motion.x(), _motion.y(), 0);
    }

    if (_dFillList != 0 && _filled && normal) // fill display list
    {
        glColor4f(_fillColor.r(), _fillColor.g(), _fillColor.b(), _alpha_);
        glCallList (_dFillList);
    }

    // stroke color !
    if (_dStrokeList != 0 && normal) // stroke display list
    {
        glColor4f(_strokeColor.r(), _strokeColor.g(), _strokeColor.b(),
        _alpha_);

        glCallList (_dStrokeList);
    }
    else if (_stroke && normal)        // hertzmann stroke
    {
        glColor4f(_strokeColor.r(), _strokeColor.g(), _strokeColor.b(),
        _alpha_);
        _stroke->drawWideLineCurve();
    }
    else              // broke-ass GL rendering
    {
        glColor4f(_strokeColor.r(), _strokeColor.g(), _strokeColor.b(),
        _alpha_);
        glBegin (GL_POINTS);
        for (int i = 0; i < getNumElements(); i++)
        {
            const DrawPoint *dp = getPointerToElement(i);
            glVertex2f(dp->x(), dp->y());
        }
        glEnd();

        if (_shouldBe)
        {
            glColor4f(1, 0, 0, _alpha_);
            glBegin(GL_POINTS);
            for (int i = 0; i < getNumElements(); i++)
            {
                const Vec2f* dp = _shouldBe->getPointerToElement(i);
                glVertex2f(dp->x(), dp->y());
            }
            glEnd();
        }
    }

    if (_inMotion)
        glPopMatrix();

}
示例#3
0
double AbstractPath::distanceTo2(const Vec2f pt, int& index) const { 
  int i, max = getNumElements();
  float res=FLT_MAX,tmp;
  for (i=0; i<max; i++) {
    if ((tmp=getPointerToElement(i)->distanceTo2(pt)) < res) {
      res = tmp;
      index = i;
    }
  }
  return ((double)res);
}
示例#4
0
double DrawPath::distToLast2(const Vec2f& loc) const
{
    return getPointerToElement(getNumElements() - 1)->distanceTo2(loc);
}
示例#5
0
double AbstractPath::distanceToStart(const Vec2f pt) const {
  return getPointerToElement(0)->distanceTo2(pt);
}
示例#6
0
double AbstractPath::distanceToEnd(const Vec2f pt) const {
  return getPointerToElement(getNumElements()-1)->distanceTo2(pt);
}