Skip to content

Add RouletteStyle and make the roulette-like layout the default - #51

Merged
fummicc1 merged 4 commits into
modernize-ios17-swift6from
claude/repository-improvements-fhid6w
Aug 24, 2026
Merged

fummicc1 merged 4 commits into
modernize-ios17-swift6from
claude/repository-improvements-fhid6w

Conversation

@fummicc1

@fummicc1 fummicc1 commented Aug 15, 2026 •

Copy link
Copy Markdown
Owner

Closes #47. Targets modernize-ios17-swift6 so it ships as part of v2.0.0.

The problem

#47 reports that the roulette does not look like a roulette:

  1. Labels sit around the middle instead of near the outer edge
  2. Labels are not rotated to follow their wedge
  3. Every separator converges to a point in the centre, which is visually noisy while spinning

The approach

A new RouletteStyle, applied with a .rouletteStyle(_:) view modifier backed by an environment value. This deliberately avoids adding a parameter to the five existing RouletteView / RouletteInternalView initializers.

RouletteView(parts: parts)
    .rouletteStyle(
        RouletteStyle(
            labelPosition: 0.8,        // 0 = centre, 1 = outer edge
            labelOrientation: .radial,
            innerRadiusRatio: 0.25     // hub size, 0 for a full pie
        )
    )

Parts render as annular sectors when a hub is configured and as full wedges otherwise, so the 1.x drawing path is untouched.

The default

The intent of #47 is a wheel that looks like a real roulette, so that is what the default is: labels out at the rim, laid out radially, hub in the middle.

Default .pie (1.x look)
labelPosition 0.74 0.5
labelOrientation .radial .tangential
innerRadiusRatio 0.22 0

As on a real wheel, labels on the left half sit upside down. That is the authentic arrangement rather than a defect, and it reads fine for numbers.

An earlier revision of this PR defaulted to .radialUpright, which flips that half to keep every label readable. Rendering the two side by side showed the flip reverses reading direction between neighbouring labels, which looks less coherent than the faithful layout — so the faithful one won the default and the flip stayed as an opt-in.

Every mode stays selectable

labelOrientation Effect
.radial Reads outward from the hub, exactly like a real roulette. The default.
.radialUpright Same radial layout, left half flipped so every label reads upright. Better for word labels.
.tangential Runs across the wedge, perpendicular to the radius. The 1.x behaviour.
.fixed Always upright, whatever angle the wedge sits at.
// words rather than numbers
.rouletteStyle(RouletteStyle(labelOrientation: .radialUpright))

// the 1.x appearance, unchanged
.rouletteStyle(.pie)

Visual change

This changes the default appearance. Existing users will see labels move outward, rotate to follow their wedge, and a hub appear in the middle. That is the intent of #47, and it is why this belongs in the v2.0.0 major bump rather than a minor release. RouletteStyle.pie restores the previous look in one line.

Tests

Nine tests covering the default and .pie presets, ratio clamping, that all four orientations stay selectable, and the rotation maths for each — including the flip boundaries at 90°/270° and angles outside 0..<360. Geometry is pure logic, so it is unit-testable; the rendered result is not.

Not verified here

CI compiles the package and runs unit tests — it cannot tell whether the roulette looks right. The layout was checked by rasterising the same geometry maths outside SwiftUI, which validates label placement, rotation and hub size but not font metrics. Whether long labels such as "JavaScript" fit at the real system font size still wants a look in the demo app.

claude added 4 commits August 15, 2026 08:14
Closes #47.

1.x drew labels halfway out from the centre, laid across the wedge, with
every separator meeting in a point in the middle — which does not look
like a roulette, as reported in #47.

Introduces `RouletteStyle`, applied through a `.rouletteStyle(_:)` view
modifier backed by an environment value, so no initializer gains another
parameter:

- `labelPosition` — where the label sits between centre (0) and rim (1)
- `labelOrientation` — `.radial` (reads outward, like a real roulette),
  `.tangential` (the 1.x look) or `.fixed` (always upright)
- `innerRadiusRatio` — hub left empty in the middle, so separators no
  longer converge to a point

The default is now labels near the rim, radial, with a hub.
`RouletteStyle.pie` restores the 1.x appearance for anyone who wants it.

Parts are drawn as annular sectors when a hub is configured, and as full
wedges otherwise, so the 1.x path is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnVAQvHFsMievKMZBpRHTP
Following the wedge exactly, as a real roulette does, leaves every label
on the left half of the wheel upside down. That reads fine for the one
and two digit numbers on a real wheel, but poorly for the word labels
this library is usually given.

Adds `.radialUpright`, which keeps the radial layout but turns labels on
that half a further 180 degrees, and makes it the default. `.radial` is
still there for anyone who wants the true roulette look.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnVAQvHFsMievKMZBpRHTP
#47 asks for a wheel that looks like a real roulette, so that is what the
default now is: labels out at the rim (0.74), laid out radially, with a
hub in the middle (0.22). As on a real wheel, labels on the left half sit
upside down — that is the authentic arrangement, not a defect.

The earlier default, .radialUpright, flipped that half to keep every
label readable. Rendering the two side by side showed the flip reverses
reading direction between neighbouring labels, which reads as less
coherent than the faithful layout. It stays available as an opt-in for
callers whose labels are words rather than numbers, alongside
.tangential, .fixed and the .pie preset for the 1.x appearance.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnVAQvHFsMievKMZBpRHTP
@fummicc1
fummicc1 merged commit 5ac45d8 into modernize-ios17-swift6 Aug 24, 2026
3 checks passed
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