// Generate an analogous color palette (colors adjacent on color wheel)
///|
pub fn RGB::analogous(self : RGB, count : Int) -> Array[RGB] {
  let hsl = self.to_hsl()
  let result = Array::new()
  let step = 30.0

  for i in 0.. RGB {
  let hsl = self.to_hsl()
  let h = (hsl.h + 180.0) % 360.0
  HSL::to_rgb({ h, s: hsl.s, l: hsl.l })
}

// Generate a triadic color palette (120° apart)

///|
pub fn RGB::triadic(self : RGB) -> Array[RGB] {
  let hsl = self.to_hsl()
  [
    self,
    HSL::to_rgb({ h: (hsl.h + 120.0) % 360.0, s: hsl.s, l: hsl.l }),
    HSL::to_rgb({ h: (hsl.h + 240.0) % 360.0, s: hsl.s, l: hsl.l }),
  ]
}

// Generate a tetradic (square) color palette (90° apart)

///|
pub fn RGB::tetradic(self : RGB) -> Array[RGB] {
  let hsl = self.to_hsl()
  [
    self,
    HSL::to_rgb({ h: (hsl.h + 90.0) % 360.0, s: hsl.s, l: hsl.l }),
    HSL::to_rgb({ h: (hsl.h + 180.0) % 360.0, s: hsl.s, l: hsl.l }),
    HSL::to_rgb({ h: (hsl.h + 270.0) % 360.0, s: hsl.s, l: hsl.l }),
  ]
}

// Generate monochromatic palette (same hue, varying lightness)

///|
pub fn RGB::monochromatic(self : RGB, count : Int) -> Array[RGB] {
  let hsl = self.to_hsl()
  let result = Array::new()

  for i in 0.. Array[RGB] {
  let hsl = self.to_hsl()
  [
    self,
    HSL::to_rgb({ h: (hsl.h + 150.0) % 360.0, s: hsl.s, l: hsl.l }),
    HSL::to_rgb({ h: (hsl.h + 210.0) % 360.0, s: hsl.s, l: hsl.l }),
  ]
}