SmartCorner

sealed interface SmartCorner

Each SmartPoint has a SmartCorner. The default implementation is RegularCorner, which does nothing. RoundedCorner, as the name suggests adds a circular arc instead of a sharp corner.

Other possible corner types (not yet implemented) :

  • ChamferedCorner

  • CoveCorner (like RoundedCorner, but inverted)

  • SteppedRoundedCorner (like RoundedCorner, but with a small square step). In woodworking, edges are often rounded with an additional step.

A corner cannot evaluate its geometry on its own - they depend on the position and corner of the previous and next SmartPoints.

  1. Calls prepare. This calculates the distance in the direction of the prev/next SmartPoint that the corner wants to use.

  2. Determines if the distance is too great, and if so, calls limitDistanceBefore/limitDistanceAfter.

  3. Calls calculate. The geometry is now fixed.

  4. Calls buildCorner to add the corner's geometry to the quantised outline of the shape. For a RegularCorner, a single point (SmartPoint.position). For RoundedCorner, the points on the circular arc. The number of points is determined by a heuristic based on the radius of the corner, and the angle swept.

Corners can be used in conjunction with bezier curves. In this case, the "direction" to the next/previous SmartPoint is based on this SmartPoint's bezier handles, and NOT the direction of the next/previous SmartPoint.position.

Properties

Link copied to clipboard
abstract val distanceAfter: Double

The distance towards the next SmartPoint required by the corner.

Link copied to clipboard
abstract val distanceBefore: Double

The distance towards the previous SmartPoint required by the corner.

Link copied to clipboard
abstract val offsetAfter: Vector2

The end of the corner relative to SmartPoint.position Only valid after calculate has been called.

Link copied to clipboard
abstract val offsetBefore: Vector2

The start of the corner relative to SmartPoint.position. Only valid after calculate has been called.

Functions

Link copied to clipboard
abstract fun buildCorner(prev: SmartPoint?, point: SmartPoint, next: SmartPoint?, to: MutableList<Vector2>)
Link copied to clipboard
abstract fun calculate(prev: SmartPoint?, point: SmartPoint, next: SmartPoint?)
Link copied to clipboard
abstract fun limitDistanceAfter(distance: Double)
Link copied to clipboard
abstract fun limitDistanceBefore(distance: Double)
Link copied to clipboard
abstract fun prepare(prev: SmartPoint?, point: SmartPoint, next: SmartPoint?)