Ellipse.swift 787 B

12345678910111213141516171819202122232425
  1. /// An ellipse.
  2. public struct Ellipse: InsettableShape {
  3. /// Creates an ``Ellipse`` instance.
  4. public nonisolated init() {}
  5. public nonisolated func path(in bounds: Path.Rect) -> Path {
  6. Path()
  7. .addCircle(center: .zero, radius: bounds.width / 2.0)
  8. .applyTransform(
  9. AffineTransform(
  10. linearTransform: SIMD4(
  11. x: 1.0,
  12. y: 0.0,
  13. z: 0.0,
  14. w: bounds.height / bounds.width
  15. ),
  16. translation: bounds.center
  17. )
  18. )
  19. }
  20. public nonisolated func inset(by amount: Double) -> some InsettableShape {
  21. InsettableShapeImpl(inset: amount, base: self)
  22. }
  23. }