Add native Go port of Rough.js 4.0.4 - #1
Merged
Conversation
alixander
marked this pull request as ready for review
August 9, 2026 04:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Compatibility
This targets the exact Rough.js 4.0.4 behavior embedded by D2:
35302b8f1119ad004b4550f9a4d4162d3d845b0a5601a7c6046815613316d882ffbaede24261bfec295e3502ae7539abb181482021f8682b994c6063e9605a19f50a6bd9f3b0901cbff4db2326b3f85308e29b7fRough.js 4.0.4 did not ship an automated test suite, so parity is enforced with source-shaped tests, D2's exact sketch goldens, and a deterministic 1,000-call differential across all 9 generator methods, all 7 fill styles, and all 18 public options.
D2's former Goja runtime matches rough-go strictly on arm64 and amd64. Node/V8 has four deterministic engine/libm boundary cases where tiny intermediate differences are amplified by Rough.js's random-offset calculations; those exact calls use narrowly scoped 0.1-1px numeric tolerances while topology, operation order, styles, options, and all other 996 calls remain strict.
Dependent D2 migration: d2lang/d2#2821. D2 pins this pushed commit by pseudo-version; no local replacement is used.
Tests
go test ./...go test -race ./...go vet ./...