Skip to content

Add geometric transform workflows: reflect, scale, shear, arbitrary-center rotation#43

Merged
vl3c merged 8 commits intomainfrom
feature/transform-workflows
Feb 16, 2026
Merged

Add geometric transform workflows: reflect, scale, shear, arbitrary-center rotation#43
vl3c merged 8 commits intomainfrom
feature/transform-workflows

Conversation

@vl3c
Copy link
Copy Markdown
Owner

@vl3c vl3c commented Feb 15, 2026

Summary

  • Add reflection, dilation (scale), shear, and arbitrary-center rotation as geometric transform operations on existing drawable objects
  • Each drawable class gets reflect(), scale(), shear(), rotate_around() methods following the existing translate()/rotate() pattern
  • TransformationsManager orchestrates lookup, undo archiving, delegation, dependency refresh, and redraw for all new transforms
  • Three new AI tools (reflect_object, scale_object, shear_object) and enhanced rotate_object with optional center coordinates
  • Unsupported operations raise ValueError with clear messages (e.g., shearing circles, non-uniform scaling of circles/rotated ellipses)
  • Pre-archive validation prevents undo history pollution when transforms are rejected
  • Dependency refresh uses get_vertices() presence instead of hard-coded class names, covering all Polygon subclasses

Test plan

  • New Brython test suite (test_transforms.py) with 42 tests covering:
    • Drawable-level transforms on Point, Segment, Vector, Triangle, Circle, Ellipse
    • Manager orchestration for all new operations
    • Error cases (non-uniform circle scale, shear on circle/ellipse, zero-length segment axis, missing drawable)
    • Undo archiving verification (called on success, skipped on unsupported ops)
  • Run existing client test suite to verify no regressions
  • Manual test: create triangle, reflect across x-axis, verify vertices, undo restores original

🤖 Generated with Claude Code

vl3c added 7 commits February 16, 2026 20:28
Add four new transform methods to each geometry drawable:
- Point: direct coordinate transforms with label sync
- Segment: delegates to point methods, recalculates line formula
- Vector: delegates to underlying segment
- Polygon: iterates vertices for all transforms
- Circle: reflect/scale/rotate center; shear raises ValueError
- Ellipse: reflect adjusts rotation_angle; scale supports uniform
  and axis-aligned non-uniform; shear raises ValueError
…th arbitrary center

New methods: reflect_object, scale_object, shear_object follow the same
orchestration pattern as translate_object (find → archive → transform →
refresh dependencies → redraw).

Extend rotate_object with optional center_x/center_y parameters for
rotation around an arbitrary point. When provided, Points and Circles
become eligible targets (they have rotate_around methods).

Extract shared helpers: _find_drawable_by_name, _gather_moved_points,
_refresh_dependencies_after_transform, _get_class_name, _redraw.

Add _resolve_segment_to_line to convert a named segment into line
coefficients for segment-axis reflections.
…nctionRegistry

Add Canvas delegation methods for the three new transforms and update
rotate_object signature with optional center_x/center_y.

Register all three in get_available_functions() and
get_undoable_functions() alongside the existing transform entries.
…d update rotate_object

Add JSON schemas for three new transform tools with strict parameter
validation. Update rotate_object with optional center_x/center_y
parameters for arbitrary-center rotation.
Test drawable-level transforms (reflect, scale, shear, rotate_around)
on Point, Segment, Vector, Triangle, Circle, and Ellipse. Test manager
orchestration for reflect_object, scale_object, shear_object, and
rotate_object with arbitrary center. Verify undo archiving, error
cases (non-uniform circle scale, shear on circle/ellipse, missing
drawable, zero-length segment axis, single center coord).
Add Geometric Transformations section to Example Prompts with reflect,
scale, shear, and arbitrary-center rotation examples.

Update Reference Manual: TransformationsManager description and methods,
Canvas methods, drawable method lists for Point, Segment, Vector,
Polygon, Circle, and Ellipse, and function category summaries.
…d transforms

Fix dependency refresh to use moved_points presence instead of a
hard-coded class name set, so all Polygon subclasses (Quadrilateral,
Pentagon, Hexagon, etc.) get proper segment formula and cache refresh
after transforms. Also refactor translate_object to use the shared
_refresh_dependencies_after_transform helper.

Add _validate_shear_support and _validate_scale_support checks that
run before undo archiving, so unsupported operations (shear on
circle/ellipse, non-uniform scale on circle/rotated ellipse) raise
ValueError without polluting the undo history.

Add tests verifying archive is not called on rejected transforms.
@vl3c vl3c force-pushed the feature/transform-workflows branch from ba061be to a1b2f40 Compare February 16, 2026 18:28
Expand test_transforms.py from 42 to 126 test methods covering:
- Point: general line reflection, identity transforms, negative scale,
  non-origin shear centers, unknown axis no-op behavior
- Segment: y-axis/arbitrary line reflection, shear with visible effect,
  formula recalculation after scale (fix weak assertion)
- Vector: shear and rotate_around
- Rectangle: drawable-level reflect, scale, rotate_around
- Circle: y-axis/line reflection, scale from non-origin, negative scale
  center movement
- Ellipse: line reflection with offset, zero scale, negative scale,
  180-aligned non-uniform scale, modulo wrap, degenerate line no-op
- Manager: line axis, invalid axis, zero coefficients, segment not found,
  empty segment name, zero/threshold scale factors, invalid shear axis,
  excluded types (Function/Graph/Angle), no-archive on missing drawable,
  rotate point/circle exclusion without center, return values, redraw
  control, segment formula refresh
- Invariants: double reflect identity, scale inverse identity, 360
  rotation, four 90s rotation, shear inverse identity
- Composition: reflect+scale, shear+rotate, scale+reflect circle,
  rotate+reflect ellipse

Fix two weak existing tests found by Codex review:
- test_segment_scale_verifies_line_formula: was a no-op assertion
- test_composition_shear_then_rotate: shear had no visible effect (dy=0)
@vl3c vl3c merged commit 79bceec into main Feb 16, 2026
1 check passed
@vl3c vl3c deleted the feature/transform-workflows branch February 16, 2026 19:41
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