Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mandelbrot-explorer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ильин Владимир Александрович
mandelbrot-explorer
Commits
27f0ca93
Commit
27f0ca93
authored
Feb 17, 2025
by
Ильин Владимир Александрович
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed reset button in turn of R key
parent
44346766
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
33 deletions
+9
-33
ui.o
build/ui.o
+0
-0
mandelbrot
mandelbrot
+0
-0
mandelbrot.c
src/mandelbrot.c
+7
-3
ui.c
src/ui.c
+2
-29
ui.h
src/ui.h
+0
-1
No files found.
build/ui.o
View file @
27f0ca93
No preview for this file type
mandelbrot
View file @
27f0ca93
No preview for this file type
src/mandelbrot.c
View file @
27f0ca93
...
...
@@ -112,9 +112,6 @@ main(int argc, char *argv[])
SDL_Event
event
;
while
(
SDL_PollEvent
(
&
event
))
{
if
(
handle_ui_event
(
&
ui
,
event
,
&
view
))
continue
;
switch
(
event
.
type
)
{
case
SDL_QUIT
:
...
...
@@ -146,6 +143,13 @@ main(int argc, char *argv[])
view
.
y_max
=
view
.
y_max
*
0
.
9
;
view
.
zoom
=
view
.
zoom
*
0
.
9
;
break
;
case
SDL_SCANCODE_R
:
view
.
x_min
=
-
2
.
0
;
view
.
x_max
=
1
.
0
;
view
.
y_min
=
-
1
.
5
;
view
.
y_max
=
1
.
5
;
view
.
zoom
=
1
.
0
;
break
;
}
default:
handle_mouse
(
event
,
&
mouse
,
&
view
);
...
...
src/ui.c
View file @
27f0ca93
...
...
@@ -22,13 +22,10 @@ render_text(SDL_Renderer* renderer, TTF_Font* font, const char* text, SDL_Rect*
void
init_ui
(
UI
*
ui
)
{
ui
->
reset_button
=
(
SDL_Rect
){
UI_PADDING
,
UI_PADDING
,
BUTTON_WIDTH
,
BUTTON_HEIGHT
};
ui
->
zoom_display
=
(
SDL_Rect
){
UI_PADDING
,
UI_PADDING
,
BUTTON_WIDTH
,
BUTTON_HEIGHT
};
ui
->
zoom_display
=
(
SDL_Rect
){
UI_PADDING
,
UI_PADDING
*
2
+
BUTTON_HEIGHT
,
ui
->
fps_display
=
(
SDL_Rect
){
UI_PADDING
,
UI_PADDING
*
2
+
BUTTON_HEIGHT
,
BUTTON_WIDTH
,
BUTTON_HEIGHT
};
ui
->
fps_display
=
(
SDL_Rect
){
UI_PADDING
,
UI_PADDING
*
3
+
BUTTON_HEIGHT
*
2
,
BUTTON_WIDTH
,
BUTTON_HEIGHT
};
TTF_Init
();
ui
->
font
=
TTF_OpenFont
(
"/usr/share/fonts/nerdfonts/TerminessNerdFont-Regular.ttf"
,
FONT_SIZE
);
if
(
!
ui
->
font
)
{
...
...
@@ -40,47 +37,23 @@ void
render_ui
(
UI
*
ui
,
SDL_Renderer
*
renderer
,
ViewInfo
view
,
float
fps
)
{
SDL_SetRenderDrawColor
(
renderer
,
60
,
60
,
60
,
UI_ALPHA
);
SDL_RenderFillRect
(
renderer
,
&
ui
->
reset_button
);
SDL_RenderFillRect
(
renderer
,
&
ui
->
zoom_display
);
SDL_RenderFillRect
(
renderer
,
&
ui
->
fps_display
);
SDL_SetRenderDrawColor
(
renderer
,
255
,
255
,
255
,
UI_ALPHA
);
SDL_RenderDrawRect
(
renderer
,
&
ui
->
reset_button
);
SDL_RenderDrawRect
(
renderer
,
&
ui
->
zoom_display
);
SDL_RenderDrawRect
(
renderer
,
&
ui
->
fps_display
);
if
(
ui
->
font
)
{
render_text
(
renderer
,
ui
->
font
,
"Reset"
,
&
ui
->
reset_button
);
char
buf
[
32
];
snprintf
(
buf
,
sizeof
(
buf
),
"Zoom: %.2fx"
,
view
.
zoom
);
render_text
(
renderer
,
ui
->
font
,
buf
,
&
ui
->
zoom_display
);
snprintf
(
buf
,
sizeof
(
buf
),
"Fps: %f"
,
fps
);
render_text
(
renderer
,
ui
->
font
,
buf
,
&
ui
->
fps_display
);
}
}
int
handle_ui_event
(
UI
*
ui
,
SDL_Event
event
,
ViewInfo
*
view
)
{
if
(
event
.
type
==
SDL_MOUSEBUTTONDOWN
&&
event
.
button
.
button
==
SDL_BUTTON_LEFT
)
{
int
x
=
event
.
button
.
x
;
int
y
=
event
.
button
.
y
;
if
(
SDL_PointInRect
(
&
(
SDL_Point
){
x
,
y
},
&
ui
->
reset_button
))
{
view
->
x_min
=
-
2
.
0
;
view
->
x_max
=
1
.
0
;
view
->
y_min
=
-
1
.
5
;
view
->
y_max
=
1
.
5
;
view
->
zoom
=
1
.
0
;
return
1
;
}
}
return
0
;
}
void
cleanup_ui
(
UI
*
ui
)
{
if
(
ui
->
font
)
{
...
...
src/ui.h
View file @
27f0ca93
...
...
@@ -15,7 +15,6 @@
typedef
struct
{
SDL_Rect
reset_button
;
SDL_Rect
zoom_display
;
SDL_Rect
fps_display
;
TTF_Font
*
font
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment