Fluid 1.3.0
Material Design for QtQuick and Qml
Loading...
Searching...
No Matches
geometry.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// SPDX-FileCopyrightText: 2024-2025 hypengw <hypengwip@gmail.com>
3// SPDX-License-Identifier: MPL-2.0
4
5#pragma once
6
7#include <QSGGeometry>
8#include <QColor>
9#include <QVector4D>
10
11namespace Fluid::SceneGraph {
12
14{
15 // position
16 float x;
17 float y;
18
19 // color
20 float r;
21 float g;
22 float b;
23 float a;
24
25 void setPoint(float x, float y) noexcept
26 {
27 this->x = x;
28 this->y = y;
29 }
30 void setPoint(QVector2D v) noexcept
31 {
32 x = v.x();
33 y = v.y();
34 }
35 void setColor(QRgb c) noexcept
36 {
37 r = qRed(c) / 255.0f;
38 g = qGreen(c) / 255.0f;
39 b = qBlue(c) / 255.0f;
40 a = qAlpha(c) / 255.0f;
41 }
42 void setColor(const QColor &c) noexcept
43 {
44 setColor(c.rgb());
45 }
46};
47
49{
50 // circle edge
51 float ce_x; // if in x edge
52 float ce_y; // if in y edge
53 float ce_distance_to_outter; // from inner rect
54 float ce_distance_to_inner; // from inner rect
55
56 operator QVector2D() const
57 {
58 return { x, y };
59 }
60 operator QColor() const
61 {
62 return QColor::fromRgbF(r, g, b, a);
63 }
64};
65
66std::unique_ptr<QSGGeometry, std::default_delete<QSGGeometry>> createRectangleGeometry();
67
68// tl tr bl br
69void updateRectangleGeometry(RectangleVertex *vertexs, QVector2D size, QRgb color,
70 QVector4D radius);
71
73{
74 // shadow
75 float offset_x;
76 float offset_y;
78
79 void setOffset(QVector2D v) noexcept
80 {
81 offset_x = v.x();
82 offset_y = v.y();
83 }
84};
85
86std::unique_ptr<QSGGeometry, std::default_delete<QSGGeometry>> createShadowGeometry();
87
102
104{
105 QVector3D z_plane_params;
106 QVector3D light_pos;
107 float light_radius{ 0 };
108 QRgb ambient_color{ 0 };
109 QRgb spot_color{ 0 };
110 uint32_t flags{ 0 };
111 QVector4D radius;
112};
113
114void updateShadowGeometry(QSGGeometry *geo, const ShadowParams &params, const QRectF &rect);
115
116} // namespace Fluid::SceneGraph
@ DirectionalLight_ShadowFlag
Definition geometry.h:96
@ TransparentOccluder_ShadowFlag
Definition geometry.h:92
@ ConcaveBlurOnly_ShadowFlag
Definition geometry.h:98
std::unique_ptr< QSGGeometry, std::default_delete< QSGGeometry > > createShadowGeometry()
Definition geometry.cpp:232
std::unique_ptr< QSGGeometry, std::default_delete< QSGGeometry > > createRectangleGeometry()
Definition geometry.cpp:167
void updateShadowGeometry(QSGGeometry *geo, const ShadowParams &params, const QRectF &rect)
Definition geometry.cpp:250
void updateRectangleGeometry(RectangleVertex *vertexs, QVector2D size, QRgb color, QVector4D radius)
Definition geometry.cpp:185
void setColor(QRgb c) noexcept
Definition geometry.h:35
void setColor(const QColor &c) noexcept
Definition geometry.h:42
void setPoint(QVector2D v) noexcept
Definition geometry.h:30
void setPoint(float x, float y) noexcept
Definition geometry.h:25
void setOffset(QVector2D v) noexcept
Definition geometry.h:79