FloatPoint Path::pointAtLength(float length, bool& ok) { VGfloat x = 0, y = 0; m_path->makeCompatibleContextCurrent(); vgPointAlongPath(m_path->vgPath(), 0, vgGetParameteri(m_path->vgPath(), VG_PATH_NUM_SEGMENTS), length, &x, &y, 0, 0); ok = (vgGetError() == VG_NO_ERROR); return FloatPoint(x, y); }
float Path::normalAngleAtLength(float length, bool& ok) { VGfloat tangentX, tangentY; m_path->makeCompatibleContextCurrent(); vgPointAlongPath(m_path->vgPath(), 0, vgGetParameteri(m_path->vgPath(), VG_PATH_NUM_SEGMENTS), length, 0, 0, &tangentX, &tangentY); ok = (vgGetError() == VG_NO_ERROR); return atan2f(tangentY, tangentX) * 180.0 / piFloat; // convert to degrees }
static void draw_marks(VGPath path) { VGfloat point[2], tangent[2]; int i = 0; for (i = 0; i < 1300; i += 50) { vgPointAlongPath(path, 0, 6, i, point + 0, point + 1, tangent + 0, tangent + 1); draw_point(point[0], point[1]); } }