Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
c1b07630
Commit
c1b07630
authored
Nov 20, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Elaborate HSVColor interface
Fixes #507
parent
ffb95f05
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
19 deletions
+65
-19
colors.dart
packages/flutter/lib/src/painting/colors.dart
+64
-18
view.dart
packages/flutter/lib/src/rendering/view.dart
+1
-1
No files found.
packages/flutter/lib/src/painting/colors.dart
View file @
c1b07630
...
...
@@ -2,45 +2,45 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
show
Color
;
import
'dart:ui'
show
Color
,
lerpDouble
;
class
HSVColor
{
const
HSVColor
.
fromAHSV
(
this
.
a
,
this
.
h
,
this
.
s
,
this
.
v
);
const
HSVColor
.
fromAHSV
(
this
.
a
lpha
,
this
.
hue
,
this
.
saturation
,
this
.
value
);
/// Alpha, from 0.0 to 1.0.
final
double
a
;
final
double
a
lpha
;
/// Hue, from 0.0 to 360.0.
final
double
h
;
final
double
h
ue
;
/// Saturation, from 0.0 to 1.0.
final
double
s
;
final
double
s
aturation
;
/// Value, from 0.0 to 1.0.
final
double
v
;
final
double
v
alue
;
HSVColor
withAlpha
(
double
a
)
{
return
new
HSVColor
.
fromAHSV
(
a
,
h
,
s
,
v
);
HSVColor
withAlpha
(
double
a
lpha
)
{
return
new
HSVColor
.
fromAHSV
(
a
lpha
,
hue
,
saturation
,
value
);
}
HSVColor
withHue
(
double
h
)
{
return
new
HSVColor
.
fromAHSV
(
a
,
h
,
s
,
v
);
HSVColor
withHue
(
double
h
ue
)
{
return
new
HSVColor
.
fromAHSV
(
a
lpha
,
hue
,
saturation
,
value
);
}
HSVColor
withSaturation
(
double
s
)
{
return
new
HSVColor
.
fromAHSV
(
a
,
h
,
s
,
v
);
HSVColor
withSaturation
(
double
s
aturation
)
{
return
new
HSVColor
.
fromAHSV
(
a
lpha
,
hue
,
saturation
,
value
);
}
HSVColor
withValue
(
double
v
)
{
return
new
HSVColor
.
fromAHSV
(
a
,
h
,
s
,
v
);
HSVColor
withValue
(
double
v
alue
)
{
return
new
HSVColor
.
fromAHSV
(
a
lpha
,
hue
,
saturation
,
value
);
}
/// Returns this color in RGB.
Color
toColor
()
{
final
double
h
=
this
.
h
%
360
;
final
double
c
=
s
*
v
;
final
double
h
=
hue
%
360
;
final
double
c
=
s
aturation
*
value
;
final
double
x
=
c
*
(
1
-
(((
h
/
60.0
)
%
2
)
-
1
).
abs
());
final
double
m
=
v
-
c
;
final
double
m
=
v
alue
-
c
;
double
r
;
double
g
;
...
...
@@ -71,10 +71,56 @@ class HSVColor {
b
=
x
;
}
return
new
Color
.
fromARGB
(
(
a
*
0xFF
).
round
(),
(
alpha
*
0xFF
).
round
(),
((
r
+
m
)
*
0xFF
).
round
(),
((
g
+
m
)
*
0xFF
).
round
(),
((
b
+
m
)
*
0xFF
).
round
()
);
}
HSVColor
_scaleAlpha
(
double
factor
)
{
return
withAlpha
(
alpha
*
factor
);
}
/// Linearly interpolate between two HSVColors.
///
/// If either color is null, this function linearly interpolates from a
/// transparent instance of the other color.
static
HSVColor
lerp
(
HSVColor
a
,
HSVColor
b
,
double
t
)
{
if
(
a
==
null
&&
b
==
null
)
return
null
;
if
(
a
==
null
)
return
b
.
_scaleAlpha
(
t
);
if
(
b
==
null
)
return
a
.
_scaleAlpha
(
1.0
-
t
);
return
new
HSVColor
.
fromAHSV
(
lerpDouble
(
a
.
alpha
,
b
.
alpha
,
t
),
lerpDouble
(
a
.
hue
,
b
.
hue
,
t
),
lerpDouble
(
a
.
saturation
,
b
.
saturation
,
t
),
lerpDouble
(
a
.
value
,
b
.
value
,
t
)
);
}
bool
operator
==(
dynamic
other
)
{
if
(
identical
(
this
,
other
))
return
true
;
if
(
other
is
!
HSVColor
)
return
false
;
final
HSVColor
typedOther
=
other
;
return
typedOther
.
alpha
==
alpha
&&
typedOther
.
hue
==
hue
&&
typedOther
.
saturation
==
saturation
&&
typedOther
.
value
==
value
;
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
alpha
.
hashCode
;
value
=
37
*
value
+
hue
.
hashCode
;
value
=
37
*
value
+
saturation
.
hashCode
;
value
=
37
*
value
+
value
.
hashCode
;
return
value
;
}
String
toString
()
=>
"HSVColor(
$alpha
,
$hue
,
$saturation
,
$value
)"
;
}
packages/flutter/lib/src/rendering/view.dart
View file @
c1b07630
...
...
@@ -130,7 +130,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
scene
.
dispose
();
assert
(()
{
if
(
debugEnableRepaintRainbox
)
debugCurrentRepaintColor
=
debugCurrentRepaintColor
.
withHue
(
debugCurrentRepaintColor
.
h
+
debugRepaintRainboxHueIncrement
);
debugCurrentRepaintColor
=
debugCurrentRepaintColor
.
withHue
(
debugCurrentRepaintColor
.
h
ue
+
debugRepaintRainboxHueIncrement
);
return
true
;
});
}
finally
{
...
...
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