CodeDocument::Position CodeDocument::findWordBreakBefore (const Position& position) const noexcept { auto p = position; const int maxDistance = 256; int i = 0; bool stoppedAtLineStart = false; while (i < maxDistance) { auto c = p.movedBy (-1).getCharacter(); if (c == '\r' || c == '\n') { stoppedAtLineStart = true; if (i > 0) break; } if (! CharacterFunctions::isWhitespace (c)) break; p.moveBy (-1); ++i; } if (i < maxDistance && ! stoppedAtLineStart) { auto type = getCharacterType (p.movedBy (-1).getCharacter()); while (i < maxDistance && type == getCharacterType (p.movedBy (-1).getCharacter())) { p.moveBy (-1); ++i; } } return p; }
static QList<int> bounce(QPoint & p0, QVector2D vel, QSize size, const QRectList & rectsIn) { QList<int> touched; #if 0 QList<QPair<int, QRect> > rects; QRect swept = QRect(p0, size).united(QRect(movedBy(p0, vel), size)); for (int i = 0; i < rectsIn.count(); ++i) if (rectsIn.at(i).intersects(swept)) rects << qMakePair(i, rectsIn.at(i)); QVector2D p(p0.x(), p0.y()); QVector2D d(td.manhattanNormalize(vel)); while (vel.lengthSquared() > d.lengthSquared()) { } #endif return touched; }
void Item::moveBy( double dx, double dy ) { KtlQCanvasPolygon::moveBy(dx,dy); emit movedBy( dx, dy ); }
RoundRect movedBy(double _x, double _y) const { return movedBy({ _x, _y }); }
Polygon movedBy(const Vec2& v) const { return movedBy(v.x, v.y); }
[[nodiscard]] constexpr Ellipse movedBy(const position_type& v) const noexcept { return movedBy(v.x, v.y); }
RoundRect operator - (const Vec2& v) const { return movedBy(-v); }
Cylinder movedBy(double _x, double _y, double _z) const { return movedBy({ _x, _y, _z }); }
constexpr Line movedBy(const position_type& v) const noexcept { return movedBy(v.x, v.y); }
Shape operator - (const Vec2& v) const { return movedBy(-v); }
Shape operator + (const Vec2& v) const { return movedBy(v); }
Shape movedBy(double x, double y) const { return movedBy({ x, y }); }