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
Onuralp SEZER
Game Library
Commits
89f75b27
Commit
89f75b27
authored
2 years ago
by
Joseph Walton-Rivers
Browse files
Options
Downloads
Patches
Plain Diff
added some arc-generation code for use as progress bars
parent
df9139fb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
demo/demo/grid.cpp
+17
-0
17 additions, 0 deletions
demo/demo/grid.cpp
include/fggl/gfx/paint.hpp
+26
-1
26 additions, 1 deletion
include/fggl/gfx/paint.hpp
with
43 additions
and
1 deletion
demo/demo/grid.cpp
+
17
−
0
View file @
89f75b27
...
...
@@ -55,6 +55,7 @@ namespace demo {
}
}
float
progress
=
0.0
f
;
void
GridScene
::
render
(
fggl
::
gfx
::
Graphics
&
gfx
)
{
Game
::
render
(
gfx
);
...
...
@@ -67,6 +68,22 @@ namespace demo {
paint
.
fill
(
hexTest
);
}
// draw test arcs
for
(
int
sides
=
0
;
sides
<
12
;
++
sides
)
{
float
endAngle
=
progress
*
(
M_PI
*
2
);
float
startAngle
=
sides
/
12.0
F
*
(
M_PI
*
2
);
float
endAngle2
=
endAngle
+
startAngle
;
auto
hexTest
=
fggl
::
gfx
::
make_arc
(
fggl
::
math
::
vec2
{
sides
+
3
,
7
}
*
DRAW_SIZE
,
DRAW_HALF
,
startAngle
,
endAngle2
,
fggl
::
gfx
::
colours
::
CYAN
);
paint
.
fill
(
hexTest
);
}
progress
+=
0.01
F
;
if
(
progress
>
1.0
F
)
{
progress
=
0.0
F
;
}
gfx
.
draw2D
(
paint
);
}
...
...
This diff is collapsed.
Click to expand it.
include/fggl/gfx/paint.hpp
+
26
−
1
View file @
89f75b27
...
...
@@ -97,7 +97,7 @@ namespace fggl::gfx {
bool
sinFirst
=
true
;
};
inline
Path2D
make_shape
(
math
::
vec2
center
,
float
radius
,
int
sides
,
math
::
vec3
colour
=
{
1.0
f
,
1.0
f
,
1.0
f
}
,
ShapeOpts
opts
=
{})
{
inline
Path2D
make_shape
(
math
::
vec2
center
,
float
radius
,
int
sides
,
math
::
vec3
colour
=
colours
::
WHITE
,
ShapeOpts
opts
=
{})
{
double
angle
=
(
M_PI
*
2.0
)
/
sides
;
fggl
::
gfx
::
Path2D
tileGfx
(
center
);
...
...
@@ -119,6 +119,31 @@ namespace fggl::gfx {
return
tileGfx
;
}
inline
Path2D
make_arc
(
math
::
vec2
center
,
float
radius
,
float
start
,
float
end
,
math
::
vec3
colour
=
colours
::
WHITE
,
int
slices
=
25
)
{
const
float
angle
=
(
M_PI
*
2.0
)
/
slices
;
fggl
::
gfx
::
Path2D
tileGfx
(
center
);
tileGfx
.
colour
(
colour
);
tileGfx
.
moveTo
(
center
);
for
(
float
totalAngle
=
start
;
totalAngle
<
end
;
totalAngle
+=
angle
)
{
// NOLINT(cert-flp30-c)
float
xPos
=
(
float
)(
sinf
(
totalAngle
)
*
radius
)
+
center
.
x
;
float
yPos
=
(
float
)(
cosf
(
totalAngle
)
*
radius
)
+
center
.
y
;
tileGfx
.
pathTo
({
xPos
,
yPos
});
if
(
(
totalAngle
+
angle
)
>
end
)
{
break
;
}
}
{
float
xPos
=
(
float
)
(
sinf
(
end
)
*
radius
)
+
center
.
x
;
float
yPos
=
(
float
)
(
cosf
(
end
)
*
radius
)
+
center
.
y
;
tileGfx
.
pathTo
(
{
xPos
,
yPos
}
);
}
tileGfx
.
close
();
return
tileGfx
;
}
enum
class
PaintType
{
FILL
,
STROKE
...
...
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