Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
phys_tp_elec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
boris.stefanov
phys_tp_elec
Merge requests
!1
Gfx
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Gfx
gfx
into
main
Overview
0
Commits
9
Pipelines
0
Changes
10
Merged
joey.martig
requested to merge
gfx
into
main
2 years ago
Overview
0
Commits
9
Pipelines
0
Changes
10
Expand
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
32342971
9 commits,
2 years ago
10 files
+
164
−
57
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
10
Search (e.g. *.vue) (Ctrl+P)
src/draw.c
0 → 100644
+
66
−
0
Options
#include
"../utils/gfx/gfx.h"
#include
"field.h"
/*
(50, 50) → (75, 50)1 , (50, 50) → (72, 62), (50, 50) → (62, 72)
(50, 50) → (50, 75), (50, 50) → (38, 72), (50, 50) → (28, 62)
(50, 50) → (25, 50), (50, 50) → (28, 38), (50, 50) → (37, 28)
(50, 50) → (50, 25), (50, 50) → (62, 28), (50, 50) → (72, 37)
*/
void
gfx_draw_line
(
struct
gfx_context_t
*
ctxt
,
coordinates_t
p0
,
coordinates_t
p1
,
uint32_t
color
)
{
int
dx
=
abs
(
p1
.
column
-
p0
.
column
);
int
sx
=
p0
.
column
<
p1
.
column
?
1
:
-
1
;
int
dy
=
-
abs
(
p1
.
row
-
p0
.
row
);
int
sy
=
p0
.
row
<
p1
.
row
?
1
:
-
1
;
int
error
=
dx
+
dy
;
while
(
true
)
{
gfx_putpixel
(
ctxt
,
p0
.
column
,
p0
.
row
,
color
);
if
(
p0
.
column
==
p1
.
column
&&
p0
.
row
==
p1
.
row
)
break
;
int
e2
=
2
*
error
;
if
(
e2
>=
dy
)
{
if
(
p0
.
column
==
p1
.
column
)
break
;
error
=
error
+
dy
;
p0
.
column
=
p0
.
column
+
sx
;
}
if
(
e2
<=
dx
)
{
if
(
p0
.
row
==
p1
.
row
)
break
;
error
=
error
+
dx
;
p0
.
row
=
p0
.
row
+
sy
;
}
}
}
void
gfx_draw_circle
(
struct
gfx_context_t
*
ctxt
,
coordinates
c
,
uint32_t
r
,
uint32_t
color
)
{
int
x
=
0
;
int
y
=
r
;
int
d
=
r
-
1
;
while
(
y
>=
x
){
gfx_putpixel
(
ctxt
,
c
.
row
+
x
,
c
.
column
+
y
,
color
);
gfx_putpixel
(
ctxt
,
c
.
row
+
y
,
c
.
column
+
x
,
color
);
gfx_putpixel
(
ctxt
,
c
.
row
-
x
,
c
.
column
+
y
,
color
);
gfx_putpixel
(
ctxt
,
c
.
row
-
y
,
c
.
column
+
x
,
color
);
gfx_putpixel
(
ctxt
,
c
.
row
+
x
,
c
.
column
-
y
,
color
);
gfx_putpixel
(
ctxt
,
c
.
row
+
y
,
c
.
column
-
x
,
color
);
gfx_putpixel
(
ctxt
,
c
.
row
-
x
,
c
.
column
-
y
,
color
);
gfx_putpixel
(
ctxt
,
c
.
row
-
y
,
c
.
column
-
x
,
color
);
if
(
d
>=
2
*
x
){
d
=
d
-
2
*
x
-
1
;
x
++
;
}
else
if
(
d
<
2
*
(
r
-
y
)){
d
=
d
+
2
*
y
-
1
;
y
--
;
}
else
{
d
=
d
+
2
*
(
y
-
x
-
1
);
y
--
;
x
++
;
}
}
}
Loading