summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/AffineTransform.h
diff options
context:
space:
mode:
authorMatthew Olsson <matthewcolsson@gmail.com>2021-04-12 11:20:55 -0700
committerAndreas Kling <kling@serenityos.org>2021-05-02 22:48:06 +0200
commitac238b3bd63e47a334c6859ddb6570b89f7be3dc (patch)
tree1b3aa2c5dc873219728f14f5c613887058b099df /Userland/Libraries/LibGfx/AffineTransform.h
parentf5c676fd86a3ced3ede298d09f0b6d7b4ee1624e (diff)
downloadserenity-ac238b3bd63e47a334c6859ddb6570b89f7be3dc.zip
LibGfx: Add some helper methods to AffineTransform
Also makes some basic getters ALWAYS_INLINE and [[nodiscard]], as well as fixing as error with the map method.
Diffstat (limited to 'Userland/Libraries/LibGfx/AffineTransform.h')
-rw-r--r--Userland/Libraries/LibGfx/AffineTransform.h35
1 files changed, 27 insertions, 8 deletions
diff --git a/Userland/Libraries/LibGfx/AffineTransform.h b/Userland/Libraries/LibGfx/AffineTransform.h
index 3e2642f40d..63277b1049 100644
--- a/Userland/Libraries/LibGfx/AffineTransform.h
+++ b/Userland/Libraries/LibGfx/AffineTransform.h
@@ -6,6 +6,7 @@
#pragma once
+#include <AK/Format.h>
#include <AK/Forward.h>
#include <LibGfx/Forward.h>
@@ -36,18 +37,28 @@ public:
template<typename T>
Rect<T> map(const Rect<T>&) const;
- float a() const { return m_values[0]; }
- float b() const { return m_values[1]; }
- float c() const { return m_values[2]; }
- float d() const { return m_values[3]; }
- float e() const { return m_values[4]; }
- float f() const { return m_values[5]; }
+ [[nodiscard]] ALWAYS_INLINE float a() const { return m_values[0]; }
+ [[nodiscard]] ALWAYS_INLINE float b() const { return m_values[1]; }
+ [[nodiscard]] ALWAYS_INLINE float c() const { return m_values[2]; }
+ [[nodiscard]] ALWAYS_INLINE float d() const { return m_values[3]; }
+ [[nodiscard]] ALWAYS_INLINE float e() const { return m_values[4]; }
+ [[nodiscard]] ALWAYS_INLINE float f() const { return m_values[5]; }
- float x_scale() const;
- float y_scale() const;
+ [[nodiscard]] float x_scale() const;
+ [[nodiscard]] float y_scale() const;
+ [[nodiscard]] FloatPoint scale() const;
+ [[nodiscard]] float x_translation() const;
+ [[nodiscard]] float y_translation() const;
+ [[nodiscard]] FloatPoint translation() const;
AffineTransform& scale(float sx, float sy);
+ AffineTransform& scale(const FloatPoint& s);
+ AffineTransform& set_scale(float sx, float sy);
+ AffineTransform& set_scale(const FloatPoint& s);
AffineTransform& translate(float tx, float ty);
+ AffineTransform& translate(const FloatPoint& t);
+ AffineTransform& set_translation(float tx, float ty);
+ AffineTransform& set_translation(const FloatPoint& t);
AffineTransform& rotate_radians(float);
AffineTransform& multiply(const AffineTransform&);
@@ -56,3 +67,11 @@ private:
};
}
+
+template<>
+struct AK::Formatter<Gfx::AffineTransform> : Formatter<FormatString> {
+ void format(FormatBuilder& builder, Gfx::AffineTransform value)
+ {
+ return Formatter<FormatString>::format(builder, "[{} {} {} {} {} {}]", value.a(), value.b(), value.c(), value.d(), value.e(), value.f());
+ }
+};