gluturtle 0.0.5 → 0.0.6
raw patch · 3 files changed
+20/−5 lines, 3 files
Files
- gluturtle.cabal +2/−2
- src/Graphics/UI/GLUT/Turtle/Field.hs +17/−3
- tests/testGLUT.hs +1/−0
gluturtle.cabal view
@@ -2,7 +2,7 @@ cabal-version: >= 1.6 name: gluturtle-version: 0.0.5+version: 0.0.6 stability: alpha author: Yoshikuni Jujo <PAF01143@nifty.ne.jp> maintainer: Yoshikuni Jujo <PAF01143@nifty.ne.jp>@@ -28,7 +28,7 @@ Ghc-options: -Wall Other-modules: Graphics.UI.GLUT.Turtle.Field, Graphics.UI.GLUT.Turtle.Input, Graphics.UI.GLUT.Turtle.Move, Graphics.UI.GLUT.Turtle.State,- Graphics.UI.GLUT.Turtle.Data, Graphics.UI.GLUT.Turtle.Layers+ Graphics.UI.GLUT.Turtle.Data, Graphics.UI.GLUT.Turtle.Layers, Graphics.UI.GLUT.Turtle.Triangles, Graphics.UI.GLUT.Turtle.TriangleTools executable testTurtle
src/Graphics/UI/GLUT/Turtle/Field.hs view
@@ -232,12 +232,25 @@ positionToVertex3 :: Position -> Vertex2 GLfloat positionToVertex3 (Center x y) = Vertex2 (fromRational $ toRational x / 300)- (fromRational $ toRational y / 300 + 0.2)+ (fromRational $ toRational y / 300) positionToVertex3 _ = error "positionToVertex3: not implemented" writeString :: Field -> Layer -> String -> Double -> Color -> Position -> String -> IO ()-writeString _f _ _fname _size _clr _pos _str = return ()+writeString f _ _fname size clr (Center x_ y_) str =+ atomicModifyIORef_ (fActions f) (action :)+ where+ action = preservingMatrix $ do+ let size' = size / 15+ x = 6.666 * fromRational (toRational $ x_ / size')+ y = 6.666 * fromRational (toRational $ y_ / size')+ s = 0.0005 * fromRational (toRational size')+ G.color $ colorToColor4 clr+ G.scale (s :: GLfloat) (s :: GLfloat) (s :: GLfloat)+ G.clearColor $= G.Color4 0 0 0 0+ G.translate (G.Vector3 x y 0 :: G.Vector3 GLfloat)+ G.renderString G.Roman str+writeString _ _ _ _ _ _ _ = error "writeString: not implemented" drawImage :: Field -> Layer -> FilePath -> Position -> Double -> Double -> IO () drawImage _f _ _fp _pos _w _h = return ()@@ -295,7 +308,8 @@ writeIORef (fString f) "" continue <- ($ str) =<< readIORef (fInputtext f) unless continue G.leaveMainLoop-keyboardProc f (G.Char '\b') G.Down _ _ = atomicModifyIORef_ (fString f) init+keyboardProc f (G.Char '\b') G.Down _ _ =+ atomicModifyIORef_ (fString f) $ \s -> if null s then s else init s keyboardProc f (G.Char c) state _ _ | state == G.Down = atomicModifyIORef_ (fString f) (++ [c]) | otherwise = return ()
tests/testGLUT.hs view
@@ -35,4 +35,5 @@ processInput _ _ "exit" = return False processInput f t "position" = position t >>= outputString f . show >> return True processInput _ t "penup" = penup t >> return True+processInput _ t "message" = write t "KochiGothic" 20 "Hello, world!" >> return True processInput _ _ _ = return True