generate script max slope picture billiards

This commit is contained in:
Florian Stecker 2021-10-03 19:29:21 -05:00
parent 19be344749
commit dd940f8f35
1 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,14 @@
-- resize and convert image with
-- convert max_slope_billiards.pnm -scale 3000x max_slope_billiards.png
import Text.Printf
colors = [(0.651,0.808,0.890), (0.122,0.471,0.706), (0.698,0.875,0.541), (0.200,0.627,0.173), (0.984,0.604,0.600), (0.890,0.102,0.110), (0.992,0.749,0.435), (1.000,0.498,0.000), (0.792,0.698,0.839), (0.416,0.239,0.604), (1.000,1.000,0.600), (0.694,0.349,0.157), (1.000,1.000,0.000), (0.000,1.000,1.000)]
col = map (\(r,g,b) -> (round $ r*255, round $ g*255, round $ b*255)) colors :: [(Int,Int,Int)]
main = do
foo <- readFile "max_slopes_billiard"
let dat = map (read.(!!2).words) $ lines foo :: [Int]
writeFile "max_slope_billiards.pnm" $ header ++ unlines [printf "%d %d %d" r g b | p <- dat, let (r,g,b) = col !! (p `mod` 10)]
where
header = "P3\n300\n123\n255\n"