29RelativePointPath::RelativePointPath()
30 : usesNonZeroWinding (
true),
31 containsDynamicPoints (
false)
35RelativePointPath::RelativePointPath (
const RelativePointPath& other)
36 : usesNonZeroWinding (true),
37 containsDynamicPoints (false)
39 for (
int i = 0; i < other.elements.size(); ++i)
40 elements.add (other.elements.getUnchecked (i)->clone());
43RelativePointPath::RelativePointPath (
const Path& path)
44 : usesNonZeroWinding (path.isUsingNonZeroWinding()),
45 containsDynamicPoints (false)
47 for (Path::Iterator i (path); i.next();)
49 switch (i.elementType)
51 case Path::Iterator::startNewSubPath: elements.add (
new StartSubPath (RelativePoint (i.x1, i.y1)));
break;
52 case Path::Iterator::lineTo: elements.add (
new LineTo (RelativePoint (i.x1, i.y1)));
break;
53 case Path::Iterator::quadraticTo: elements.add (
new QuadraticTo (RelativePoint (i.x1, i.y1), RelativePoint (i.x2, i.y2)));
break;
54 case Path::Iterator::cubicTo: elements.add (
new CubicTo (RelativePoint (i.x1, i.y1), RelativePoint (i.x2, i.y2), RelativePoint (i.x3, i.y3)));
break;
55 case Path::Iterator::closePath: elements.add (
new CloseSubPath());
break;
61RelativePointPath::~RelativePointPath()
65bool RelativePointPath::operator== (
const RelativePointPath& other)
const noexcept
67 if (elements.size() != other.elements.size()
68 || usesNonZeroWinding != other.usesNonZeroWinding
69 || containsDynamicPoints != other.containsDynamicPoints)
72 for (
int i = 0; i < elements.size(); ++i)
74 ElementBase*
const e1 = elements.getUnchecked (i);
75 ElementBase*
const e2 = other.elements.getUnchecked (i);
77 if (e1->type != e2->type)
80 int numPoints1, numPoints2;
81 const RelativePoint*
const points1 = e1->getControlPoints (numPoints1);
82 const RelativePoint*
const points2 = e2->getControlPoints (numPoints2);
84 jassert (numPoints1 == numPoints2);
86 for (
int j = numPoints1; --j >= 0;)
87 if (points1[j] != points2[j])
94bool RelativePointPath::operator!= (
const RelativePointPath& other)
const noexcept
96 return ! operator== (other);
101 elements.swapWith (other.elements);
102 std::swap (usesNonZeroWinding, other.usesNonZeroWinding);
103 std::swap (containsDynamicPoints, other.containsDynamicPoints);
108 for (
int i = 0; i < elements.size(); ++i)
109 elements.getUnchecked (i)->addToPath (path, scope);
112bool RelativePointPath::containsAnyDynamicPoints()
const
114 return containsDynamicPoints;
117void RelativePointPath::addElement (ElementBase* newElement)
119 if (newElement !=
nullptr)
121 elements.add (newElement);
122 containsDynamicPoints = containsDynamicPoints || newElement->isDynamic();
127RelativePointPath::ElementBase::ElementBase (
const ElementType type_) : type (type_)
131bool RelativePointPath::ElementBase::isDynamic()
137 if (
points[i].isDynamic())
144RelativePointPath::StartSubPath::StartSubPath (
const RelativePoint& pos)
145 : ElementBase (startSubPathElement), startPos (pos)
149void RelativePointPath::StartSubPath::addToPath (Path& path, Expression::Scope* scope)
const
151 path.startNewSubPath (startPos.
resolve (scope));
154RelativePoint* RelativePointPath::StartSubPath::getControlPoints (
int&
numPoints)
160RelativePointPath::ElementBase* RelativePointPath::StartSubPath::clone()
const
162 return new StartSubPath (startPos);
166RelativePointPath::CloseSubPath::CloseSubPath()
167 : ElementBase (closeSubPathElement)
171void RelativePointPath::CloseSubPath::addToPath (Path& path, Expression::Scope*)
const
176RelativePoint* RelativePointPath::CloseSubPath::getControlPoints (
int&
numPoints)
182RelativePointPath::ElementBase* RelativePointPath::CloseSubPath::clone()
const
184 return new CloseSubPath();
188RelativePointPath::LineTo::LineTo (
const RelativePoint&
endPoint_)
189 : ElementBase (lineToElement), endPoint (
endPoint_)
193void RelativePointPath::LineTo::addToPath (Path& path, Expression::Scope* scope)
const
195 path.lineTo (endPoint.
resolve (scope));
198RelativePoint* RelativePointPath::LineTo::getControlPoints (
int&
numPoints)
204RelativePointPath::ElementBase* RelativePointPath::LineTo::clone()
const
206 return new LineTo (endPoint);
210RelativePointPath::QuadraticTo::QuadraticTo (
const RelativePoint&
controlPoint,
const RelativePoint& endPoint)
211 : ElementBase (quadraticToElement)
214 controlPoints[1] = endPoint;
217void RelativePointPath::QuadraticTo::addToPath (Path& path, Expression::Scope* scope)
const
219 path.quadraticTo (controlPoints[0].resolve (scope),
220 controlPoints[1].resolve (scope));
223RelativePoint* RelativePointPath::QuadraticTo::getControlPoints (
int&
numPoints)
226 return controlPoints;
229RelativePointPath::ElementBase* RelativePointPath::QuadraticTo::clone()
const
231 return new QuadraticTo (controlPoints[0], controlPoints[1]);
236RelativePointPath::CubicTo::CubicTo (
const RelativePoint&
controlPoint1,
const RelativePoint&
controlPoint2,
const RelativePoint& endPoint)
237 : ElementBase (cubicToElement)
241 controlPoints[2] = endPoint;
244void RelativePointPath::CubicTo::addToPath (Path& path, Expression::Scope* scope)
const
246 path.cubicTo (controlPoints[0].resolve (scope),
247 controlPoints[1].resolve (scope),
248 controlPoints[2].resolve (scope));
251RelativePoint* RelativePointPath::CubicTo::getControlPoints (
int&
numPoints)
254 return controlPoints;
257RelativePointPath::ElementBase* RelativePointPath::CubicTo::clone()
const
259 return new CubicTo (controlPoints[0], controlPoints[1], controlPoints[2]);
When evaluating an Expression object, this class is used to resolve symbols and perform functions tha...
A path is a sequence of lines and curves that may either form a closed shape or be open-ended.
A path object that consists of RelativePoint coordinates rather than the normal fixed ones.
Point< float > resolve(const Expression::Scope *evaluationContext) const
Calculates the absolute position of this point.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...