Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
861ea059
Commit
861ea059
authored
Jul 17, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Different approach to coloring netname labels.
parent
f4114d22
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
16 deletions
+43
-16
color4d.h
include/gal/color4d.h
+36
-12
pcb_painter.cpp
pcbnew/pcb_painter.cpp
+7
-4
No files found.
include/gal/color4d.h
View file @
861ea059
...
...
@@ -82,9 +82,9 @@ public:
*/
COLOR4D
&
Highlight
(
double
aFactor
)
{
r
=
(
double
)
r
*
(
1
.
0
-
aFactor
)
+
aFactor
;
g
=
(
double
)
g
*
(
1
.
0
-
aFactor
)
+
aFactor
;
b
=
(
double
)
b
*
(
1
.
0
-
aFactor
)
+
aFactor
;
r
=
r
*
(
1
.
0
-
aFactor
)
+
aFactor
;
g
=
g
*
(
1
.
0
-
aFactor
)
+
aFactor
;
b
=
b
*
(
1
.
0
-
aFactor
)
+
aFactor
;
return
*
this
;
}
...
...
@@ -97,9 +97,23 @@ public:
*/
COLOR4D
&
Darken
(
double
aFactor
)
{
r
=
(
double
)
r
*
(
1
.
0
-
aFactor
);
g
=
(
double
)
g
*
(
1
.
0
-
aFactor
);
b
=
(
double
)
b
*
(
1
.
0
-
aFactor
);
r
=
r
*
(
1
.
0
-
aFactor
);
g
=
g
*
(
1
.
0
-
aFactor
);
b
=
b
*
(
1
.
0
-
aFactor
);
return
*
this
;
}
/**
* Function Invert
* Makes the color inverted, alpha remains the same.
* @return COLOR4D& Inverted color.
*/
COLOR4D
&
Invert
()
{
r
=
(
1
.
0
-
r
);
g
=
(
1
.
0
-
g
);
b
=
(
1
.
0
-
b
);
return
*
this
;
}
...
...
@@ -112,9 +126,9 @@ public:
*/
COLOR4D
Highlighted
(
double
aFactor
)
const
{
return
COLOR4D
(
r
*
(
1
.
0
-
aFactor
)
+
aFactor
,
g
*
(
1
.
0
-
aFactor
)
+
aFactor
,
b
*
(
1
.
0
-
aFactor
)
+
aFactor
,
return
COLOR4D
(
r
*
(
1
.
0
-
aFactor
)
+
aFactor
,
g
*
(
1
.
0
-
aFactor
)
+
aFactor
,
b
*
(
1
.
0
-
aFactor
)
+
aFactor
,
a
);
}
...
...
@@ -126,12 +140,22 @@ public:
*/
COLOR4D
Darkened
(
double
aFactor
)
const
{
return
COLOR4D
(
r
*
(
1
.
0
-
aFactor
),
g
*
(
1
.
0
-
aFactor
),
b
*
(
1
.
0
-
aFactor
),
return
COLOR4D
(
r
*
(
1
.
0
-
aFactor
),
g
*
(
1
.
0
-
aFactor
),
b
*
(
1
.
0
-
aFactor
),
a
);
}
/**
* Function Inverted
* Returns an inverted color, alpha remains the same.
* @return COLOR4D& Inverted color.
*/
COLOR4D
Inverted
()
const
{
return
COLOR4D
(
1
.
0
-
r
,
1
.
0
-
g
,
1
.
0
-
b
,
a
);
}
/**
* Function GetBrightness
* Returns the brightness value of the color ranged from 0.0 to 1.0.
...
...
pcbnew/pcb_painter.cpp
View file @
861ea059
...
...
@@ -309,10 +309,12 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
// Set a proper color for the label
color
=
getLayerColor
(
aTrack
->
GetLayer
(),
aTrack
->
GetNet
(),
aTrack
->
ViewIsHighlighted
()
);
COLOR4D
labelColor
=
getLayerColor
(
aLayer
,
0
,
aTrack
->
ViewIsHighlighted
()
);
if
(
color
.
GetBrightness
()
>
0.5
)
m_gal
->
SetStrokeColor
(
color
.
Darkened
(
0.8
)
);
m_gal
->
SetStrokeColor
(
labelColor
.
Inverted
(
)
);
else
m_gal
->
SetStrokeColor
(
color
.
Highlighted
(
0.8
)
);
m_gal
->
SetStrokeColor
(
labelColor
);
m_gal
->
SetLineWidth
(
width
/
10.0
);
m_gal
->
SetBold
(
false
);
...
...
@@ -447,11 +449,12 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
// Set a proper color for the label
color
=
getLayerColor
(
aPad
->
GetParent
()
->
GetLayer
(),
aPad
->
GetNet
(),
aPad
->
ViewIsHighlighted
()
);
COLOR4D
labelColor
=
getLayerColor
(
aLayer
,
0
,
aPad
->
ViewIsHighlighted
()
);
if
(
color
.
GetBrightness
()
>
0.5
)
m_gal
->
SetStrokeColor
(
color
.
Darkened
(
0.8
)
);
m_gal
->
SetStrokeColor
(
labelColor
.
Inverted
(
)
);
else
m_gal
->
SetStrokeColor
(
color
.
Highlighted
(
0.8
)
);
m_gal
->
SetStrokeColor
(
labelColor
);
if
(
displayNetname
&&
m_pcbSettings
->
m_padNumbers
)
{
...
...
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