// poly makes either a polygon or polyline void poly(VGfloat * x, VGfloat * y, VGint n, VGbitfield flag) { VGfloat points[n * 2]; VGPath path = newpath(); interleave(x, y, n, points); vguPolygon(path, points, n, VG_FALSE); vgDrawPath(path, flag); vgDestroyPath(path); }
void createPrimitives() { VGfloat points[] = {-30,-30, 30,-30, 0,30}; line = testCreatePath(); vguLine(line, -30,-30,30,30); primitives[0] = line; polyOpen = testCreatePath(); vguPolygon(polyOpen, points, 3, VG_FALSE); primitives[1] = polyOpen; polyClosed = testCreatePath(); vguPolygon(polyClosed, points, 3, VG_TRUE); primitives[2] = polyClosed; rect = testCreatePath(); vguRect(rect, -50,-30, 100,60); primitives[3] = rect; rectRound = testCreatePath(); vguRoundRect(rectRound, -50,-30, 100,60, 30,30); primitives[4] = rectRound; ellipse = testCreatePath(); vguEllipse(ellipse, 0,0, 100, 100); primitives[5] = ellipse; arcOpen = testCreatePath(); vguArc(arcOpen, 0,0, 100,60, 0, 270, VGU_ARC_OPEN); primitives[6] = arcOpen; arcChord = testCreatePath(); vguArc(arcChord, 0,0, 100,60, 0, 270, VGU_ARC_CHORD); primitives[7] = arcChord; arcPie = testCreatePath(); vguArc(arcPie, 0,0, 100,60, 0, 270, VGU_ARC_PIE); primitives[8] = arcPie; }
void PainterOpenVG::drawPolygon(size_t numPoints, const FloatPoint* points, VGbitfield specifiedPaintModes) { ASSERT(m_state); VGbitfield paintModes = 0; if (!m_state->strokeDisabled()) paintModes |= VG_STROKE_PATH; if (!m_state->fillDisabled()) paintModes |= VG_FILL_PATH; paintModes &= specifiedPaintModes; if (!paintModes) return; m_surface->makeCurrent(); // Path segments: all points + "close path". const VGint numSegments = numPoints + 1; const VGint numCoordinates = numPoints * 2; VGPath path = vgCreatePath( VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0 /* scale */, 0.0 /* bias */, numSegments /* expected number of segments */, numCoordinates /* expected number of total coordinates */, VG_PATH_CAPABILITY_APPEND_TO); ASSERT_VG_NO_ERROR(); Vector<VGfloat> vgPoints(numCoordinates); for (int i = 0; i < numPoints; ++i) { vgPoints[i*2] = points[i].x(); vgPoints[i*2 + 1] = points[i].y(); } if (vguPolygon(path, vgPoints.data(), numPoints, VG_TRUE /* closed */) == VGU_NO_ERROR) { vgDrawPath(path, paintModes); ASSERT_VG_NO_ERROR(); } vgDestroyPath(path); ASSERT_VG_NO_ERROR(); }