import 'package:flutter/material.dart';

/// Darkens a color by a given percentage
Color darken(Color color, [double amount = 0.3]) {
  assert(amount >= 0 && amount <= 1);
  
  final hsl = HSLColor.fromColor(color);
  final darkened = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0));
  
  return darkened.toColor();
}

/// Lightens a color by a given percentage
Color lighten(Color color, [double amount = 0.3]) {
  assert(amount >= 0 && amount <= 1);
  
  final hsl = HSLColor.fromColor(color);
  final lightened = hsl.withLightness((hsl.lightness + amount).clamp(0.0, 1.0));
  
  return lightened.toColor();
}