Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
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
Model registry
Operate
Environments
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
09ad9143
Commit
09ad9143
authored
18 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
better rgb/hsv conversion
parent
1bfe2b6a
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
Common/ColorTable.cpp
+33
-54
33 additions, 54 deletions
Common/ColorTable.cpp
doc/TODO
+8
-1
8 additions, 1 deletion
doc/TODO
with
41 additions
and
55 deletions
Common/ColorTable.cpp
+
33
−
54
View file @
09ad9143
// $Id: ColorTable.cpp,v 1.3
1
2006-0
1-06 00:34:20
geuzaine Exp $
// $Id: ColorTable.cpp,v 1.3
2
2006-0
8-25 23:01:16
geuzaine Exp $
//
//
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
//
//
...
@@ -424,62 +424,41 @@ int ColorTable_IsAlpha(GmshColorTable * ct)
...
@@ -424,62 +424,41 @@ int ColorTable_IsAlpha(GmshColorTable * ct)
// HSV/RBG conversion routines
// HSV/RBG conversion routines
#define UNDEFINED 0
void
HSV_to_RGB
(
double
H
,
double
S
,
double
V
,
double
*
R
,
double
*
G
,
double
*
B
)
// rgb on [0, 1], sv returned on [0, 1] and h on [0, 6].
// Exception: h is returned UNDEFINED if S==0.
#define RETURN_HSV(h,s,v) {*H=h; *S=s; *V=v; return;}
void
RGB_to_HSV
(
double
R
,
double
G
,
double
B
,
double
*
H
,
double
*
S
,
double
*
V
)
{
{
double
v
,
x
,
f
;
if
(
S
<
5.0e-6
)
{
int
i
;
*
R
=
*
G
=
*
B
=
V
;
}
x
=
DMIN
(
DMIN
(
R
,
G
),
B
);
else
{
v
=
DMAX
(
DMAX
(
R
,
G
),
B
);
int
i
=
(
int
)
H
;
if
(
v
==
x
)
double
f
=
H
-
(
float
)
i
;
RETURN_HSV
(
UNDEFINED
,
0
,
v
);
double
p1
=
V
*
(
1.0
-
S
);
f
=
(
R
==
x
)
?
G
-
B
:
((
G
==
x
)
?
B
-
R
:
R
-
G
);
double
p2
=
V
*
(
1.0
-
S
*
f
);
i
=
(
R
==
x
)
?
3
:
((
G
==
x
)
?
5
:
1
);
double
p3
=
V
*
(
1.0
-
S
*
(
1.0
-
f
));
RETURN_HSV
(
i
-
f
/
(
v
-
x
),
(
v
-
x
)
/
v
,
v
);
switch
(
i
){
case
0
:
*
R
=
V
;
*
G
=
p3
;
*
B
=
p1
;
break
;
case
1
:
*
R
=
p2
;
*
G
=
V
;
*
B
=
p1
;
break
;
case
2
:
*
R
=
p1
;
*
G
=
V
;
*
B
=
p3
;
break
;
case
3
:
*
R
=
p1
;
*
G
=
p2
;
*
B
=
V
;
break
;
case
4
:
*
R
=
p3
;
*
G
=
p1
;
*
B
=
V
;
break
;
case
5
:
*
R
=
V
;
*
G
=
p1
;
*
B
=
p2
;
break
;
}
}
}
}
// h given on [0, 6] or UNDEFINED. s and v given on [0, 1].
void
RGB_to_HSV
(
double
R
,
double
G
,
double
B
,
// rgb each returned on [0, 1].
double
*
H
,
double
*
S
,
double
*
V
)
#define RETURN_RGB(r,g,b) {*R=r; *G=g; *B=b; return;}
void
HSV_to_RGB
(
double
H
,
double
S
,
double
V
,
double
*
R
,
double
*
G
,
double
*
B
)
{
{
double
m
,
n
,
f
;
double
maxv
=
R
>
G
?
R
:
G
;
if
(
B
>
maxv
)
maxv
=
B
;
int
i
;
*
V
=
maxv
;
if
(
maxv
>
0
){
if
(
H
==
UNDEFINED
)
double
minv
=
R
<
G
?
R
:
G
;
if
(
B
<
minv
)
minv
=
B
;
RETURN_RGB
(
V
,
V
,
V
);
*
S
=
1.0
-
double
(
minv
)
/
maxv
;
i
=
(
int
)
floor
(
H
);
if
(
maxv
>
minv
){
f
=
H
-
i
;
if
(
maxv
==
R
){
*
H
=
(
G
-
B
)
/
double
(
maxv
-
minv
);
if
(
*
H
<
0
)
*
H
+=
6.0
;
}
if
(
!
(
i
&
1
))
else
if
(
maxv
==
G
)
*
H
=
2.0
+
(
B
-
R
)
/
double
(
maxv
-
minv
);
f
=
1
-
f
;
// if i is even
else
*
H
=
4.0
+
(
R
-
G
)
/
double
(
maxv
-
minv
);
m
=
V
*
(
1
-
S
);
}
n
=
V
*
(
1
-
S
*
f
);
switch
(
i
)
{
case
6
:
case
0
:
RETURN_RGB
(
V
,
n
,
m
);
case
1
:
RETURN_RGB
(
n
,
V
,
m
);
case
2
:
RETURN_RGB
(
m
,
V
,
n
);
case
3
:
RETURN_RGB
(
m
,
n
,
V
);
case
4
:
RETURN_RGB
(
n
,
m
,
V
);
case
5
:
RETURN_RGB
(
V
,
m
,
n
);
}
}
}
}
This diff is collapsed.
Click to expand it.
doc/TODO
+
8
−
1
View file @
09ad9143
$Id: TODO,v 1.15 2006-08-22 17:47:08 geuzaine Exp $
$Id: TODO,v 1.16 2006-08-25 23:01:16 geuzaine Exp $
********************************************************************
add a "Box" tab to the clipping plane dialog to create a clip
box in one step (instead of defining 6 planes)
********************************************************************
extrude along a given function (e.g. radius to extrude a sphere)
extrude along a given function (e.g. radius to extrude a sphere)
...
...
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