LMMS
Loading...
Searching...
No Matches
juce_RelativeParallelogram.cpp
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
32
34 : topLeft (r.getTopLeft()), topRight (r.getTopRight()), bottomLeft (r.getBottomLeft())
35{
36}
37
38RelativeParallelogram::RelativeParallelogram (const RelativePoint& topLeft_, const RelativePoint& topRight_, const RelativePoint& bottomLeft_)
39 : topLeft (topLeft_), topRight (topRight_), bottomLeft (bottomLeft_)
40{
41}
42
43RelativeParallelogram::RelativeParallelogram (const String& topLeft_, const String& topRight_, const String& bottomLeft_)
44 : topLeft (topLeft_), topRight (topRight_), bottomLeft (bottomLeft_)
45{
46}
47
51
53{
54 points[0] = topLeft.resolve (scope);
55 points[1] = topRight.resolve (scope);
56 points[2] = bottomLeft.resolve (scope);
57}
58
60{
61 resolveThreePoints (points, scope);
62 points[3] = points[1] + (points[2] - points[0]);
63}
64
71
73{
74 Point<float> points[4];
75 resolveFourCorners (points, scope);
76
77 path.startNewSubPath (points[0]);
78 path.lineTo (points[1]);
79 path.lineTo (points[3]);
80 path.lineTo (points[2]);
81 path.closeSubPath();
82}
83
85{
86 Point<float> corners[3];
87 resolveThreePoints (corners, scope);
88
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()));
93
94 topRight.moveToAbsolute (newTopRight, scope);
95 bottomLeft.moveToAbsolute (newBottomLeft, scope);
96
97 return AffineTransform::fromTargetPoints (corners[0], corners[0],
98 corners[1], newTopRight,
99 corners[2], newBottomLeft);
100}
101
103{
104 return topLeft.isDynamic() || topRight.isDynamic() || bottomLeft.isDynamic();
105}
106
107bool RelativeParallelogram::operator== (const RelativeParallelogram& other) const noexcept
108{
109 return topLeft == other.topLeft && topRight == other.topRight && bottomLeft == other.bottomLeft;
110}
111
112bool RelativeParallelogram::operator!= (const RelativeParallelogram& other) const noexcept
113{
114 return ! operator== (other);
115}
116
118{
119 const Point<float> tr (corners[1] - corners[0]);
120 const Point<float> bl (corners[2] - corners[0]);
121 target -= corners[0];
122
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());
125}
126
128{
129 return corners[0]
130 + Line<float> (Point<float>(), corners[1] - corners[0]).getPointAlongLine (point.x)
131 + Line<float> (Point<float>(), corners[2] - corners[0]).getPointAlongLine (point.y);
132}
133
135{
136 const Point<float> points[] = { p[0], p[1], p[2], p[1] + (p[2] - p[0]) };
138}
139
140} // namespace juce
static Audio_Scope * scope
Definition player.cpp:26
Definition juce_AffineTransform.h:43
static AffineTransform fromTargetPoints(float x00, float y00, float x10, float y10, float x01, float y01) noexcept
Definition juce_AffineTransform.cpp:213
Definition juce_Expression.h:109
Definition juce_Line.h:47
Point< ValueType > getPointAlongLine(ValueType distanceFromStart) const noexcept
Definition juce_Line.h:204
ValueType getLength() const noexcept
Definition juce_Line.h:117
Definition juce_Path.h:65
void startNewSubPath(float startX, float startY)
Definition juce_Path.cpp:216
void closeSubPath()
Definition juce_Path.cpp:292
void lineTo(float endX, float endY)
Definition juce_Path.cpp:233
Definition juce_Point.h:42
Definition juce_Rectangle.h:67
static Rectangle findAreaContainingPoints(const Point< ValueType > *points, int numPoints) noexcept
Definition juce_Rectangle.h:901
RelativePoint topLeft
Definition juce_RelativeParallelogram.h:63
AffineTransform resetToPerpendicular(Expression::Scope *scope)
Definition juce_RelativeParallelogram.cpp:84
~RelativeParallelogram()
Definition juce_RelativeParallelogram.cpp:48
bool isDynamic() const
Definition juce_RelativeParallelogram.cpp:102
RelativePoint topRight
Definition juce_RelativeParallelogram.h:63
void resolveFourCorners(Point< float > *points, Expression::Scope *scope) const
Definition juce_RelativeParallelogram.cpp:59
static Rectangle< float > getBoundingBox(const Point< float > *parallelogramCorners) noexcept
Definition juce_RelativeParallelogram.cpp:134
RelativePoint bottomLeft
Definition juce_RelativeParallelogram.h:63
void resolveThreePoints(Point< float > *points, Expression::Scope *scope) const
Definition juce_RelativeParallelogram.cpp:52
static Point< float > getInternalCoordForPoint(const Point< float > *parallelogramCorners, Point< float > point) noexcept
Definition juce_RelativeParallelogram.cpp:117
static Point< float > getPointForInternalCoord(const Point< float > *parallelogramCorners, Point< float > internalPoint) noexcept
Definition juce_RelativeParallelogram.cpp:127
RelativeParallelogram()
Definition juce_RelativeParallelogram.cpp:29
const Rectangle< float > getBounds(Expression::Scope *scope) const
Definition juce_RelativeParallelogram.cpp:65
void getPath(Path &path, Expression::Scope *scope) const
Definition juce_RelativeParallelogram.cpp:72
Definition juce_RelativePoint.h:38
Definition juce_String.h:53
unsigned bl
Definition inflate.c:935
struct @113205115357366127300225113341150224053346037032::@137033172036070230260373056156374243321245367362 left
Definition carla_juce.cpp:31
uch * p
Definition crypt.c:594
int r
Definition crypt.c:458