Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
card10
firmware
Commits
e098bceb
Commit
e098bceb
authored
Aug 23, 2019
by
Rahix
Browse files
Merge branch 'optimize-circle' into 'master'
Optimize circle drawing See merge request
card10/firmware!175
parents
3043832b
bca913c3
Pipeline
#3133
passed with stages
in 1 minute and 2 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/gfx/gfx.c
View file @
e098bceb
...
...
@@ -135,12 +135,12 @@ void gfx_clear(struct gfx_region *reg)
void
gfx_circle
(
struct
gfx_region
*
reg
,
int
x
,
int
y
,
int
r
,
int
t
,
Color
c
)
{
int
outer
=
(
r
+
t
)
*
(
r
+
t
);
int
inner
=
r
*
r
;
for
(
int
y_
=
y
-
r
-
t
;
y_
<=
y
+
r
+
t
;
y_
++
)
{
for
(
int
x_
=
x
-
r
-
t
;
x_
<=
x
+
r
+
t
;
x_
++
)
{
int
dx
=
(
x_
-
x
)
*
(
x_
-
x
);
int
dy
=
(
y_
-
y
)
*
(
y_
-
y
);
int
outer
=
(
r
+
t
)
*
(
r
+
t
);
int
inner
=
r
*
r
;
int
dx
=
(
x_
-
x
)
*
(
x_
-
x
);
int
dy
=
(
y_
-
y
)
*
(
y_
-
y
);
int
edge
=
((
dx
+
dy
)
>=
inner
)
&&
((
dx
+
dy
)
<=
outer
);
if
(
edge
)
gfx_setpixel
(
reg
,
x_
,
y_
,
c
);
...
...
@@ -150,11 +150,11 @@ void gfx_circle(struct gfx_region *reg, int x, int y, int r, int t, Color c)
void
gfx_circle_fill
(
struct
gfx_region
*
reg
,
int
x
,
int
y
,
int
r
,
Color
c
)
{
int
edge
=
r
*
r
;
for
(
int
y_
=
y
-
r
;
y_
<=
y
+
r
;
y_
++
)
{
for
(
int
x_
=
x
-
r
;
x_
<=
x
+
r
;
x_
++
)
{
int
dx
=
(
x_
-
x
)
*
(
x_
-
x
);
int
dy
=
(
y_
-
y
)
*
(
y_
-
y
);
int
edge
=
r
*
r
;
int
fill
=
(
dx
+
dy
)
<=
edge
;
if
(
fill
)
gfx_setpixel
(
reg
,
x_
,
y_
,
c
);
...
...
Write
Preview
Supports
Markdown
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