stride3d / stride3d/stride

[Math] UInt -> Color might not behave as users might expect

Open
#747 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug priority-Low work-estimate-M
Dominant language
C#
Stars
7.8k
Forks
1.2k
Avg merge
2d 17h
Merged PRs (30d)
49

Description

Release Type: GitHub

Version: Latest

Platform(s): Any

Describe the bug
The format for string and ints to convert from and to colors are different from what most users might expect and what summaries for those functions implies:

var c = Color.FromRgba(ColorExtensions.StringToRgba("#FF119900"));
System.Console.WriteLine( $"R:{c.R:X} G:{c.G:X} B:{c.B:X} A:{c.A:X}" );
// Prints R:11 G:99 B:00 A:FF

c = Color.FromRgba(0xFF119900);
System.Console.WriteLine( $"R:{c.R:X} G:{c.G:X} B:{c.B:X} A:{c.A:X}" );
// Prints R:00 G:99 B:11 A:FF

To Reproduce
See above

Expected behavior
Mention that input string must be in ARGB format or change implementation to parse as an RGBA strings.
Should Color.FromRgba be changed to handle like most people would expect from an hex literal?
Try to avoid breaking changes if possible.

Additional context
#746
#693

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the Color.FromRgba and ColorExtensions.StringToRgba entry points, then compare their handling of the two examples in the issue. Review related issues #746 and #693 before deciding whether documentation or implementation should change; done means the formats are consistent or explicitly documented without unintended breaking changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.