-- HTurtle.hs
module HTurtle where
type Point = (Double,Double)
f0 :: String -> IO()
f0 s = putStrLn s
f1 :: String -> IO()
f1 s = do
putStr s
putStrLn "()"
f2 :: String -> Double -> IO()
f2 s n = do
putStr s
putStr "("
putStr $ show n
putStrLn ")"
f2' :: String -> Point -> IO()
f2' s p = do
putStr s
putStrLn $ show p
f3 :: String -> String -> IO()
f3 s s1 = do
putStr s
putStr "("
putStr "\""
putStr s1
putStr "\""
putStrLn ")"
start = f0 "from turtle import *"
end = f1 "done"
pensize = f2 "pensize"
screensize p = f2' "screensize" p
polygon :: [Point] -> String -> Bool -> IO ()
polygon pp@(p:ps) color True = do
fillColor color
beginFill
penup
setPos p
pendown
mapM_ setPos (ps ++ [p])
endFill
line ps c = polygon ps c True
dot p = penup >> setPos p >> pendown >> f1 "dot" >> pendown
penup = f1 "penup"
pendown = f1 "pendown"
triangle = polygon
circle (a,b) x = penup >> setPos (a,b-x) >> pendown >> f2 "circle" x
speed n = f2 "speed" n
shape t = f3 "shape" t
color c = f3 "color" c
fillColor c = f3 "fillcolor" c
beginFill = f1 "begin_fill"
endFill = f1 "end_fill"
setPos (a,b) = f2' "setpos" (a,b)
setx x = f2 "setx" x
sety y = f2 "sety" y
-- end of HTurtle.hs
2023年6月3日土曜日
HTurtle.hs
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿