From c91b133c880fb1131df90473727ee0712c2e160a Mon Sep 17 00:00:00 2001 From: Louis Dalibard Date: Tue, 24 Dec 2024 17:14:37 +0100 Subject: [PATCH] yes --- palette-generator/Stylix/Main.hs | 6 +++--- palette-generator/Stylix/Palette.hs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/palette-generator/Stylix/Main.hs b/palette-generator/Stylix/Main.hs index d85c16e..ddeecb0 100644 --- a/palette-generator/Stylix/Main.hs +++ b/palette-generator/Stylix/Main.hs @@ -11,8 +11,8 @@ import Text.JSON ( encode ) import Text.Read (readMaybe) -- String to float -stringToFloat :: String -> Float -stringToFloat s = case readMaybe s of +stringToDouble :: String -> Double +stringToDouble s = case readMaybe s of Just x -> x Nothing -> error "Invalid float value" @@ -29,7 +29,7 @@ mainProcess (polarity,primaryScaleDark,primaryScaleLight, input, output) = do setStdGen $ mkStdGen 0 image <- loadImage input - palette <- evolve (polarity,stringToFloat primaryScaleDark,stringToFloat primaryScaleLight,convertRGB8 image) + palette <- evolve (polarity,stringToDouble primaryScaleDark,stringToDouble primaryScaleLight,convertRGB8 image) let outputTable = makeOutputTable $ V.map lab2rgb palette writeFile output $ encode outputTable diff --git a/palette-generator/Stylix/Palette.hs b/palette-generator/Stylix/Palette.hs index d6d3794..2e5adc7 100644 --- a/palette-generator/Stylix/Palette.hs +++ b/palette-generator/Stylix/Palette.hs @@ -38,7 +38,7 @@ randomFromImage image = do color = RGB (fromIntegral r) (fromIntegral g) (fromIntegral b) return $ rgb2lab color -instance Species (String,Float,Float, Image PixelRGB8) (V.Vector LAB) where +instance Species (String,Double,Double, Image PixelRGB8) (V.Vector LAB) where generate (_,_,_, image) = V.replicateM 16 $ randomFromImage image crossover _ a b = return $ alternatingZip a b