Repository navigation
refactor: computeFitTransform() statt vierfach kopierter Einpass-Logik (#359) - #370
Merged
Merged
Conversation
#359) Bounding Box der Striche → Skalierung/Offset stand fast identisch in DrawingCanvas.web.tsx, DrawingCanvas.native.tsx (getScaledPaths), ShareService.ts und ShareService.native.ts (computeScaleOffset); nur das Padding unterschied sich (10 Canvas, 40 Export). - utils/drawingTransform.ts: computeFitTransform(paths, width, height, padding) + IDENTITY_TRANSFORM, ohne React-Native-Abhängigkeit - alle vier Stellen nutzen den Helper (-138 Zeilen) - Tests: Randfälle (leer, nur Fills, Einzelpunkt, Linie, Padding) und ein Äquivalenztest gegen die bisherige Implementierung für 300 zufällige Zeichnungen Verhalten unverändert; im Browser pixelidentisch (Ergebnis-Canvas, Replay-Mitte, Replay-Ende) gegenüber dem Stand davor. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017fxbsNALrmwMj7LGMDPLw2
🔀 Mergeability-Report✅ Konfliktfrei mergebar ( CI-Checks: ✅ keine fehlgeschlagenen Checks ⏳ 🔍 Code Quality & Linting Merge-Checkliste
Kostenlos generiert von reusable-mergeability.yml · keine API-Kosten · review-gate: |
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.
Pull Request
Closes #359
Beschreibung
Die Logik „Zeichnung in eine Fläche einpassen“ (Bounding Box der Striche → Skalierung und Offset) stand viermal fast identisch im Code:
components/DrawingCanvas.web.tsx(Redraw-Effekt)components/DrawingCanvas.native.tsx(getScaledPaths)services/ShareService.tsservices/ShareService.native.ts(computeScaleOffset)Unterschiede gab es nur beim Padding: 10 bei den Zeichenflächen, 40 beim PNG-Export.
Änderung
computeFitTransform(paths, width, height, padding)inutils/drawingTransform.ts(plusIDENTITY_TRANSFORM), ohne React-Native-Abhängigkeit. Er liefert die Identität, wenn es keine Striche gibt, nur Fills oder die Bounding Box Breite oder Höhe 0 hat. Die Skalierung wird nie größer als 1.-Infinity > 0ist false und führt zur Identität).Die Props-/Defaults-Dopplung zwischen Web- und Native-Canvas aus #359 („optional im selben Zug“) ist bewusst nicht Teil dieses PRs, damit er ein reines, leicht prüfbares Refactoring bleibt.
Art der Änderung
Cross-Platform Kompatibilität
Betrifft dieser PR plattformspezifischen Code? Ja (Web-/Native-Canvas und beide ShareService-Dateien), der Helper selbst ist plattformneutral.
Testing Checklist
--noUnusedLocalsin den geänderten Dateien), keine ESLint Warnings, Prettier saubernpm run test:ci: 477/477 grünHinweis zur Reihenfolge
Mit #369 kollidiert nur
CHANGELOG.md(beide ergänzen einen Eintrag oben); das löse ich nach dem Merge des jeweils ersten PRs auf.Generated by Claude Code