Skip to content

Feature/color macros mordernization#370

Open
pointertobios wants to merge 2 commits into
x-ege:masterfrom
pointertobios:feature/color-macros-mordernization
Open

Feature/color macros mordernization#370
pointertobios wants to merge 2 commits into
x-ege:masterfrom
pointertobios:feature/color-macros-mordernization

Conversation

@pointertobios

@pointertobios pointertobios commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • 新增统一的颜色相关头文件,提供颜色类型及打包、拆包、灰度转换等便捷接口。
    • 主头文件和中文头文件已接入新的颜色定义来源,便于直接使用相关能力。
  • Chores
    • 更新忽略规则,新增对 .cache/ 目录的忽略。

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

将颜色类型 color_t 与相关宏从 include/ege.hinclude/ege.zh_CN.h 中移除,新建 include/ege/color.h,以 inline constexpr 函数重新实现颜色打包/拆包/灰度转换,并通过 using 引入全局作用域。两个原有头文件改为 #include "ege/color.h"

Changes

颜色定义提取到独立头文件

Layer / File(s) Summary
新增 include/ege/color.h
include/ege/color.h
namespace ege 内以 inline constexpr 函数实现 color_t 类型定义、颜色分量打包(EGERGBA/EGERGB/EGEARGB/EGEACOLOR)、分量提取与 alpha 变换(EGECOLORA/EGEGET_R/G/B/A)以及灰度构造(EGEGRAY/EGEGRAYA/EGEAGRAY),文件末尾用 using ege::... 将各函数引入全局作用域。
原有头文件切换到 ege/color.h
include/ege.h, include/ege.zh_CN.h
两个头文件各新增 #include "ege/color.h",同时删除原内置的 EGE_COLOR_T_TYPEDEF 守卫下的 typedef uint32_t color_t 及全套颜色宏定义块。
.gitignore 更新
.gitignore
新增 .cache/ 忽略规则。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • x-ege/xege#318:将 COLORS 枚举底层类型改为 color_t,与本 PR 对 color_t 来源的迁移强相关。

Poem

🐇 小兔子捧起颜色盒,
把宏宏们搬进新小屋,
color.h 整整齐齐住,
红绿蓝透再不散落路,
using 一声呼,全家出来啦!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题与本次颜色宏现代化/拆分到独立头文件的主要改动一致,能清楚概括变更方向。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@augmentcode

augmentcode Bot commented Jun 30, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR modernizes EGE color utilities by moving the color type and helper definitions into a dedicated header.

Changes:

  • Adds include/ege/color.h with constexpr color construction/extraction helpers.
  • Updates include/ege.h and include/ege.zh_CN.h to include the new header and removes the inlined macro/typedef definitions.
  • Exports the helpers into the global namespace via using declarations for drop-in usage.
  • Ignores .cache/ directories in .gitignore.

Technical Notes: Switching from macros to constexpr functions avoids macro pitfalls and makes the helpers usable in constant expressions while keeping the same call sites.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread include/ege/color.h
Comment thread include/ege.h

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@include/ege/color.h`:
- Around line 8-12: The public API still refers to bare color_t, but the type
was moved into the ege namespace, so compilation breaks unless it is re-exported
globally. Update include/ege/color.h to add a global using ege::color_t
alongside the existing function re-exports, and make sure the same public-facing
symbol is available to include/ege.h and include/ege.zh_CN.h where color_t is
used.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a220b8ac-4a33-46c6-bafe-59f6993c4bc5

📥 Commits

Reviewing files that changed from the base of the PR and between e85aa27 and 084f77f.

📒 Files selected for processing (4)
  • .gitignore
  • include/ege.h
  • include/ege.zh_CN.h
  • include/ege/color.h

Comment thread include/ege/color.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants