Add simple high pipes

This commit is contained in:
2021-06-21 16:29:24 +02:00
parent 04ed034a3e
commit c2297cd114
8 changed files with 54 additions and 12 deletions
+17 -4
View File
@@ -1,5 +1,6 @@
module Dodge.Room.Foreground
where
import Dodge.Picture
import Picture
import Geometry
import Geometry.Data
@@ -14,11 +15,11 @@ highDiagonalMesh
-> Float -- ^ vertical distance between lines
-> Picture
highDiagonalMesh pa pb w d = setDepth (-0.2) $ pictures $
(map (flip thickLine 1 . flat2) $ diagonalLinesRect pb pa w d (pi/4))
(map (flip thickLine 3 . flat2) $ diagonalLinesRect pb pa w d (3*pi/4))
++
(map (flip thickLine 1 . flat2) $ diagonalLinesRect pa pc h d (3* pi/4))
(map (flip thickLine 3 . flat2) $ diagonalLinesRect pb pc (negate h) d (pi/4))
where
pc = pa +.+ w *.* normalizeV (vNormal (pb -.- pa))
pc = pb +.+ w *.* normalizeV (vNormal (pb -.- pa))
h = dist pa pb
diagonalLinesRect
@@ -34,10 +35,22 @@ diagonalLinesRect pa pb w d ang = zip lhsPoints $ map findDiPoint lhsPoints
diVec = rotateV ang xVec
pax = pa +.+ xVec
pbx = pb +.+ xVec
lhsPoints = divideLine d (pa -.- yN) (pb +.+ yN)
lhsPoints = divideLineExact d (pa -.- yN) (pb +.+ yN)
findDiPoint p = head . sortOn (dist p) $ catMaybes
[intersectLineLine' p (p +.+ diVec) pax pbx
,intersectSegLine' pa pax p (p +.+ diVec)
,intersectSegLine' pb pbx p (p +.+ diVec)
]
yN = d * 0.5 *.* (normalizeV $ pa -.- pb)
highPipe :: Point2 -> Point2 -> Picture
highPipe x y = pictures
[setDepth (-0.2) $ thickLine [x,y] 10
,setDepth (-0.19) $ color orange $ thickLine [x,y] 10
,verticalPipe 5 orange x 0 (-0.2)
,verticalPipe 5 orange y 0 (-0.2)
,verticalPipe 5 orange (0.5 *.* (x +.+ y)) (-0.1) (-0.2)
]
--highGirder :: Point2 -> Point2 -> Picture
--highGirder x y =