From 1f5ed42288bdf0b0c4b96517a5d306c9fa616364 Mon Sep 17 00:00:00 2001 From: David Himmelstrup Date: Thu, 5 Dec 2019 18:59:54 +0800 Subject: [PATCH] Improve povray examples. Former-commit-id: c7d6f6ced12cc3ee017d57bfc59fb0d54a1f5093 --- docs/gallery.md | 15 +++++++++++++++ examples/tut_glue_povray.hs | 32 ++----------------------------- examples/tut_glue_povray_ortho.hs | 12 +++++------- 3 files changed, 22 insertions(+), 37 deletions(-) diff --git a/docs/gallery.md b/docs/gallery.md index fa2a5c8..d618912 100644 --- a/docs/gallery.md +++ b/docs/gallery.md @@ -256,3 +256,18 @@ This file is auto-generated by docs/render_all.sh. DO NOT EDIT.


+## tut_glue_povray_ortho + +
+ View tut_glue_povray_ortho.hs +

+  {!examples/tut_glue_povray_ortho.hs!}
+  
+
+
+ + +


+ diff --git a/examples/tut_glue_povray.hs b/examples/tut_glue_povray.hs index 683befe..c99b843 100755 --- a/examples/tut_glue_povray.hs +++ b/examples/tut_glue_povray.hs @@ -33,7 +33,7 @@ main = reanimate $ parA bg $ sceneAnimation $ do getZ <- freezeVar zRot return $ \real_t dur t -> povraySlow [] $ - script (svgAsPngFile (texture (t/dur))) (transZ real_t) (getX real_t) (getZ real_t) + script (svgAsPngFile (texture (t/dur))) (transZ real_t) (getX real_t) (getZ real_t) wait 2 tweenVar zPos 9 (\t v -> fromToS v 8 (t/9)) tweenVar xRot 9 (\t v -> fromToS v 360 $ curveS 2 (t/9)) @@ -45,9 +45,7 @@ main = reanimate $ parA bg $ sceneAnimation $ do bg = animate $ const $ mkBackgroundPixel $ PixelRGBA8 252 252 252 0xFF texture :: Double -> SVG -texture t = mkGroup - [ checker 10 10 - , frameAt (t*duration latexExample) latexExample ] +texture t = frameAt (t*duration latexExample) latexExample script :: FilePath -> Double -> Double -> Double -> Text script png transZ rotX rotZ = [iTrim| @@ -83,32 +81,6 @@ polygon { } |] -checker :: Int -> Int -> SVG -checker w h = - withFillColor "white" $ - withStrokeColor "white" $ - withStrokeWidth 0.1 $ - mkGroup - [ withStrokeWidth 0 $ - withFillOpacity 1 $ mkBackground "blue" - , mkGroup - [ translate (stepX*x-offsetX + stepX/2) 0 $ - mkLine (0, -screenHeight/2*0.9) (0, screenHeight/2*0.9) - | x <- map fromIntegral [0..w-1] - ] - , - mkGroup - [ translate 0 (stepY*y-offsetY) $ - mkLine (-screenWidth/2, 0) (screenWidth/2, 0) - | y <- map fromIntegral [0..h] - ] - ] - where - stepX = screenWidth/fromIntegral w - stepY = screenHeight/fromIntegral h - offsetX = screenWidth/2 - offsetY = screenHeight/2 - ----------------------------------- -- COPIED FROM tut_glue_latex.hs -- diff --git a/examples/tut_glue_povray_ortho.hs b/examples/tut_glue_povray_ortho.hs index 2fbaf9c..a8adbd7 100755 --- a/examples/tut_glue_povray_ortho.hs +++ b/examples/tut_glue_povray_ortho.hs @@ -34,7 +34,7 @@ main = reanimate $ parA bg $ sceneAnimation $ do getZ <- freezeVar zRot return $ \real_t dur t -> povraySlow [] $ - script (svgAsPngFile (texture (t/dur))) (getX real_t) (getY real_t) (getZ real_t) + script (svgAsPngFile (texture (t/dur))) (getX real_t) (getY real_t) (getZ real_t) wait 2 let tDuration = 20 tweenVar yRot tDuration (\t v -> fromToS v (v+180) $ curveS 2 (t/tDuration)) @@ -52,7 +52,7 @@ main = reanimate $ parA bg $ sceneAnimation $ do texture :: Double -> SVG texture t = mkGroup - [ checker 10 10 + [ checker 20 20 , frameAt (t*duration latexExample) latexExample ] @@ -97,12 +97,11 @@ sphere { checker :: Int -> Int -> SVG checker w h = - withFillColor "white" $ - withStrokeColor "white" $ - withStrokeWidth 0.1 $ + withStrokeColor "lightblue" $ + withStrokeWidth (defaultStrokeWidth/2) $ mkGroup [ withStrokeWidth 0 $ - withFillOpacity 0.7 $ mkBackground "blue" + withFillOpacity 0.8 $ mkBackground "white" , mkGroup [ translate (stepX*x-offsetX + stepX/2) 0 $ mkLine (0, -screenHeight/2*0.9) (0, screenHeight/2*0.9) @@ -200,4 +199,3 @@ drawAnimation' mbSeed fillDur step svg = sceneAnimation $ do case mbSeed of Nothing -> lst Just seed -> shuffle' lst (length lst) (mkStdGen seed) -