8000 Color api rename by zhuxudong · Pull Request #2607 · galacean/engine · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Color api rename #2607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 9, 2025
Merged

Conversation

zhuxudong
Copy link
Member
@zhuxudong zhuxudong commented Apr 9, 2025

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

What is the current behavior? (You can also link to an open issue here)

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

Other information:

Summary by CodeRabbit

  • Refactor
    • Standardized color conversion terminology by replacing outdated labels with sRGB, improving clarity in color transformations.
  • Documentation
    • Revised documentation and annotations to accurately describe conversions between linear and sRGB color spaces.
  • Tests
    • Updated tests to align with the improved nomenclature, ensuring consistency in color conversion validations.

@zhuxudong zhuxudong added the enhancement New feature or request label Apr 9, 2025
@zhuxudong zhuxudong requested a review from GuoLei1990 April 9, 2025 09:21
@zhuxudong zhuxudong self-assigned this Apr 9, 2025
Copy link
coderabbitai bot commented Apr 9, 2025

Walkthrough

This pull request updates documentation and code references for color space conversion in the Color class. The conversion previously referred to as “gamma” is now explicitly labeled as “sRGB.” In the source code, the method call toGamma has been renamed to toSRGB, and a deprecated toGamma method has been added for backward compatibility. Test cases and Chinese documentation have been updated accordingly.

Changes

File(s) Change Summary
docs/en/core/math.mdx & docs/zh/core/math.mdx Updated comments to reflect conversion from linear space to sRGB space, and updated method call references from toGamma to toSRGB.
packages/math/src/Color.ts Renamed toGamma to toSRGB with updated documentation; added a deprecated toGamma method that wraps the new toSRGB method for backward compatibility.
tests/src/math/Color.test.ts Renamed variable from colorGamma to colorSRGB and updated the method call accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant Color
    Caller->>Color: Call toGamma() (deprecated)
    Color->>Color: Delegate to toSRGB()
    Color-->>Caller: Return sRGB conversion result
Loading

Possibly related PRs

Suggested labels

documentation, math

Suggested reviewers

  • GuoLei1990
  • Sway007
  • luzhuang

Poem

I’m a rabbit hopping through the code so bright,
Changing gamma to sRGB feels just right.
Deprecated calls take a gentle leap,
Ensuring legacy friends can safely keep.
With every line, I celebrate in delight!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 958265a and 3346204.

📒 Files selected for processing (4)
  • docs/en/core/math.mdx (1 hunks)
  • docs/zh/core/math.mdx (1 hunks)
  • packages/math/src/Color.ts (2 hunks)
  • tests/src/math/Color.test.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
tests/src/math/Color.test.ts (1)
packages/math/src/Color.ts (1)
  • Color (8-376)
🪛 GitHub Check: codecov/patch
packages/math/src/Color.ts

[warning] 374-375: packages/math/src/Color.ts#L374-L375
Added lines #L374 - L375 were not covered by tests

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: e2e (22.x)
🔇 Additional comments (11)
tests/src/math/Color.test.ts (2)

93-94: LGTM, variable name updated to match method renaming.

The variable name change from colorGamma to colorSRGB correctly aligns with the API changes in the Color class, maintaining consistency across the codebase.


103-104: Method call correctly updated to use new API.

The test now properly uses the renamed toSRGB method instead of the deprecated toGamma method, ensuring tests reflect the current API while maintaining the same test logic.

docs/zh/core/math.mdx (3)

247-247: Documentation updated to reflect new terminology.

The comment has been appropriately updated from "linear 空间转 gamma 空间" to "linear 空间转 sRGB 空间", correctly describing the color space conversion.


249-249: Method call updated to use new API.

The code example now uses the renamed toSRGB method, maintaining consistency with the API changes.


251-251: Correct update of color space terminology.

The comment has been properly updated from "gamma 空间转 linear 空间" to "sRGB 空间转 linear 空间" to reflect the more specific color space naming.

docs/en/core/math.mdx (3)

246-246: Documentation updated to reflect new terminology.

The comment has been appropriately updated from mentioning gamma space to explicitly referencing sRGB space, providing more precise terminology.


248-248: Method call updated to use new API.

The code example now uses the renamed toSRGB method, maintaining consistency with the API changes.


250-250: Correct update of color space terminology.

The comment has been properly updated to reflect the more specific "sRGB space" terminology instead of "gamma space".

packages/math/src/Color.ts (3)

315-319: Documentation properly updated for the renamed method.

The JSDoc comments have been appropriately updated to reflect the more precise terminology, changing references from "gamma space" to "sRGB space".


320-320: Method name updated to use more precise terminology.

The method name change from toGamma to toSRGB provides more precise terminology about the color space conversion being performed, while the implementation remains unchanged.


372-375:

❓ Verification inconclusive

Good addition of backward compatibility method.

Adding a deprecated toGamma method that calls the new toSRGB method ensures backward compatibility for existing code, following good deprecation practices.

The static analysis indicates these lines aren't covered by tests. Consider adding a test case that explicitly verifies the deprecated method works:


🏁 Script executed:

#!/bin/bash
# Check if there are any tests for the deprecated method
rg -A 2 "toGamma" --type ts --glob "tests/**/*.test.ts"

Length of output: 55


Deprecated Method Test Coverage

The implementation of toGamma as a backward compatibility alias to toSRGB is solid. However, static analysis indicates that this method currently lacks test coverage. Please add a test case that verifies toGamma returns the same output as toSRGB. For example, you might add the following assertion in your test suite:

expect(color.toGamma(someColor)).toEqual(color.toSRGB(someColor));

This additional test will help catch any future regressions in the deprecation behavior.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 374-375: packages/math/src/Color.ts#L374-L375
Added lines #L374 - L375 were not covered by tests

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Apr 9, 2025
Copy link
codecov bot commented Apr 9, 2025

Codecov Report

Attention: Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.

Project coverage is 68.60%. Comparing base (958265a) to head (3346204).
Report is 1 commits behind head on dev/1.5.

Files with missing lines Patch % Lines
packages/math/src/Color.ts 77.77% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           dev/1.5    #2607   +/-   ##
========================================
  Coverage    68.59%   68.60%           
========================================
  Files          966      966           
  Lines       101438   101443    +5     
  Branches      8714     8715    +1     
========================================
+ Hits         69582    69594   +12     

8000
+ Misses       31593    31586    -7     
  Partials       263      263           
Flag Coverage Δ
unittests 68.60% <77.77%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@GuoLei1990 GuoLei1990 added ignore for release ignore for release and removed documentation Improvements or additions to documentation labels Apr 9, 2025
@GuoLei1990 GuoLei1990 merged commit ae3dc4a into galacean:dev/1.5 Apr 9, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ignore for release ignore for release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0