Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hqr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Show more breadcrumbs
solverstack
hqr
Commits
d02d9e85
Commit
d02d9e85
authored
8 years ago
by
BOUCHERIE Raphael
Browse files
Options
Downloads
Patches
Plain Diff
Updated drawinf functions, added factorisation parameters, allowing to change color
parent
3326debb
No related branches found
No related tags found
1 merge request
!4
Treewalk
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/libdraw.h
+2
-3
2 additions, 3 deletions
include/libdraw.h
src/treedraw.c
+35
-7
35 additions, 7 deletions
src/treedraw.c
testings/testing_treedraw.c
+6
-5
6 additions, 5 deletions
testings/testing_treedraw.c
with
43 additions
and
15 deletions
include/libdraw.h
+
2
−
3
View file @
d02d9e85
...
...
@@ -27,10 +27,9 @@ BEGIN_C_DECLS
*/
void
libhqr_writeheader
(
FILE
*
tree
);
void
libhqr_writecss
();
void
libhqr_writeend
(
FILE
*
tree
);
void
libhqr_drawTT
(
int
x
,
int
y
,
int
w
,
int
h
,
FILE
*
tree
);
void
libhqr_drawTS
(
int
x
,
int
y
,
int
w
,
int
h
,
FILE
*
tree
);
void
libhqr_drawTT
(
int
x
,
int
y
,
int
w
,
int
h
,
int
k
,
FILE
*
tree
);
void
libhqr_drawTS
(
int
x
,
int
y
,
int
w
,
int
h
,
int
k
,
FILE
*
tree
);
void
libhqr_drawline
(
int
x1
,
int
y1
,
int
x2
,
int
y2
,
FILE
*
tree
);
END_C_DECLS
...
...
This diff is collapsed.
Click to expand it.
src/treedraw.c
+
35
−
7
View file @
d02d9e85
...
...
@@ -28,14 +28,42 @@ void libhqr_writeheader(FILE *tree){
if
(
fprintf
(
tree
,
"<svg width=
\"
2000
\"
height=
\"
2000
\"
version=
\"
1.1
\"
\n
xmlns=
\"
http://www.w3.org/2000/svg
\"
>
\n
"
)
<
0
)
return
;
}
void
libhqr_writecss
();
void
libhqr_drawTT
(
int
x
,
int
y
,
int
w
,
int
h
,
FILE
*
tree
){
if
(
fprintf
(
tree
,
"<rect x=
\"
%d
\"
y=
\"
%d
\"
width=
\"
%d
\"
height=
\"
%d
\"
fill=
\"
red
\"
/>
\n
"
,
x
,
y
,
w
,
h
)
<
0
)
return
;
void
libhqr_drawTT
(
int
x
,
int
y
,
int
w
,
int
h
,
int
k
,
FILE
*
tree
){
switch
(
k
%
4
){
case
0
:
if
(
fprintf
(
tree
,
"<rect x=
\"
%d
\"
y=
\"
%d
\"
width=
\"
%d
\"
height=
\"
%d
\"
fill=
\"
red
\"
/>
\n
"
,
x
,
y
,
w
,
h
)
<
0
)
return
;
break
;
case
1
:
if
(
fprintf
(
tree
,
"<rect x=
\"
%d
\"
y=
\"
%d
\"
width=
\"
%d
\"
height=
\"
%d
\"
fill=
\"
blue
\"
/>
\n
"
,
x
,
y
,
w
,
h
)
<
0
)
return
;
break
;
case
2
:
if
(
fprintf
(
tree
,
"<rect x=
\"
%d
\"
y=
\"
%d
\"
width=
\"
%d
\"
height=
\"
%d
\"
fill=
\"
green
\"
/>
\n
"
,
x
,
y
,
w
,
h
)
<
0
)
return
;
break
;
case
3
:
if
(
fprintf
(
tree
,
"<rect x=
\"
%d
\"
y=
\"
%d
\"
width=
\"
%d
\"
height=
\"
%d
\"
fill=
\"
black
\"
/>
\n
"
,
x
,
y
,
w
,
h
)
<
0
)
return
;
break
;
default:
return
;
}
}
void
libhqr_drawTS
(
int
x
,
int
y
,
int
w
,
int
h
,
FILE
*
tree
){
if
(
fprintf
(
tree
,
"<rect x=
\"
%d
\"
y=
\"
%d
\"
width=
\"
%d
\"
height=
\"
%d
\"
fill =
\"
red
\"
/>
\n
"
,
x
,
y
,
w
,
h
)
<
0
)
return
;
void
libhqr_drawTS
(
int
x
,
int
y
,
int
w
,
int
h
,
int
k
,
FILE
*
tree
){
switch
(
k
%
4
){
case
0
:
if
(
fprintf
(
tree
,
"<rect x=
\"
%d
\"
y=
\"
%d
\"
width=
\"
%d
\"
height=
\"
%d
\"
fill=
\"
red
\"
/>
\n
"
,
x
,
y
,
w
,
h
)
<
0
)
return
;
break
;
case
1
:
if
(
fprintf
(
tree
,
"<rect x=
\"
%d
\"
y=
\"
%d
\"
width=
\"
%d
\"
height=
\"
%d
\"
fill=
\"
blue
\"
/>
\n
"
,
x
,
y
,
w
,
h
)
<
0
)
return
;
break
;
case
2
:
if
(
fprintf
(
tree
,
"<rect x=
\"
%d
\"
y=
\"
%d
\"
width=
\"
%d
\"
height=
\"
%d
\"
fill=
\"
green
\"
/>
\n
"
,
x
,
y
,
w
,
h
)
<
0
)
return
;
break
;
case
3
:
if
(
fprintf
(
tree
,
"<rect x=
\"
%d
\"
y=
\"
%d
\"
width=
\"
%d
\"
height=
\"
%d
\"
fill=
\"
black
\"
/>
\n
"
,
x
,
y
,
w
,
h
)
<
0
)
return
;
break
;
default:
return
;
}
int
x2
=
x
+
(
w
/
4
);
int
y2
=
y
+
(
h
/
4
);
int
w2
=
(
w
/
2
);
...
...
@@ -44,7 +72,7 @@ void libhqr_drawTS(int x, int y, int w, int h, FILE *tree){
}
void
libhqr_drawline
(
int
x1
,
int
y1
,
int
x2
,
int
y2
,
FILE
*
tree
){
if
(
fprintf
(
tree
,
"<line x1=
\"
%d
\"
y1=
\"
%d
\"
x2=
\"
%d
\"
y2=
\"
%d
\"
/>
\n
"
,
x1
,
y1
,
x2
,
y2
)
<
0
)
return
;
if
(
fprintf
(
tree
,
"<line x1=
\"
%d
\"
y1=
\"
%d
\"
x2=
\"
%d
\"
y2=
\"
%d
\"
style=
\"
fill:none;stroke:black;stroke-width:2px;
\"
/>
\n
"
,
x1
,
y1
,
x2
,
y2
)
<
0
)
return
;
}
void
libhqr_writeend
(
FILE
*
tree
){
...
...
This diff is collapsed.
Click to expand it.
testings/testing_treedraw.c
+
6
−
5
View file @
d02d9e85
...
...
@@ -19,20 +19,21 @@
#include
<string.h>
#include
"libdraw.h"
#define WIDTH 50
#define HEIGHT 50
int
main
(
int
argc
,
char
**
argv
)
{
FILE
*
tree
=
fopen
(
"tree.svg"
,
"w+"
);
int
x
,
y
,
w
,
h
,
i
,
j
;
w
=
50
;
h
=
50
;
int
x
,
y
,
i
,
j
;
libhqr_writeheader
(
tree
);
libhqr_drawline
(
125
,
100
,
125
,
800
,
tree
);
for
(
i
=
1
;
i
<
5
;
i
++
){
for
(
j
=
1
;
j
<
9
;
j
++
){
x
=
100
*
i
;
y
=
100
*
j
;
libhqr_drawline
(
x
,
y
,
w
,
h
,
tree
);
libhqr_drawTS
(
x
,
y
,
w
,
h
,
tree
);
libhqr_drawTS
(
x
,
y
,
WIDTH
,
HEIGHT
,
1
,
tree
);
}
}
libhqr_writeend
(
tree
);
...
...
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