Skip to content

New features#9

Merged
maxwase merged 13 commits intomasterfrom
new-features
Jan 31, 2026
Merged

New features#9
maxwase merged 13 commits intomasterfrom
new-features

Conversation

@maxwase
Copy link
Owner

@maxwase maxwase commented Jan 31, 2026

This pull request introduces several significant UI and code improvements to the paper folding app. The most notable changes include a major reorganization and enhancement of the Style controls (now integrated into the main Settings panel), the addition of a Flip feature with corresponding UI and animation logic, and substantial improvements to the polygon clipping and cleanup algorithms for more robust geometry handling. Additionally, the codebase is now better documented, and several UI elements have been refined for clarity and accessibility.

UI and Feature Enhancements:

  • The Style panel has been removed and its controls (paper size, border, and color options) are now part of the main Settings panel, with added support for a custom paper aspect ratio and separate front/back paper colors. [1] [2]
  • A new Flip button is added to the action bar, allowing users to flip the paper, with corresponding animation and input lock logic implemented in the code. [1] [2] [3] [4] [5]
  • The Reset and Undo buttons are now disabled during both fold and flip animations to prevent state corruption. [1] [2]
  • The fold fallback icon now adapts to device orientation for improved user guidance. [1] [2] [3]

Polygon Clipping and Geometry Improvements:

  • The polygon clipping logic in clipPolyHalfPlane has been refactored for clarity, with new utility functions to collapse near-coincident vertices and remove collinear points, reducing rendering artifacts and improving numerical stability. [1] [2]
  • The area and point-in-polygon functions are now more robust and better documented.

UI Polish and Accessibility:

  • The Hinge reset button has been visually integrated with the section header for improved clarity. [1] [2]
  • A new Debug section is available in the Info panel for development and troubleshooting.
  • The Reset button icon has been updated for consistency with its function.

Help and Documentation Updates:

  • The help copy for controls and gestures has been updated for clarity and to reflect the new Flip feature.

Summary of Most Important Changes:

UI and Feature Enhancements

  • Style controls moved from a separate panel into the main Settings panel, with added support for custom aspect ratio and front/back paper colors. [1] [2]
  • Flip button added to the action bar, with supporting animation and input lock logic in main code. [1] [2] [3] [4] [5]
  • Reset and Undo buttons now disabled during both fold and flip animations. [1] [2]
  • Fold fallback icon now adapts based on device orientation. [1] [2] [3]

Geometry and Algorithm Improvements

  • Polygon clipping and cleanup logic refactored for robustness, with new functions to collapse nearby vertices and remove collinear points, and improved documentation. [1] [2]

UI Polish and Documentation

  • Hinge reset button visually integrated into section header; new Debug section in Info panel; Reset icon updated. [1] [2] [3]
  • Help text updated for new controls and Flip feature.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces a flip feature for paper folding simulation and consolidates UI controls. The implementation includes substantial refactoring of the polygon clipping and geometry handling code, along with new animation logic for the flip operation.

Changes:

  • Adds Flip button and animation with 3D rotation effect around vertical axis
  • Consolidates Style panel controls into main Settings panel with support for custom aspect ratios and separate front/back paper colors
  • Refactors polygon clipping logic with improved numerical stability through vertex collapsing and collinear point removal
  • Enhances fold animation rendering with better layer sorting and documentation
  • Adds keyboard shortcuts (F for flip, R for reset, Space/Enter for fold)
  • Introduces debug section in Info panel for development diagnostics

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
index.html Removes Style panel, integrates controls into Settings with custom aspect ratio inputs, adds Flip button and debug spoiler section
src/style.css Updates input-row layout from space-between to flex with gap, adds section-header and reset-inline-btn styles, adds custom aspect and debug spoiler styles
src/main.ts Adds flip animation runtime and handlers, updates keyboard shortcuts, adds custom aspect ratio logic, refactors color picker for front/back colors, updates debug status display
src/paper/model.ts Adds outer field to Face interface, adds unused flipPaper function (duplicate of commitFlip)
src/paper/fold.ts Updates commitFold to invert layers and set outer flag, refactors normalizeVerts into clearer helper functions
src/paper/flip.ts New file implementing flip animation building and commit logic
src/render/paper.ts Refactors fold animation with improved layer sorting and documentation, adds drawFlippingPaper function, extracts lighting calculations into separate functions, adds constants for magic numbers
src/geom/polygon.ts Refactors cleanup into separate collapseNearbyVertices and removeCollinearVertices functions, extracts signedPolyArea, improves documentation
src/device/posture.ts Updates help text to reflect new controls (Space/F/R shortcuts)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

window.addEventListener("keydown", (e) => {
if ((e.code === "KeyF" || e.code === "Enter" || e.code === "Space") && !e.repeat) {
if (e.repeat) return;
if (e.code === "Space" || e.code === "Enter") {
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The global keyboard shortcut handler for Space/Enter keys (lines 384-386) may conflict with the conditional Space key listener added earlier in the code at lines 321-327 (when postureSupport === PostureSupport.Unavailable). If both listeners are active, pressing Space will trigger the fold action twice. Verify that this doesn't cause duplicate fold animations or consider consolidating the keyboard shortcuts into a single listener.

Suggested change
if (e.code === "Space" || e.code === "Enter") {
if (
(e.code === "Space" && postureSupport !== PostureSupport.Unavailable) ||
e.code === "Enter"
) {

Copilot uses AI. Check for mistakes.
@maxwase maxwase merged commit 3962890 into master Jan 31, 2026
1 check 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