cpp-and-hs.hs
Text Reading C++ and Haskell
This was used as a “flavour image” for a blog post on Haskell FFI
#!/usr/bin/env stack
{- stack script --resolver lts-22.6
--package linear
--package waterfall-cad
--extra-dep waterfall-cad-0.4.0.0
--extra-dep opencascade-hs-0.4.0.0
-}
-- short-description: Text Reading C++ and Haskell
--
-- description: Text Reading C++ and Haskell
-- description:
-- description: This was used as a "flavour image" for a [blog post](../posts/2024-01-23-ffi.html)
-- description: on Haskell FFI
import qualified Waterfall
import Linear
import Data.Function ((&))
renderText :: Waterfall.Font -> String -> Waterfall.Solid
=
renderText font t &
Waterfall.text font t 0.1 &
Waterfall.prism pi/2)
Waterfall.rotate (unit _x) (
object :: Waterfall.Font -> Waterfall.Solid
=
object font let box = Waterfall.scale (V3 175 14 14) Waterfall.centeredCube
=
nameOne "c++" &
renderText font 0.1 *^ unit _z) &
Waterfall.translate (0.2
Waterfall.rotate (unit _z) and = renderText font "&"
=
nameTwo "haskell" &
renderText font -0.1 *^ unit _z) &
Waterfall.translate (-0.2)
Waterfall.rotate (unit _z) (in mconcat [nameOne, and, nameTwo]
main :: IO ()
= do
main <- Waterfall.fontFromSystem "monospace" Waterfall.Regular 0.15
font 0.01 "cpp-plus-hs.stl" (object font)
Waterfall.writeSTL