Get the perspective right in povray example.

Former-commit-id: dde6365fef0939b7c703de73ee25282ecaf55344
This commit is contained in:
David Himmelstrup 2019-12-05 08:17:32 +08:00
commit e87e69c5b9

View file

@ -12,19 +12,21 @@ import Data.Text (Text)
main :: IO () main :: IO ()
main = reanimate $ mkAnimation 10 $ \t -> main = reanimate $ mkAnimation 10 $ \t ->
let s = 4 in -- fromToS 1 4 t in let s = fromToS 0 4 t in
let rot = fromToS 0 (360) t in let rot = fromToS 0 (360) t in
mkGroup mkGroup
[ mkBackground "black" [ mkBackground "black"
, povrayExtreme [] (script (svgAsPngFile (texture t)) s rot) , povraySlow [] (script (svgAsPngFile (texture $ oscillateS t)) s rot)
--, texture -- , texture $ oscillateS t
] ]
where where
texture :: Double -> SVG texture :: Double -> SVG
texture t = mkGroup texture t = mkGroup
[ checker 10 10 [ checker 10 10
, withFillColor "red" $ mkCircle (t*10) ] , translate (screenWidth/2) 0 $
translate (-screenWidth*t) 0 $
withFillColor "red" $ mkCircle 3 ]
script :: FilePath -> Double -> Double -> Text script :: FilePath -> Double -> Double -> Text
script png s rot = [iTrim| script png s rot = [iTrim|
@ -42,17 +44,12 @@ script png s rot = [iTrim|
//Place the camera //Place the camera
camera { camera {
//orthographic
perspective perspective
// angle 50 //location <0,0,-9-${s*2}>
//location <0,-${max 0 (((s**1.5)-1)/16)},-9> location <0,0,-9>
location <0,-${max 0 (((s**1.5)-1))},-22>
//translate <0,-${max 0 (((s**1.5)-1))},-20>
//translate <0,0,-20>
look_at <0,0,0> look_at <0,0,0>
//right x*image_width/image_height up y
//up <0,9,0> right x*16/9
//right <16,0,0>
} }
@ -70,15 +67,15 @@ polygon {
//<-9, -4.5>, <-9, 4.5>, <9, 4.5>, <9, -4.5> //<-9, -4.5>, <-9, 4.5>, <9, 4.5>, <9, -4.5>
<0, 0>, <0, 1>, <1, 1>, <1, 0> <0, 0>, <0, 1>, <1, 1>, <1, 0>
texture { texture {
//pigment{ color rgb <0,0,1> } //pigment{ color rgb <0,1,0> }
pigment{ pigment{
image_map{ png ${png} } image_map{ png ${png} }
} }
} }
scale <16/9,1,1> translate <-1/2,-1/2>
translate <-1.777/2,-0.5> scale <16,9>
scale 9 rotate <0,${rot},${rot}>
rotate <0,0,${rot}> translate <0,0,${s*2}>
} }
|] |]