Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,23 @@
import System.Environment (getArgs)
plotChar :: Int -> Float -> Float -> Float -> Float -> Char
plotChar iter cReal cImag y x
| zReal^2 > 10000 = ' '
| iter == 1 = '#'
| otherwise = plotChar (pred iter) cReal cImag zImag zReal
where
zReal = x * x - y * y + cReal
zImag = x * y * 2 + cImag
parseArgs :: [String] -> (Float, Float)
parseArgs [] = (-0.8, 0.156)
parseArgs [cReal, cImag] = (read cReal :: Float, read cImag :: Float)
parseArgs _ = error "Invalid arguments"
main :: IO ()
main = do
args <- getArgs
let (cReal, cImag) = parseArgs args
print (cReal, cImag)
mapM_ putStrLn $ [-100,-96..100] >>= \y ->
[[-280,-276..280] >>= \x -> [plotChar 50 cReal cImag (y/100) (x/200)]]

View file

@ -0,0 +1,17 @@
{-# LANGUAGE LambdaCase #-}
getJuliaValues :: Float -> Float -> Float -> Float -> Float -> Int -> [[Int]]
getJuliaValues width height centerX centerY zoom maxIter =
[0..pred height] >>= \h -> [[0..pred width] >>= \w -> [calc h w]]
where
initzx x = 1.5 * (x - width / 2) / (0.5 * zoom * width)
initzy y = 1.0 * (y - height / 2) / (0.5 * zoom * height)
calc y x = loop 0 (initzx x) (initzy y)
where
loop i zx zy
| zx * zx + zy * zy >= 4.0 = i
| i == maxIter = 0
| otherwise = loop (succ i) (zx*zx - zy*zy + centerX) (2.0*zx*zy + centerY)
main :: IO ()
main = mapM_ (putStrLn . fmap (\case 0 -> '#'; _ -> ' ')) (getJuliaValues 140 50 (-0.8) 0.156 1.0 50)