Skip to content

Conversation

@matanlurey
Copy link
Contributor

@matanlurey matanlurey commented Dec 23, 2024

Closes #160592.

Made a few other tiny non-breaking refactors, for example changing withValues internally.

@matanlurey matanlurey requested a review from gaaclarke December 23, 2024 19:22
@flutter-dashboard

This comment was marked as outdated.

@github-actions github-actions bot added the engine flutter/engine related. See also e: labels. label Dec 23, 2024
@matanlurey
Copy link
Contributor Author

Removed the refactoring so this is 100% a documentation change.

/// Color c2 = const Color.fromARGB(0xFF, 0x42, 0xA5, 0xF5);
/// Color c3 = const Color.fromARGB(255, 66, 165, 245);
/// Color c4 = const Color.fromRGBO(66, 165, 245, 1.0);
/// Color c1 = const Color.from(alpha: 1.0, red: 0.2588, green: 0.6471, blue: 0.9608);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style nit:

const c1 = Color.from(....)
const c2 = ... 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to revert this :(, filed #160884.

@matanlurey matanlurey requested a review from jtmcdole December 26, 2024 20:16
/// is fully opaque, with a red [r] channel value of `0.2588` (or `0x42` or `66`
/// as an 8-bit value), a green [g] channel value of `0.6471` (or `0xA5` or
/// `165` as an 8-bit value), and a blue [b] channel value of `0.9608` (or
/// `0xF5` or `245` as an 8-bit value). In the common "hash syntax" for RGB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "hash syntax" a common term? I've only heard it referred to as "hex color". In fact, this seems to be coming straight out of CSS hex color syntax. Maybe we should say exactly that: CSS hex color syntax? And maybe even link to https://developer.mozilla.org/en-US/docs/Web/CSS/hex-color?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree ("hash syntax" was just wording copied from the original docs).

Changed to "CSS hex color syntax" and linked appropriately.

/// The normalized green channel of this color.
///
/// A value of `0.0` represents no red in this color. A value of `1.0`
/// represents the maximum amount of greeb.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/greeb/green/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greebo.

Done!

/// > component values (such as `0.5`) into their 8-bit equivalent by using
/// > the [toARGB32] method; the returned value is not guaranteed to be stable
/// > across different platforms or executions due to the complexity of
/// > floating-point math.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth noting that the returned value is compatible with the default constructor (Color.new) but does not guarantee to result in the same color due to imprecisions in numeric conversions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion, done (albeit done in toARGB32, this is now a stub method as suggested above)

/// * Bits 8-15 are the green value.
/// * Bits 0-7 are the blue value.
///
/// > [!WARNING]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning would be more useful on the non-deprecated toARGB32 method rather than here. In fact, maybe we should turn this dartdoc into a stub that simply points to toARGB32?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@matanlurey matanlurey requested a review from yjbanov December 26, 2024 22:27
Copy link
Contributor

@yjbanov yjbanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@matanlurey matanlurey added this pull request to the merge queue Dec 27, 2024
@mdebbar mdebbar removed this pull request from the merge queue due to a manual request Dec 27, 2024
@matanlurey matanlurey added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 27, 2024
@auto-submit auto-submit bot added this pull request to the merge queue Dec 27, 2024
Merged via the queue into flutter:master with commit 840ef1c Dec 28, 2024
179 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Dec 28, 2024
Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @matanlurey a good improvement with notes about mentioning 0.0 and 1.0 being the min a max values.

Comment on lines +217 to +219
///
/// A value of `0.0` represents no blue in this color. A value of `1.0`
/// represents the maximum amount of blue.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was very careful about using the word "normalized" or saying 1.0 is the maximum value since internally that isn't the case with ColorSpace.extendedSRGB. It is normalized but 1.0 isn't the max value. Can we remove that sentence please?

/// Returns a new color with the provided components updated.
///
/// Each component ([alpha], [red], [green], [blue]) represents a normalized
/// floating-point value wher `0.0` is the minimum and `1.0` is the maximum;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too.

/// color space.
/// If [colorSpace] is provided, and is different than the current color
/// space, the component values are updated before transforming them to the
/// provided color space.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/color space/[ColorSpace]

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 6, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jan 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Color.withValues(alpha: x) expects values between 0...1 instead of 0...255

4 participants