yes
This commit is contained in:
parent
4f079e775d
commit
c6ebdab026
@ -8,6 +8,13 @@ import System.Environment ( getArgs )
|
|||||||
import System.Exit ( die )
|
import System.Exit ( die )
|
||||||
import System.Random ( setStdGen, mkStdGen )
|
import System.Random ( setStdGen, mkStdGen )
|
||||||
import Text.JSON ( encode )
|
import Text.JSON ( encode )
|
||||||
|
import Text.Read (readMaybe)
|
||||||
|
|
||||||
|
-- String to float
|
||||||
|
stringToFloat :: String -> Float
|
||||||
|
stringToFloat s = case readMaybe s of
|
||||||
|
Just x -> x
|
||||||
|
Nothing -> error "Invalid float value"
|
||||||
|
|
||||||
-- | Load an image file.
|
-- | Load an image file.
|
||||||
loadImage :: String -- ^ Path to the file
|
loadImage :: String -- ^ Path to the file
|
||||||
@ -22,7 +29,7 @@ mainProcess (polarity,primaryScaleDark,primaryScaleLight, input, output) = do
|
|||||||
setStdGen $ mkStdGen 0
|
setStdGen $ mkStdGen 0
|
||||||
|
|
||||||
image <- loadImage input
|
image <- loadImage input
|
||||||
palette <- evolve (polarity, primaryScaleDark,primaryScaleLight,convertRGB8 image)
|
palette <- evolve (polarity,stringToFloat primaryScaleDark,stringToFloat primaryScaleLight,convertRGB8 image)
|
||||||
let outputTable = makeOutputTable $ V.map lab2rgb palette
|
let outputTable = makeOutputTable $ V.map lab2rgb palette
|
||||||
|
|
||||||
writeFile output $ encode outputTable
|
writeFile output $ encode outputTable
|
||||||
|
@ -34,7 +34,7 @@ randomFromImage image = do
|
|||||||
color = RGB (fromIntegral r) (fromIntegral g) (fromIntegral b)
|
color = RGB (fromIntegral r) (fromIntegral g) (fromIntegral b)
|
||||||
return $ rgb2lab color
|
return $ rgb2lab color
|
||||||
|
|
||||||
instance Species (String,String,String, Image PixelRGB8) (V.Vector LAB) where
|
instance Species (String,Float,Float, Image PixelRGB8) (V.Vector LAB) where
|
||||||
generate (_,_,_, image) = V.replicateM 16 $ randomFromImage image
|
generate (_,_,_, image) = V.replicateM 16 $ randomFromImage image
|
||||||
|
|
||||||
crossover _ a b = return $ alternatingZip a b
|
crossover _ a b = return $ alternatingZip a b
|
||||||
@ -84,15 +84,31 @@ instance Species (String,String,String, Image PixelRGB8) (V.Vector LAB) where
|
|||||||
lightScheme
|
lightScheme
|
||||||
= lightnessError (V.fromList [90, 70, 55, 35, 25, 10, 5, 5]) 40
|
= lightnessError (V.fromList [90, 70, 55, 35, 25, 10, 5, 5]) 40
|
||||||
|
|
||||||
|
// 0.2, 0.133,0.178,0.85,0.93,0.88,1.0,1.0 for 0.1 scale
|
||||||
|
// f(x) = ax+b for multiplier (light)
|
||||||
|
// 0.889, 0.111
|
||||||
|
// 0.963, 0.037
|
||||||
|
// 0.913, 0.087
|
||||||
|
// 0.167, 0.833
|
||||||
|
// 0.078, 0.922
|
||||||
|
// 0.133, 0.087
|
||||||
|
// 0.0, 1.0
|
||||||
|
// 0.0, 1.0
|
||||||
|
|
||||||
{-
|
{-
|
||||||
For dark themes, the background is dark and the text is bright.
|
For dark themes, the background is dark and the text is bright.
|
||||||
The accent colours are slightly brighter.
|
The accent colours are slightly brighter.
|
||||||
-}
|
-}
|
||||||
darkScheme
|
darkScheme
|
||||||
= lightnessError (V.fromList [10, 30, 45, 65, 75, 90, 95, 95]) 60
|
= lightnessError (V.fromList [10, 30, 45, 65, 75, 90, 95, 95]) 60
|
||||||
|
|
||||||
darkerScheme
|
// 0.2, 0.133,0.178,0.85,0.93,0.88,1.0,1.0 for 0.1 scale
|
||||||
= lightnessError (V.fromList [5, 10, 15, 60, 70, 80, 95, 95]) 60
|
// f(x) = ax+b for multiplier (dark)
|
||||||
|
// 0.889, 0.111
|
||||||
evenDarkerScheme
|
// 0.963, 0.037
|
||||||
= lightnessError (V.fromList [2, 4, 8, 55, 70, 80, 95, 95]) 60
|
// 0.913, 0.087
|
||||||
|
// 0.167, 0.833
|
||||||
|
// 0.078, 0.922
|
||||||
|
// 0.133, 0.087
|
||||||
|
// 0.0, 1.0
|
||||||
|
// 0.0, 1.0
|
||||||
|
Loading…
Reference in New Issue
Block a user