Fluid
Loading...
Searching...
No Matches
geometry.h
Go to the documentation of this file.
1/*
2 * This file is part of Fluid.
3 *
4 * Copyright (C) 2025 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
5 * Copyright (C) 2024-2025 hypengw <hypengwip@gmail.com>
6 *
7 * $BEGIN_LICENSE:MPL2$
8 *
9 * This Source Code Form is subject to the terms of the Mozilla Public
10 * License, v. 2.0. If a copy of the MPL was not distributed with this
11 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 *
13 * $END_LICENSE$
14 */
15
16#pragma once
17
18#include <QSGGeometry>
19#include <QColor>
20#include <QVector4D>
21
22namespace Fluid::SceneGraph {
23
25{
26 // position
27 float x;
28 float y;
29
30 // color
31 float r;
32 float g;
33 float b;
34 float a;
35
36 void setPoint(float x, float y) noexcept
37 {
38 this->x = x;
39 this->y = y;
40 }
41 void setPoint(QVector2D v) noexcept
42 {
43 x = v.x();
44 y = v.y();
45 }
46 void setColor(QRgb c) noexcept
47 {
48 r = qRed(c) / 255.0f;
49 g = qGreen(c) / 255.0f;
50 b = qBlue(c) / 255.0f;
51 a = qAlpha(c) / 255.0f;
52 }
53 void setColor(const QColor &c) noexcept
54 {
55 setColor(c.rgb());
56 }
57};
58
60{
61 // circle edge
62 float ce_x; // if in x edge
63 float ce_y; // if in y edge
64 float ce_distance_to_outter; // from inner rect
65 float ce_distance_to_inner; // from inner rect
66
67 operator QVector2D() const
68 {
69 return { x, y };
70 }
71 operator QColor() const
72 {
73 return QColor::fromRgbF(r, g, b, a);
74 }
75};
76
77std::unique_ptr<QSGGeometry, std::default_delete<QSGGeometry>> createRectangleGeometry();
78
79// tl tr bl br
80void updateRectangleGeometry(RectangleVertex *vertexs, QVector2D size, QRgb color,
81 QVector4D radius);
82
84{
85 // shadow
86 float offset_x;
87 float offset_y;
89
90 void setOffset(QVector2D v) noexcept
91 {
92 offset_x = v.x();
93 offset_y = v.y();
94 }
95};
96
97std::unique_ptr<QSGGeometry, std::default_delete<QSGGeometry>> createShadowGeometry();
98
113
115{
116 QVector3D z_plane_params;
117 QVector3D light_pos;
118 float light_radius{ 0 };
119 QRgb ambient_color{ 0 };
120 QRgb spot_color{ 0 };
121 uint32_t flags{ 0 };
122 QVector4D radius;
123};
124
125void updateShadowGeometry(QSGGeometry *geo, const ShadowParams &params, const QRectF &rect);
126
127} // namespace Fluid::SceneGraph
Definition rectangle.cpp:28
ShadowFlags
Definition geometry.h:99
@ All_ShadowFlag
Definition geometry.h:111
@ DirectionalLight_ShadowFlag
Definition geometry.h:107
@ None_ShadowFlag
Definition geometry.h:100
@ TransparentOccluder_ShadowFlag
Definition geometry.h:103
@ GeometricOnly_ShadowFlag
Definition geometry.h:105
@ ConcaveBlurOnly_ShadowFlag
Definition geometry.h:109
std::unique_ptr< QSGGeometry, std::default_delete< QSGGeometry > > createShadowGeometry()
Definition geometry.cpp:243
std::unique_ptr< QSGGeometry, std::default_delete< QSGGeometry > > createRectangleGeometry()
Definition geometry.cpp:178
void updateShadowGeometry(QSGGeometry *geo, const ShadowParams &params, const QRectF &rect)
Definition geometry.cpp:261
void updateRectangleGeometry(RectangleVertex *vertexs, QVector2D size, QRgb color, QVector4D radius)
Definition geometry.cpp:196
Definition geometry.h:25
void setColor(QRgb c) noexcept
Definition geometry.h:46
void setColor(const QColor &c) noexcept
Definition geometry.h:53
void setPoint(QVector2D v) noexcept
Definition geometry.h:41
float a
Definition geometry.h:34
float r
Definition geometry.h:31
float b
Definition geometry.h:33
float x
Definition geometry.h:27
float g
Definition geometry.h:32
float y
Definition geometry.h:28
void setPoint(float x, float y) noexcept
Definition geometry.h:36
Definition geometry.h:60
float ce_y
Definition geometry.h:63
float ce_distance_to_inner
Definition geometry.h:65
float ce_distance_to_outter
Definition geometry.h:64
float ce_x
Definition geometry.h:62
Definition geometry.h:115
QVector3D z_plane_params
Definition geometry.h:116
QRgb ambient_color
Definition geometry.h:119
float light_radius
Definition geometry.h:118
uint32_t flags
Definition geometry.h:121
QVector3D light_pos
Definition geometry.h:117
QRgb spot_color
Definition geometry.h:120
QVector4D radius
Definition geometry.h:122
Definition geometry.h:84
void setOffset(QVector2D v) noexcept
Definition geometry.h:90
float offset_y
Definition geometry.h:87
float offset_x
Definition geometry.h:86
float distance_correction
Definition geometry.h:88