29RelativeParallelogram::RelativeParallelogram()
33RelativeParallelogram::RelativeParallelogram (
const Rectangle<float>& r)
34 : topLeft (r.getTopLeft()), topRight (r.getTopRight()), bottomLeft (r.getBottomLeft())
38RelativeParallelogram::RelativeParallelogram (
const RelativePoint& topLeft_,
const RelativePoint& topRight_,
const RelativePoint& bottomLeft_)
39 : topLeft (topLeft_), topRight (topRight_), bottomLeft (bottomLeft_)
43RelativeParallelogram::RelativeParallelogram (
const String& topLeft_,
const String& topRight_,
const String& bottomLeft_)
44 : topLeft (topLeft_), topRight (topRight_), bottomLeft (bottomLeft_)
48RelativeParallelogram::~RelativeParallelogram()
52void RelativeParallelogram::resolveThreePoints (Point<float>* points, Expression::Scope*
const scope)
const
54 points[0] = topLeft.resolve (scope);
55 points[1] = topRight.resolve (scope);
56 points[2] = bottomLeft.resolve (scope);
59void RelativeParallelogram::resolveFourCorners (Point<float>* points, Expression::Scope*
const scope)
const
61 resolveThreePoints (points, scope);
62 points[3] = points[1] + (points[2] - points[0]);
65const Rectangle<float> RelativeParallelogram::getBounds (Expression::Scope*
const scope)
const
67 Point<float> points[4];
68 resolveFourCorners (points, scope);
69 return Rectangle<float>::findAreaContainingPoints (points, 4);
72void RelativeParallelogram::getPath (Path& path, Expression::Scope*
const scope)
const
74 Point<float> points[4];
75 resolveFourCorners (points, scope);
77 path.startNewSubPath (points[0]);
78 path.lineTo (points[1]);
79 path.lineTo (points[3]);
80 path.lineTo (points[2]);
84AffineTransform RelativeParallelogram::resetToPerpendicular (Expression::Scope*
const scope)
86 Point<float> corners[3];
87 resolveThreePoints (corners, scope);
89 const Line<float> top (corners[0], corners[1]);
90 const Line<float>
left (corners[0], corners[2]);
91 const Point<float> newTopRight (corners[0] + Point<float> (top.getLength(), 0.0f));
92 const Point<float> newBottomLeft (corners[0] + Point<float> (0.0f,
left.getLength()));
94 topRight.moveToAbsolute (newTopRight, scope);
95 bottomLeft.moveToAbsolute (newBottomLeft, scope);
97 return AffineTransform::fromTargetPoints (corners[0], corners[0],
98 corners[1], newTopRight,
99 corners[2], newBottomLeft);
102bool RelativeParallelogram::isDynamic()
const
104 return topLeft.isDynamic() || topRight.isDynamic() || bottomLeft.isDynamic();
107bool RelativeParallelogram::operator== (
const RelativeParallelogram& other)
const noexcept
109 return topLeft == other.topLeft && topRight == other.topRight && bottomLeft == other.bottomLeft;
112bool RelativeParallelogram::operator!= (
const RelativeParallelogram& other)
const noexcept
114 return ! operator== (other);
117Point<float> RelativeParallelogram::getInternalCoordForPoint (
const Point<float>*
const corners, Point<float> target)
noexcept
119 const Point<float> tr (corners[1] - corners[0]);
120 const Point<float> bl (corners[2] - corners[0]);
121 target -= corners[0];
123 return Point<float> (Line<float> (Point<float>(), tr).getIntersection (Line<float> (target, target - bl)).getDistanceFromOrigin(),
124 Line<float> (Point<float>(), bl).getIntersection (Line<float> (target, target - tr)).getDistanceFromOrigin());
127Point<float> RelativeParallelogram::getPointForInternalCoord (
const Point<float>*
const corners,
const Point<float> point)
noexcept
130 + Line<float> (Point<float>(), corners[1] - corners[0]).getPointAlongLine (point.x)
131 + Line<float> (Point<float>(), corners[2] - corners[0]).getPointAlongLine (point.y);
134Rectangle<float> RelativeParallelogram::getBoundingBox (
const Point<float>*
const p)
noexcept
136 const Point<float> points[] = { p[0], p[1], p[2], p[1] + (p[2] - p[0]) };
137 return Rectangle<float>::findAreaContainingPoints (points, 4);