Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c327cae

Browse files
authored
Revert "Fix off-by-one fromRGBO alpha value calculation (#13777)" (#14548)
This reverts commit 9f2daad.
1 parent c88e8a1 commit c327cae

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

lib/ui/painting.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,17 @@ class Color {
129129
/// * `r` is [red], from 0 to 255.
130130
/// * `g` is [green], from 0 to 255.
131131
/// * `b` is [blue], from 0 to 255.
132-
/// * `opacity` is the alpha channel of this color as a double, with 0.0 being
132+
/// * `opacity` is alpha channel of this color as a double, with 0.0 being
133133
/// transparent and 1.0 being fully opaque.
134134
///
135135
/// Out of range values are brought into range using modulo 255.
136136
///
137137
/// See also [fromARGB], which takes the opacity as an integer value.
138138
const Color.fromRGBO(int r, int g, int b, double opacity) :
139-
value = (((((opacity * 0xff + 0.5) ~/ 1) & 0xff) << 24) | // Since colors are canonicalized we need to round the alpha value manually
140-
((r & 0xff) << 16) |
141-
((g & 0xff) << 8) |
142-
((b & 0xff) << 0)) & 0xFFFFFFFF;
139+
value = ((((opacity * 0xff ~/ 1) & 0xff) << 24) |
140+
((r & 0xff) << 16) |
141+
((g & 0xff) << 8) |
142+
((b & 0xff) << 0)) & 0xFFFFFFFF;
143143

144144
/// A 32 bit value representing this color.
145145
///

testing/dart/color_test.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ void main() {
5555
expect(const NotAColor(123), equals(const NotAColor(123)));
5656
});
5757

58-
test('Color.fromRGBO', () {
59-
expect(const Color.fromRGBO(0, 0, 0, 1.0), const Color(0xFF000000));
60-
expect(const Color.fromRGBO(0, 0, 0, 0.5), const Color(0x80000000));
61-
expect(const Color.fromRGBO(0, 0, 0, 0.0), const Color(0x00000000));
62-
});
63-
6458
test('Color.lerp', () {
6559
expect(
6660
Color.lerp(const Color(0x00000000), const Color(0xFFFFFFFF), 0.0),

0 commit comments

Comments
 (0)