generate script max slope picture billiards
This commit is contained in:
		
							
								
								
									
										14
									
								
								max_slope_picture_billiards/generate.hs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								max_slope_picture_billiards/generate.hs
									
									
									
									
									
										Normal 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"
 | 
				
			||||||
		Reference in New Issue
	
	Block a user