Adding opacity -> alpha method to Color class (flutter/engine#13902)
This commit is contained in:
@@ -307,6 +307,14 @@ class Color {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an alpha value representative of the provided [opacity] value.
|
||||
///
|
||||
/// The [opacity] value may not be null.
|
||||
static int getAlphaFromOpacity(double opacity) {
|
||||
assert(opacity != null);
|
||||
return (opacity.clamp(0.0, 1.0) * 255).round();
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
if (identical(this, other))
|
||||
|
||||
@@ -226,6 +226,14 @@ class Color {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an alpha value representative of the provided [opacity] value.
|
||||
///
|
||||
/// The [opacity] value may not be null.
|
||||
static int getAlphaFromOpacity(double opacity) {
|
||||
assert(opacity != null);
|
||||
return (opacity.clamp(0.0, 1.0) * 255).round();
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
if (identical(this, other)) {
|
||||
|
||||
Reference in New Issue
Block a user