โ† All examples

mesh algorithms

Polygon offset with miter, round or bevel joins

Grow or shrink a simple 2D polygon by a distance with miter, round or bevel joins, refusing offsets that would make it cross itself. Use it for outlines, margins, toolpaths and walls from floor plans.

Recorded render of Polygon offset with miter, round or bevel joins

What this component contains

  • ATTRIBUTION.md
  • LICENSE
  • README.md
  • component.json
  • example.gltf
  • meshkit.py
  • polygon_offset_2d.py
  • preview.png
  • test_package.py
  • verification/native.json

How it works

Entry points
offset_polygon, build, main
Parameters
distance, join, arc_segments
Complexity
O(n^2) including the self-intersection check
Axes
+Y up, metres; 2D (x, y) maps to (x, 0, -y)

Recorded checks

godot 4.7.2.stable.official.ed1daf0bf

  • generator_runs_system_python
  • generator_runs_verifier_python
  • gltf_strict_structure
  • interpreters_agree
  • example_matches_generator
  • godot_headless_gltf_load
  • godot_compatibility_render

Limits to consider

Offsets that make edges vanish or cross are refused rather than cleaned up (no splitting into several polygons). Holes are not handled; offset each ring separately with the opposite sign. Round joins are polylines of arc_segments chords per right angle.