gluturtle 0.0.56 → 0.0.58
raw patch · 5 files changed
+11/−130 lines, 5 filesdep −random
Dependencies removed: random
Files
- gluturtle.cabal +1/−12
- src/Graphics/UI/GLUT/Turtle/GLUTools.hs +8/−1
- src/Graphics/UI/GLUT/Turtle/Move.hs +2/−0
- tests/randomTurtle.hs +0/−61
- tests/testGLUT.hs +0/−56
gluturtle.cabal view
@@ -2,7 +2,7 @@ cabal-version: >= 1.6 name: gluturtle-version: 0.0.56+version: 0.0.58 stability: alpha author: Yoshikuni Jujo <PAF01143@nifty.ne.jp> maintainer: Yoshikuni Jujo <PAF01143@nifty.ne.jp>@@ -32,14 +32,3 @@ Graphics.UI.GLUT.Turtle.Triangles, Graphics.UI.GLUT.Turtle.TriangleTools, Graphics.UI.GLUT.Turtle.GLUTools, Graphics.UI.GLUT.Turtle.Console--executable testTurtle- Hs-source-dirs: tests, src- Main-is: testGLUT.hs- Ghc-options: -Wall--executable randomTurtle- Hs-source-dirs: tests, src- Main-is: randomTurtle.hs- Build-depends: random- Ghc-options: -Wall
src/Graphics/UI/GLUT/Turtle/GLUTools.hs view
@@ -25,9 +25,16 @@ import Graphics.UI.GLUT.Turtle.Triangles +{- import Graphics.UI.GLUT hiding ( initialize, createWindow, keyboardMouseCallback, currentWindow,- windowSize, Key(..), SpecialKey, Color)+ windowSize, Key(..), SpecialKey, Color, keyboardCallback)+ -}+import Graphics.UI.GLUT (+ ($=), initialDisplayMode, DisplayMode(RGBMode, DoubleBuffered), Window,+ initialWindowSize, Size(Size), Position(Position), Vertex3(Vertex3),+ GLfloat, Color4(Color4), KeyState(..), Modifiers, swapBuffers+ ) import qualified Graphics.UI.GLUT as G import System.Environment import Control.Monad
src/Graphics/UI/GLUT/Turtle/Move.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE PatternGuards #-}+ module Graphics.UI.GLUT.Turtle.Move( initialize,
− tests/randomTurtle.hs
@@ -1,61 +0,0 @@-module Main where--import Graphics.UI.GLUT.Turtle-import Graphics.UI.GLUT(addTimerCallback, mainLoop)-import System.Random-import Control.Monad-import Data.Word--main :: IO ()-main = do- _args <- initialize- f <- openField "random" 480 480- t <- newTurtle f--- pencolor t "white"- pensize t 3- pencolor t ((255, 255, 255) :: (Int, Int, Int))- preprocess t- (x0, y0) <- position t- addTimerCallback 100 $ timerProc $ draw t x0 y0- mainLoop--timerProc :: IO a -> IO ()-timerProc act = do- _ <- act- addTimerCallback 20 $ timerProc act--randomWord8 :: IO Word8-randomWord8 = fmap fromIntegral (randomRIO (0, 255) :: IO Int)--randomTurtle :: Turtle -> IO ()-randomTurtle t = do- preprocess t- (x0, y0) <- position t- sequence_ $ repeat $ draw t x0 y0--preprocess :: Turtle -> IO ()-preprocess t = do- penup t- shape t "turtle"- shapesize t 2 2- (x0, y0) <- position t- forward t 100- pendown t- left t 90- circle t 100- penup t- goto t x0 y0- pendown t- position t >>= print--draw :: Turtle -> Double -> Double -> IO ()-draw t x0 y0 = do- d <- randomRIO (- 180, 180)- r <- randomWord8- g <- randomWord8- b <- randomWord8- pencolor t (r, g, b)- left t d- forward t 15- dist <- distance t x0 y0- when (dist > 100) $ undo t
− tests/testGLUT.hs
@@ -1,56 +0,0 @@-import Graphics.UI.GLUT.Turtle-import Graphics.UI.GLUT hiding (position, initialize, clear)--main :: IO ()-main = do- _args <- initialize- f <- openField "test" 640 480- c <- openConsole "console" 640 480- consolePrompt c "> "- setConsole f c- t <- newTurtle f- onclick f $ \_bn x y -> goto t x y >> return True- oncommand f (processInput f c t)--- speed t "slowest"--- fillcolor t ((255, 255, 255) :: (Int, Int, Int))--- pencolor t ((255, 255, 255) :: (Int, Int, Int))--- threadDelay 1000000--- left t 45--- forward t 100- mainLoop--processInput :: Field -> Console -> Turtle -> String -> IO Bool-processInput _ _ t "forward" = forward t 100 >> return True-processInput _ _ t "left" = left t 90 >> return True-processInput _ _ t "right" = right t 90 >> return True-processInput _ _ t "begin" = beginfill t >> return True-processInput _ _ t "end" = endfill t >> return True-processInput _ _ t "turtle" = shape t "turtle" >> return True-processInput _ _ t "stamp" = stamp t >> return True-processInput _ _ t "bold" = pensize t 7 >> return True-processInput _ _ t "verybold" = pensize t 10 >> return True-processInput _ _ t "big" = shapesize t 3 3 >> return True-processInput _ _ t "blue" = pencolor t ((0, 0, 255) :: (Int, Int, Int)) >> return True-processInput _ _ t "fblue" = fillcolor t ((0, 0, 255) :: (Int, Int, Int)) >> return True-processInput _ _ t "yellow" = pencolor t ((255, 255, 0) :: (Int, Int, Int)) >> return True-processInput _ _ t "normal" = pensize t 1 >> return True-processInput _ _ _ "exit" = return False-processInput _ c t "position" = position t >>= consoleOutput c . show >> return True-processInput _ _ t "penup" = penup t >> return True-processInput _ _ t "pendown" = pendown t >> return True-processInput _ _ t "message" = write t "KochiGothic" 100 "Hello, world!" >> return True-processInput _ _ _ "0very1very2very3very4very5very6very7very8very9very0very-long-line"- = putStrLn "very long line" >> return True-processInput _ _ t "hide" = hideturtle t >> return True-processInput _ _ t "bred" = bgcolor t ((255, 0, 0) :: (Int, Int, Int)) >> return True-processInput _ _ t "bgreen" = bgcolor t ((0, 255, 0) :: (Int, Int, Int)) >> return True--- processInput _ _ t "home" = goto t 0 0 >> return True-processInput _ _ t "undo" = undo t >> return True-processInput f _ _ "size" = setFieldSize f 100 200 >> return True-processInput f _ _ "topleft" = topleft f >> return True-processInput f _ _ "center" = center f >> return True-processInput _ _ t "goto100" = goto t 100 100 >> return True-processInput _ _ t "clear" = clear t >> return True-processInput _ _ t "svg" = getSVG t >>= print >> return True-processInput _ _ t "home" = home t >> return True-processInput _ _ _ _ = return True