// Core geometric types for the Vg vector graphics library

///|
/// A 2D point in the cartesian plane
#valtype
pub struct Point {
  x : Double
  y : Double
} derive(Eq, Debug)

///|
/// Bounding box
#valtype
pub struct Box {
  min_x : Double
  min_y : Double
  max_x : Double
  max_y : Double
} derive(Eq, Debug)

///|
/// Path segment types
pub(all) enum PathSegment {
  MoveTo(Point)
  LineTo(Point)
  CurveTo(Point, Point, Point) // control1, control2, end (cubic Bézier)
  QCurveTo(Point, Point) // control, end (quadratic Bézier)
  EArcTo(Double, Double, Double, Bool, Bool, Point) // rx, ry, rotation, large_arc, sweep, end
  Close
} derive(Eq, Debug)

///|
/// A path is a sequence of segments. `pub(all)` so downstream packages can build
/// a segment array in one pass instead of through the copying builders.
pub(all) struct Path(Array[PathSegment]) derive(Eq, Debug)

///|
/// 2D transformation matrix
#valtype
pub struct Transform {
  m11 : Double // Scale X
  m12 : Double // Skew Y
  m21 : Double // Skew X
  m22 : Double // Scale Y
  m31 : Double // Translate X
  m32 : Double // Translate Y
} derive(Eq, Debug)

// Explicit method promotions for the derived traits. Without these `extend`
// declarations the compiler implicitly promotes the `impl` methods to regular
// methods, which is deprecated; declaring them keeps `p.equal(q)` /
// `p.to_repr()` working for downstream users.

///|
pub extend Point with Eq::{not_equal, equal}

///|
pub extend Point with Debug::{to_repr}

///|
pub extend Box with Eq::{not_equal, equal}

///|
pub extend Box with Debug::{to_repr}

///|
pub extend PathSegment with Eq::{not_equal, equal}

///|
pub extend PathSegment with Debug::{to_repr}

///|
pub extend Path with Eq::{not_equal, equal}

///|
pub extend Path with Debug::{to_repr}

///|
pub extend Transform with Eq::{not_equal, equal}

///|
pub extend Transform with Debug::{to_repr}