From 7f22db449a98f2b83f45ec83e10b37bcc3e92ab9 Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 13 Oct 2025 16:54:17 +0100 Subject: [PATCH] AffineTransform: Add horizontalFlip() --- modules/juce_graphics/geometry/juce_AffineTransform.cpp | 6 ++++++ modules/juce_graphics/geometry/juce_AffineTransform.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/modules/juce_graphics/geometry/juce_AffineTransform.cpp b/modules/juce_graphics/geometry/juce_AffineTransform.cpp index af0c1f7748..a77d49416a 100644 --- a/modules/juce_graphics/geometry/juce_AffineTransform.cpp +++ b/modules/juce_graphics/geometry/juce_AffineTransform.cpp @@ -188,6 +188,12 @@ AffineTransform AffineTransform::verticalFlip (float height) noexcept 0.0f, -1.0f, height }; } +AffineTransform AffineTransform::horizontalFlip (float width) noexcept +{ + return { -1.0f, 0.0f, width, + 0.0f, 1.0f, 0.0f }; +} + AffineTransform AffineTransform::inverted() const noexcept { double determinant = getDeterminant(); diff --git a/modules/juce_graphics/geometry/juce_AffineTransform.h b/modules/juce_graphics/geometry/juce_AffineTransform.h index 7bdce3d408..48bb03c614 100644 --- a/modules/juce_graphics/geometry/juce_AffineTransform.h +++ b/modules/juce_graphics/geometry/juce_AffineTransform.h @@ -215,6 +215,10 @@ public: */ static AffineTransform verticalFlip (float height) noexcept; + /** Returns a transform that will flip coordinates horizontally within a window of the given width. + */ + static AffineTransform horizontalFlip (float width) noexcept; + /** Returns a matrix which is the inverse operation of this one. Some matrices don't have an inverse - in this case, the method will just return