Skip to content

Support the 8-bit (0-255) .colorset input method (follow-up to #471)#474

Open
arulagarwal wants to merge 2 commits into
skiptools:mainfrom
arulagarwal:colorset-input-methods
Open

Support the 8-bit (0-255) .colorset input method (follow-up to #471)#474
arulagarwal wants to merge 2 commits into
skiptools:mainfrom
arulagarwal:colorset-input-methods

Conversation

@arulagarwal

@arulagarwal arulagarwal commented Jul 1, 2026

Copy link
Copy Markdown

Why

#471 (thanks @haaaaaaarshs!) fixed the common case — .colorset channels authored with Xcode's 8-bit Hexadecimal input method (0x..) now parse correctly instead of rendering black. Following up on @marcprux's note on #468, this rounds out the last numeric Input Method: 8-bit (0–255).

Xcode's "8-bit (0–255)" method writes each channel as a bare integer (e.g. "148"). That currently falls through to Double("148") = 148.0, which clamps to white — so a color authored with that method still renders wrong. This normalizes a bare integer (one with no decimal point) by /255, matching the hex path.

There also isn't yet any test coverage around colorset component parsing, so this adds fixtures + render tests for all three numeric methods (hexadecimal, 8-bit 0–255, floating point) — all encoding the same color — to guard against regressions.

What

  • ColorComponents.parseComponent: adds one branch — a bare integer (no .) is treated as an 8-bit (0–255) value and normalized /255. The hexadecimal and floating-point paths are unchanged.
  • Adds HexColor / IntColor / FloatColor fixtures (the same #04F188 encoded via each method) and render tests asserting all three agree.

A note on the tests: they're DISABLED-prefixed because decoding a bundled component .colorset throws a kotlin-reflect IllegalAccessException under the Robolectric unit runner (it can't access the generated DecodableCompanion for the nested ColorSet types), so it falls back to gray there. This is a pre-existing test-runner limitation independent of this change — the tests pass on a real device/emulator, and the parsing logic is additionally covered by a standalone check.

Before / After evidence

Standalone check of the parsing over all three methods (same color):

hex  0x04 / 0xF1 / 0x88   -> 0.0157 / 0.9451 / 0.5333
8bit 4    / 241  / 136    -> 0.0157 / 0.9451 / 0.5333   (before: "148"-style values clamped to white)
float 0.0157 / 0.9451 / 0.5333 -> unchanged

swift test --filter ColorTests passes; skip test --filter ColorTests builds/transpiles and the suite stays green.

Acceptance criteria

  • Test added for the new behavior (8-bit fixtures + render tests) plus hex/float regression fixtures
  • Existing test suite passes (swift test; skip test on Robolectric)
  • Follows project style (extends the existing parseComponent, reusing Fix hex color component parsing #471's helpers)
  • No breaking changes (hex and floating-point paths unchanged)

Refs #146, builds on #471.


Skip Pull Request Checklist:

  • REQUIRED: I have signed the Contributor Agreement
  • REQUIRED: I have tested my change locally with swift test
  • OPTIONAL: I have tested my change on an iOS simulator or device
  • OPTIONAL: I have tested my change on an Android emulator or device
  • REQUIRED: I have checked whether this change requires a corresponding update in Skip Fuse UI — none needed (internal colorset parsing; no public API change)
  • OPTIONAL: I have added an example of any UI changes to the Showcase sample app

  • AI was used to assist with this PR. How: I used Claude Code to extend the parser, add fixtures/tests, and run the suite. Verification: I read and understood every line, confirmed the 8-bit normalization against the hex/float encodings of the same color, and ran swift test + skip test plus a standalone logic check.

arulagarwal and others added 2 commits July 1, 2026 18:46
…#146)

Follow-up to skiptools#471, which handled the "8-bit Hexadecimal" input method.
Xcode's "8-bit (0-255)" method emits bare integer channels (e.g. "148"),
which fell through to Double("148") = 148.0 and clamped to white. Detect a
bare integer (no decimal point) and normalize it by /255, so all of Xcode's
numeric Input Methods now parse correctly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…iptools#146)

Adds HexColor / IntColor / FloatColor fixtures (the same #04F188 encoded via
the hexadecimal, 8-bit-0-255, and floating-point input methods) and matching
render tests. They are DISABLED-prefixed because decoding a bundled component
.colorset throws a kotlin-reflect IllegalAccessException under the Robolectric
unit runner (it works on a real device); the parsing algorithm is additionally
covered by a standalone logic harness.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant