main = do
    args <- getArgs
    let norm
          | args == []       = norm2
          | head args == "i" = normI
          | n >= 1           = normL n
          | otherwise        = error $ show n ++ " is less than 1: Not a valid norm."
              where n = read $ head args
    sites <- randomSites numpoints
    im <- newImage imgsize
    plotRegions im (closest norm sites)
    plotSites im sites
    savePngFile "voronoi.png" im
  where
    closest norm sites query =
       fst $ minimumBy (compare `on` snd)
                       (map (\(p, c) -> ((p, c), norm (p `sub` query))) sites)


-- Plotting functions
main = do
    args <- getArgs
    let norm
          | args == []       = norm2
          | head args == "i" = normI
          | n >= 1           = normL n
          | otherwise        = error $ show n ++ " is less than 1: Not a valid norm."
              where n = read $ head args
    sites <- randomSites numpoints
    im <- newImage imgsize
    plotRegions im (closest norm sites)
    plotSites im sites
    savePngFile "voronoi.png" im
  where
    closest norm sites query =
       fst $ minimumBy (compare `on` snd)
                       (map (\(p, c) -> ((p, c), norm (p `sub` query))) sites)


-- Plotting functions
main = do
    args <- getArgs
    let norm
          | args == []       = norm2
          | head args == "i" = normI
          | n >= 1           = normL n
          | otherwise        = error $ show n ++ " is less than 1: Not a valid norm."
              where n = read $ head args
    sites <- randomSites numpoints
    im <- newImage imgsize
    plotRegions im (closest norm sites)
    plotSites im sites
    savePngFile "voronoi.png" im
  where
    closest norm sites query =
       fst $ minimumBy (compare `on` snd)
                       (map (\(p, c) -> ((p, c), norm (p `sub` query))) sites)


-- Plotting functions