summaryrefslogtreecommitdiff
path: root/themes/src/shapes_2d.cpp
diff options
context:
space:
mode:
authorMatthew Kosarek <matthew@matthewkosarek.xyz>2023-09-24 17:14:48 -0400
committerMatthew Kosarek <matthew@matthewkosarek.xyz>2023-09-24 17:14:48 -0400
commit2dca902c183ece31bc0853e1e8b93d09359515e4 (patch)
tree2478c63c0aaae3c3ad608334372a9d7a91d9088d /themes/src/shapes_2d.cpp
parentc8c6d9f13b5cae6f93f1e1615bfa484e3fa9b110 (diff)
Rectangular gradient for the background in AutumnTheme
Diffstat (limited to 'themes/src/shapes_2d.cpp')
-rw-r--r--themes/src/shapes_2d.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/themes/src/shapes_2d.cpp b/themes/src/shapes_2d.cpp
new file mode 100644
index 0000000..a85e0da
--- /dev/null
+++ b/themes/src/shapes_2d.cpp
@@ -0,0 +1,39 @@
+#include "shapes_2d.h"
+#include "Renderer2d.h"
+#include "mathlib.h"
+
+RectangularGradient::RectangularGradient(Renderer2d& renderer,
+ Vector4 top,
+ Vector4 bottom,
+ f32 width,
+ f32 height,
+ Vector2 position)
+ : renderer{renderer},
+ top{top},
+ bottom{bottom},
+ width{width},
+ height{height}
+{
+ Vertex2D vertices[6];
+ vertices[0].position = position;
+ vertices[0].color = bottom;
+ vertices[1].position = { position.x + width, position.y };
+ vertices[1].color = bottom;
+ vertices[2].position = { position.x, position.y + height };
+ vertices[2].color = top;
+ vertices[3] = vertices[2];
+ vertices[4] = vertices[1];
+ vertices[5].position = { position.x + width, position.y + height };
+ vertices[5].color = top;
+ mesh.load(vertices, 6, &renderer);
+}
+
+RectangularGradient::~RectangularGradient()
+{
+ mesh.unload();
+}
+
+void RectangularGradient::render()
+{
+ mesh.render(&renderer);
+}