Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Game Library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Game Development
Game Library
Commits
ab953fbc
Commit
ab953fbc
authored
2 years ago
by
Joseph Walton-Rivers
Browse files
Options
Downloads
Patches
Plain Diff
some colour utilities
parent
743b49b0
No related branches found
No related tags found
No related merge requests found
Pipeline
#3323
failed
2 years ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fggl/gui/containers.cpp
+1
-3
1 addition, 3 deletions
fggl/gui/containers.cpp
include/fggl/gui/widget.hpp
+37
-0
37 additions, 0 deletions
include/fggl/gui/widget.hpp
with
38 additions
and
3 deletions
fggl/gui/containers.cpp
+
1
−
3
View file @
ab953fbc
...
...
@@ -54,11 +54,9 @@ namespace fggl::gui {
}*/
void
Panel
::
render
(
gfx
::
Paint
&
paint
)
{
spdlog
::
info
(
"Imma render mah panel! {}, {}"
,
bottomRight
().
x
,
bottomRight
().
y
);
// background painting time
gfx
::
Path2D
background
(
topLeft
());
background
.
colour
(
math
::
vec3
(
1.0
F
,
1.0
F
,
0
.0
F
));
background
.
colour
(
math
::
vec3
(
32.0
f
/
255.0
f
,
74.0
F
/
255.0
F
,
135.0
F
/
255
.0
F
));
draw_box
(
background
,
topLeft
(),
bottomRight
());
paint
.
fill
(
background
);
...
...
This diff is collapsed.
Click to expand it.
include/fggl/gui/widget.hpp
+
37
−
0
View file @
ab953fbc
...
...
@@ -8,6 +8,43 @@
namespace
fggl
::
gui
{
constexpr
float
RGB_MAX_VAL
=
255.0
F
;
constexpr
math
::
vec3
rgbToNormal
(
char
red
,
char
green
,
char
blue
)
{
return
{
red
/
RGB_MAX_VAL
,
green
/
RGB_MAX_VAL
,
blue
/
RGB_MAX_VAL
};
}
/**
* Convert a Hue-saturation-value colour to RGB
*
* @param hue hue component, assumed 0 - 360
* @param saturation assumed 0 - 1
* @param value assumed 0 - 1
* @return RGB, in the range 0,1 for each component
*/
constexpr
math
::
vec3
HSVtoNormal
(
float
hue
,
float
saturation
,
float
value
)
{
assert
(
0
<
hue
&&
hue
<=
360
);
assert
(
0
<
saturation
&&
saturation
<=
1
);
assert
(
0
<
value
&&
value
<=
1
);
const
float
chroma
=
value
*
saturation
;
const
float
x
=
chroma
*
(
1
-
fabs
(
fmod
(
hue
/
60.0
F
,
2
)
-
1
)
);
math
::
vec3
tmp
{
0
,
0
,
0
};
if
(
0
<=
hue
&&
hue
<
60
)
{
tmp
=
{
chroma
,
x
,
0
};
}
else
if
(
60
<=
hue
&&
hue
<
120
)
{
tmp
=
{
x
,
chroma
,
0
};
}
else
if
(
120
<=
hue
&&
hue
<
180
)
{
tmp
=
{
0
,
chroma
,
x
};
}
else
if
(
180
<=
hue
&&
hue
<
240
)
{
tmp
=
{
0
,
x
,
chroma
};
}
else
if
(
240
<=
hue
&&
hue
<
300
)
{
tmp
=
{
x
,
0
,
chroma
};
}
else
if
(
300
<=
hue
&&
hue
<
360
)
{
tmp
=
{
chroma
,
0
,
x
};
}
return
tmp
+
(
value
-
chroma
);
}
void
draw_box
(
gfx
::
Path2D
&
path
,
math
::
vec2
topLeft
,
math
::
vec2
bottomRight
);
void
draw_progress
(
gfx
::
Path2D
&
path
,
math
::
vec2
topLeft
,
math
::
vec2
size
,
float
value
);
void
draw_slider
(
gfx
::
Path2D
&
path
,
math
::
vec2
topLeft
,
math
::
vec2
size
,
float
value
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment