Skip to content

Add QuickDraw's utility calls to libQuickDraw - #73

Merged
colemancda merged 13 commits into
masterfrom
feature/quickdraw-utilities
Dec 3, 2026
Merged

colemancda merged 13 commits into
masterfrom
feature/quickdraw-utilities

Conversation

@colemancda

Copy link
Copy Markdown
Member

libQuickDraw gains the small utility calls ordinary programs use, built on what Mac OS 9.2.2 did with a new probe (ReferenceTests/Retro68/UtilitiesCapture.c).

What changed

  • Random, StuffHex, PtToAngle.
  • Fix2SmallFract, SmallFract2Fix and the conversions between RGB and CMY, HSL and HSV.
  • Accessors: GetPortBounds, GetPortVisibleRegion, GetPortTextFont, GetPortTextSize, GetPortTextFace, GetPortBitMapForCopyBits, GetRegionBounds, GetQDGlobalsScreenBits.
  • In the engine: stuffHex (GraphiteCore), Rect.angle(to:) and CMYColor/HSVColor/HSLColor (Graphite2D).

19 more functions, so 168 of 305 are implemented.

Worth knowing

  • PtToAngle is not a rounded arctangent. The probe found that AngleFromSlope moves to the next degree 501 past SlopeFromAngle's fixed-point slope, so PointAngle.swift holds the 90 slopes as measured.
  • The HSL and HSV round trips lose a little, as on the Mac.
  • Random uses the engine's existing generator, which already matched.

Testing

  • UtilitiesCaptureTests replays the probe; every line matches except the slope calls', which are skipped because they are not QuickDraw's.
  • The accessors were not captured; drawing.c checks GetPortBounds, GetPortBitMapForCopyBits and GetQDGlobalsScreenBits, and the others have no check.
  • Full swift test passes on macOS.
  • macOS and Linux (CMake, swift:6.4-trixie, FreeType off): 305 exports as declared, pure.c 26 checks and drawing.c 65 checks pass.
  • The Swift tests were not run on Linux locally.

Commits are one file each, so intermediate ones may not build on their own.

@colemancda
colemancda merged commit 905e42c into master Dec 3, 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.

1 participant