//============================================================================== void Path::addLineSegment (const Line<float>& line, float lineThickness) { const Line<float> reversed (line.reversed()); lineThickness *= 0.5f; startNewSubPath (line.getPointAlongLine (0, lineThickness)); lineTo (line.getPointAlongLine (0, -lineThickness)); lineTo (reversed.getPointAlongLine (0, lineThickness)); lineTo (reversed.getPointAlongLine (0, -lineThickness)); closeSubPath(); }
void Path::addQuadrilateral (const float x1, const float y1, const float x2, const float y2, const float x3, const float y3, const float x4, const float y4) { startNewSubPath (x1, y1); lineTo (x2, y2); lineTo (x3, y3); lineTo (x4, y4); closeSubPath(); }
void Path::addPieChart(Point const& center, const Point& radius, const double start, const double end) noexcept { const vector<Point> points = BezierCubic::fromArc(center, radius, start, end); moveTo(center); lineTo(points[0]); for(vector<Point>::size_type i = 1; i < points.size(); i++) { addNode(Node(points[i], Cubic)); } lineTo(center); close(); }
void Canvas::strokeRect(int x, int y, int width, int height) { moveTo(x,y); lineTo(x + width, y); lineTo(x + width, y + height); lineTo(x, y + height); lineTo(x,y); }
void rosette(int N, float radius) { GLPoint *pointlist = new GLPoint[N]; GLfloat theta = (2.0f * PI) / N; GLfloat angle = theta / 2; for (int c = 0; c < N; c++) { pointlist[c].set(radius*sin(theta*c), radius*cos(theta*c)); } for (int i = 0; i < N-1; i++) { moveTo(pointlist[i]); lineTo(pointlist[i+1]); } lineTo(pointlist[0]); }
void paint() { static const int ox = 150; static const int oy = 150; static const int hl = 46; static const int ml = 74; static const int sl = 120; int i; beginPaint(); clearDevice(); // circle setPenWidth(2); setPenColor(BLACK); setBrushColor(WHITE); ellipse(25, 25, 275, 275); // label setPenWidth(1); setPenColor(BLACK); for (i = 0; i < 12; ++i) { moveTo(ox + 115 * sin(RAD(180 - i * 30)), oy + 115 * cos(RAD(180 - i * 30))); lineTo(ox + 125 * sin(RAD(180 - i * 30)), oy + 125 * cos(RAD(180 - i * 30))); } // hour setPenWidth(8); setPenColor(BLACK); moveTo(ox, oy); lineTo(ox + hl * sin(RAD(180 - h * 30)), oy + hl * cos(RAD(180 - h * 30))); // minute setPenWidth(4); setPenColor(GREEN); moveTo(ox, oy); lineTo(ox + ml * sin(RAD(180 - m * 6)), oy + ml * cos(RAD(180 - m * 6))); // second setPenWidth(2); setPenColor(RED); moveTo(ox, oy); lineTo(ox + sl * sin(RAD(180 - s * 6)), oy + sl * cos(RAD(180 - s * 6))); endPaint(); }
void Context::appendPath( const cinder::Path2d &path ) { size_t point = 0; if( path.empty() ) return; moveTo( path.getPoint( point++ ) ); for( size_t seg = 0; seg < path.getNumSegments(); ++seg ) { switch( path.getSegmentType( seg ) ) { case Path2d::LINETO: lineTo( path.getPoint( point++ ) ); break; case Path2d::QUADTO: { const Vec2f &spl0( path.getPoint( point - 1 ) ); const Vec2f &spl1( path.getPoint( point + 0 ) ); const Vec2f &spl2( path.getPoint( point + 1 ) ); curveTo( spl0 + (spl1 - spl0) / 3.0f * 2.0f, spl1 + (spl2 - spl1) / 3.0f, spl2 ); point += 2; } break; case Path2d::CUBICTO: curveTo( path.getPoint( point ), path.getPoint( point + 1 ), path.getPoint( point + 2 ) ); point += 3; break; case Path2d::CLOSE: closePath(); break; } } }
void QgsDxfPaintEngine::drawPath( const QPainterPath& path ) { int pathLength = path.elementCount(); for ( int i = 0; i < pathLength; ++i ) { const QPainterPath::Element& pathElem = path.elementAt( i ); if ( pathElem.type == QPainterPath::MoveToElement ) { moveTo( pathElem.x, pathElem.y ); } else if ( pathElem.type == QPainterPath::LineToElement ) { lineTo( pathElem.x, pathElem.y ); } else if ( pathElem.type == QPainterPath::CurveToElement ) { curveTo( pathElem.x, pathElem.y ); } else if ( pathElem.type == QPainterPath::CurveToDataElement ) { mCurrentCurve.append( QPointF( pathElem.x, pathElem.y ) ); } } endCurve(); endPolygon(); }
void CanvasPathMethods::arc(float x, float y, float r, float sa, float ea, bool anticlockwise, ExceptionCode& ec) { ec = 0; if (!isfinite(x) || !isfinite(y) || !isfinite(r) || !isfinite(sa) || !isfinite(ea)) return; if (r < 0) { ec = INDEX_SIZE_ERR; return; } if (!r || sa == ea) { // The arc is empty but we still need to draw the connecting line. lineTo(x + r * cosf(sa), y + r * sinf(sa)); return; } if (!isTransformInvertible()) return; // If 'sa' and 'ea' differ by more than 2Pi, just add a circle starting/ending at 'sa'. if (anticlockwise && sa - ea >= 2 * piFloat) { m_path.addArc(FloatPoint(x, y), r, sa, sa - 2 * piFloat, anticlockwise); return; } if (!anticlockwise && ea - sa >= 2 * piFloat) { m_path.addArc(FloatPoint(x, y), r, sa, sa + 2 * piFloat, anticlockwise); return; } m_path.addArc(FloatPoint(x, y), r, sa, ea, anticlockwise); }
void BrushStroker::end() { if (_smoothed) { lineTo(_dataEnd); } }
void THLine::depersist(LuaPersistReader *pReader) { initialize(); pReader->readVUInt(m_iR); pReader->readVUInt(m_iG); pReader->readVUInt(m_iB); pReader->readVUInt(m_iA); pReader->readVFloat(m_fWidth); uint32_t numOps = 0; pReader->readVUInt(numOps); for (uint32_t i = 0; i < numOps; i++) { unsigned type; double fX, fY; pReader->readVUInt((uint32_t&)type); pReader->readVFloat(fX); pReader->readVFloat(fY); if (type == THLOP_MOVE) { moveTo(fX, fY); } else if (type == THLOP_LINE) { lineTo(fX, fY); } } }
void PathParser::append(const UnivocalPath& append_path) { const std::vector<Edge>& edges = append_path._path->m_edges; if (append_path._fill_type == UnivocalPath::FILL_LEFT) { std::for_each(edges.begin(), edges.end(), boost::bind(&PathParser::line_to, this, _1)); } else { for (std::vector<Edge>::const_reverse_iterator prev = edges.rbegin(), it = boost::next(prev), end = edges.rend(); it != end; ++it, ++prev) { if ((*prev).straight()) { lineTo((*it).ap); } else { line_to(Edge((*prev).cp, (*it).ap)); } } line_to(Edge(edges.front().cp, append_path.endPoint())); } _cur_endpoint = append_path.endPoint(); }
void WPainterPath::connectPath(const WPainterPath& path) { if (currentPosition() != path.beginPosition()) lineTo(path.beginPosition()); addPath(path); }
QT_BEGIN_NAMESPACE #define CURVE_FLATNESS Q_PI / 8 void QTriangulatingStroker::endCapOrJoinClosed(const qreal *start, const qreal *cur, bool implicitClose, bool endsAtStart) { if (endsAtStart) { join(start + 2); } else if (implicitClose) { join(start); lineTo(start); join(start+2); } else { endCap(cur); } int count = m_vertices.size(); // Copy the (x, y) values because QDataBuffer::add(const float& t) // may resize the buffer, which will leave t pointing at the // previous buffer's memory region if we don't copy first. float x = m_vertices.at(count-2); float y = m_vertices.at(count-1); m_vertices.add(x); m_vertices.add(y); }
void TTGraphicsContext::lineSegment(TTFloat64 x1, TTFloat64 y1, TTFloat64 x2, TTFloat64 y2, TTFloat64 width, TTGraphicsColor& color) { setColor(color); setLineWidth(width); moveTo(x1, y1); lineTo(x2, y2); stroke(); }
//----------------------------------------------------------------------------- void D2DDrawContext::drawLines (const CPoint* points, const int32_t& numberOfLines) { for (int32_t i = 0; i < numberOfLines * 2; i+=2) { moveTo (points[i]); lineTo (points[i+1]); } }
void CloudsVisualSystemLSystem::buildLSystem(){ // Clear // lsysLines.clear(); lsysLines.push_back(ofPolyline()); lsysNodes.clear(); lsysOriginal.clear(); LSystem sys; sys.initialPos.set(0,0); sys.unoise = 0.0; sys.utime = 0.0; sys.ds = lsysScale; sys.setAngle( lsysAngle ); sys.addAxion( lsysAxiom ); sys.addRule( lsysRule1 ); if (lsysRule2.size() > 0){ sys.addRule( lsysRule2); } sys.make( lsysDepth ); lsysOriginal = sys.mesh; if ( lsysOriginal.getVertices().size() > 2){ lineTo( lsysOriginal.getVertices()[0] ); addNode( lsysOriginal.getVertices()[0] ); for (int i = 1; i < lsysOriginal.getVertices().size();i++){ if ( i%2 == 1){ lineTo( lsysOriginal.getVertices()[i]); } else { if ( lsysOriginal.getVertices()[i] != lsysOriginal.getVertices()[i-1]){ lsysLines.push_back(ofPolyline()); lineTo( lsysOriginal.getVertices()[i] ); addNode( lsysOriginal.getVertices()[i] ); } } } } if ( lsysNodes.size() > 0){ lsysNodes[0].startTime = 0; } }
void PathParser::line_to(const Edge& curve) { if (curve.straight()) { lineTo(curve.ap); } else { curveTo(curve); } }
static void endPath(Ppolyline_t * path, boolean close) { if (close) { pointf p0 = path->ps[0]; lineTo(path, p0.x, p0.y); } path->ps = realloc(path->ps, path->pn * sizeof(pointf)); bufsize = 0; }
void forward(float dist, int isVisible) { const float RadPerDeg = 0.017453393; //radians per degree float x = CP.getX() + dist * cos(RadPerDeg * CD); float y = CP.getY() + dist * sin(RadPerDeg * CD); if (isVisible) lineTo(Point(x, y)); else moveTo(Point(x, y)); }
void Path::addCentredArc (const float centreX, const float centreY, const float radiusX, const float radiusY, const float rotationOfEllipse, const float fromRadians, float toRadians, const bool startAsNewSubPath) { if (radiusX > 0.0f && radiusY > 0.0f) { const Point<float> centre (centreX, centreY); const AffineTransform rotation (AffineTransform::rotation (rotationOfEllipse, centreX, centreY)); float angle = fromRadians; if (startAsNewSubPath) startNewSubPath (centre.getPointOnCircumference (radiusX, radiusY, angle).transformedBy (rotation)); if (fromRadians < toRadians) { if (startAsNewSubPath) angle += PathHelpers::ellipseAngularIncrement; while (angle < toRadians) { lineTo (centre.getPointOnCircumference (radiusX, radiusY, angle).transformedBy (rotation)); angle += PathHelpers::ellipseAngularIncrement; } } else { if (startAsNewSubPath) angle -= PathHelpers::ellipseAngularIncrement; while (angle > toRadians) { lineTo (centre.getPointOnCircumference (radiusX, radiusY, angle).transformedBy (rotation)); angle -= PathHelpers::ellipseAngularIncrement; } } lineTo (centre.getPointOnCircumference (radiusX, radiusY, toRadians).transformedBy (rotation)); } }
void WPainterPath::addPolygon(const std::vector<WPointF>& points) { if (!points.empty()) { unsigned i = 0; if (currentPosition() != points[0]) moveTo(points[i++]); for (; i < points.size(); ++i) lineTo(points[i]); } }
void Path::addPath (const Path& other, const AffineTransform& transformToApply) { size_t i = 0; const float* const d = other.data.elements; while (i < other.numElements) { const float type = d [i++]; if (type == closeSubPathMarker) { closeSubPath(); } else { float x = d[i++]; float y = d[i++]; transformToApply.transformPoint (x, y); if (type == moveMarker) { startNewSubPath (x, y); } else if (type == lineMarker) { lineTo (x, y); } else if (type == quadMarker) { float x2 = d [i++]; float y2 = d [i++]; transformToApply.transformPoint (x2, y2); quadraticTo (x, y, x2, y2); } else if (type == cubicMarker) { float x2 = d [i++]; float y2 = d [i++]; float x3 = d [i++]; float y3 = d [i++]; transformToApply.transformPoints (x2, y2, x3, y3); cubicTo (x, y, x2, y2, x3, y3); } else { // something's gone wrong with the element list! jassertfalse; } } } }
//----------------------------------------------------------------------------- void D2DDrawContext::drawPoint (const CPoint &point, const CColor& color) { saveGlobalState (); setLineWidth (1); setFrameColor (color); CPoint point2 (point); point2.h++; moveTo (point); lineTo (point2); restoreGlobalState (); }
void ShapeMaker::rect( double x, double y, double w, double h, double rx, double ry ) { if(rx > 0 || ry > 0) { setup(x + rx, y); lineTo(x + w - rx, y); arcTo(rx, ry, 0, false, true, x + w, y + ry); lineTo(x + w, y + h - ry); arcTo(rx, ry, 0, false, true, x + w - rx, y + h); lineTo(x + rx, y + h); arcTo(rx, ry, 0, false, true, x, y + h - ry); lineTo(x, y + ry); arcTo(rx, ry, 0, false, true, x + rx, y); close(); } else { setup(x, y); lineToR(0, h); lineToR(w, 0); lineToR(0, -h); lineToR(-w, 0); close(); } }
void _finalizeCorner( float x, float y, const osgWidget::Color& lc, const osgWidget::Color& fc ) { setSourceRGBA(lc); strokePreserve(); setSourceRGBA(fc); lineTo(x, y); fill(); }
void Canvas::drawCrcl(float x0, float y0, float r) { const int n = 100; // number of intermediate segments in arc float angleInc = 360 * 3.14159265 /(180 * n); // angle increment float angle = 0; moveTo(x0+r, y0); for(int k = 0; k < n; k++) { angle += angleInc; lineTo(x0 + r * cos(angle), y0 + r * sin(angle)); } }
void Canvas::forward( float dist, bool visible ) { const double radPerDeg = 0.017453393f; double x = currPos.x + ( dist * cos( currDir * radPerDeg ) ); double y = currPos.y + ( dist * sin( currDir * radPerDeg ) ); if( visible ) lineTo(x, y); else moveTo(x, y); }
KoConnectionShape::KoConnectionShape() : KoParameterShape(*(new KoConnectionShapePrivate(this))) { Q_D(KoConnectionShape); d->handles.push_back(QPointF(0, 0)); d->handles.push_back(QPointF(140, 140)); moveTo(d->handles[StartHandle]); lineTo(d->handles[EndHandle]); updatePath(QSizeF(140, 140)); clearConnectionPoints(); }
QT_FT_Outline *QOutlineMapper::convertPath(const QVectorPath &path) { int count = path.elementCount(); #ifdef QT_DEBUG_CONVERT printf("QOutlineMapper::convertPath(VP), size=%d\n", count); #endif beginOutline(path.hasWindingFill() ? Qt::WindingFill : Qt::OddEvenFill); if (path.elements()) { // TODO: if we do closing of subpaths in convertElements instead we // could avoid this loop const QPainterPath::ElementType *elements = path.elements(); const QPointF *points = reinterpret_cast<const QPointF *>(path.points()); for (int index = 0; index < count; ++index) { switch (elements[index]) { case QPainterPath::MoveToElement: if (index == count - 1) continue; moveTo(points[index]); break; case QPainterPath::LineToElement: lineTo(points[index]); break; case QPainterPath::CurveToElement: curveTo(points[index], points[index+1], points[index+2]); index += 2; break; default: break; // This will never hit.. } } } else { // ### We can kill this copying and just use the buffer straight... m_elements.resize(count); if (count) memcpy(m_elements.data(), path.points(), count* sizeof(QPointF)); m_element_types.resize(0); } endOutline(); return outline(); }