Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

支持RRGGBB的6位颜色格式#3199

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
MrZ626 wants to merge3 commits intoLuaLS:master
base:master
Choose a base branch
Loading
fromMrZ626:master
Draft

Conversation

MrZ626
Copy link

既然#3169 增加了"#RRGGBB"格式颜色的支持,那一些项目中有不带井号的6位颜色字符串也一起支持一下吧
顺便把这部分功能做成更容易拓展的了

@MrZ626MrZ626 changed the titlefeat: support rgb6 color format支持RRGGBB的6位颜色格式Jun 7, 2025
@CppCXYCppCXY requested a review fromCopilotJune 7, 2025 11:51
Copy link

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR expands the color format support to include non-hash 6-digit strings and refactors the color conversion logic for easier extensibility.

  • Introduces an enum of color patterns for different color modes.
  • Refactors color conversion functions into table methods to support future extensions.
  • Adds support for non-hashed 6-digit RGB color strings.
Comments suppressed due to low confidence (1)

script/core/color.lua:94

  • Ensure there are tests covering non-hashed 6-digit color strings to verify that the rgb6 conversion branch works as expected.
if source.type == 'string' then

MrZ626and others added2 commitsJune 8, 2025 06:46
in next,t改in pairs(t),写习惯了Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@tomlau10
Copy link
Contributor

那一些项目中有不带井号的6位颜色字符串也一起支持一下吧

不帶井號的 6位/8位長度的 string,不一定就是 color code 吧 😕

  • 隨便舉例:
localdbconf= {user="root",pass="123456",database="test",}

=> 這樣"123456" 就被當成 color code 了

  • 還有比如1個 literal data table
    其 key 就單純是1個 6位/8位字符長的 short hash
    也全都當成 color code 了呢
localDATA= {    ["000000"]= {field="a",    },    ["000001"]= {field="b",    },}

沒有# prefix 也當成 color code,似會造成較多誤判
或者可以考慮增加1個 config,讓 user 有需要時才打開? 🤔

  • 比如說有個semantic.rgbColorMode
  • 預設是prefix => 即現有帶# 號的 detect 方式
  • 可以有個all => 不帶# 號也做 detect,你的 use case
  • 最後還可以有個disable => 完全禁用 (這個是 bonus,或者先不用 implement)

@Issues-translate-bot

Sumneko Lua translate bot


Some projects have 6-bit color strings without pound marks, and support them together.

A 6-bit/8-bit length string without a pound mark may not be a color code 😕

  • Give some examples:
localdbconf= {user="root",pass="123456",database="test",}

=> In this way"123456" is regarded as a color code

  • There is also 1 literal data table
    The key is simply a short hash with 6-bit/8-bit characters long
    All of them are considered color codes
localDATA= {    ["000000"]= {field="a",    },    ["000001"]= {field="b",    },}

No# prefix is ​​also regarded as a color code, which seems to cause more misjudgments
Or can you consider adding 1 config to enable user to open when needed? 🤔

  • For example, there is asemantic.rgbColorMode
  • The preset isprefix =>, that is, the existing detect method with# number
  • You can have aall => detect without the# number, your use case
  • Finally, there can be adisable => completely disabled (this is bonus, or do not use implement for now)

@MrZ626
Copy link
Author

啊,那确实是应该加设置,之前八位数字也是会误判成颜色的,只是我运气好没遇见过🤣

tomlau10 reacted with thumbs up emoji

@Issues-translate-bot

Sumneko Lua translate bot


Ah, that should be set. The previous eight digits would be misjudged as colors, but I was lucky and never met them 🤣

@sumnekosumneko marked this pull request as draftJune 9, 2025 07:32
Comment on lines +5 to +10
local colorPattern = {
argb8 = "^%x%x%x%x%x%x%x%x$",
hexrgb6 = "^#%x%x%x%x%x%x$",
rgb6 = "^%x%x%x%x%x%x$",
}

Copy link
Contributor

Choose a reason for hiding this comment

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

The naming scheme is a bit out of the line when compared to their usual meaning in color science. The number usually means the number of bits for each color channel. So, ARGB8 would mean 4 channels where each has 8 bits, while RGB8 would be 3 channels of 8 bits.

If I understand the code correctly, thergb6 andargb8 in the code store channels as Lua numbers, so doubles. I believe it would be a bit more consistent with some established conventions to drop the number and only specify the channel names.

Some references:
https://en.wikipedia.org/wiki/Color_depth#True_color_(24-bit)
https://www.khronos.org/opengl/wiki/Image_Format
https://photo.stackexchange.com/questions/90171/what-is-difference-between-8bit-rgb-and-16bit-rgb

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@C3paC3paC3pa left review comments

Copilot code reviewCopilotCopilot left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@MrZ626@tomlau10@Issues-translate-bot@C3pa

[8]ページ先頭

©2009-2025 Movatter.jp