programdemos/rosetta/cube.xtl
ᵘs̲creen : Float -> Float
ᵘs̲creen ← { f → p ← eye ᵍp̲roject f xs ← (size ÷ 2) + zoom × 1 s̲elect p ys ← (size ÷ 2) − zoom × 2 s̲elect p (2 c̲at t̲ally xs) r̲eshape xs c̲at ys }
Used in: ᵘp̲olygon
ᵘn̲ormal : Num a => a -> a
ᵘn̲ormal ← { f → u ← (2 s̲elect₂ f) − 1 s̲elect₂ f w ← (4 s̲elect₂ f) − 1 s̲elect₂ f ((1 o̲- u) × 2 o̲- w) − (2 o̲- u) × 1 o̲- w }
Used in: ᵘl̲it
ᵘl̲it : Float -> Float
ᵘl̲it ← { f → n ← ᵘn̲ormal f center ← ('+ r̲/ o̲\ f) ÷ 4.0 outward ← n × (2.0 × f̲loat 0 < '+ r̲/ n × center) − 1.0 0 m̲ax ('+ r̲/ outward × light) ÷ ('+ r̲/ n × n) ^ 0.5 }
Used in: ᵘp̲olygon
ᵘp̲olygon : Truthy a => a -> Float -> Char
ᵘp̲olygon ← { shaded f → fill ← ᵛf̲ill "shaded" i̲f< "v:r_gb 3 r_eshape 40 + 200 * u:l_it f; \"none\"" (fill c̲at "#222" ᵛs̲troke 1.5) ᵛp̲olygon f̲loor 0.5 + ᵘs̲creen f }
Used in: ᵘs̲cene
ᵘs̲cene : Truthy a => a -> Float -> Char
ᵘs̲cene ← { shaded a → turned ← ((ᵍr̲otY 1.3 × a) ᵍt̲urn ᵍr̲otX a) ᵍt̲urn cube solid ← faces ᵍs̲olid turned polygons ← '{ i → shaded ᵘp̲olygon i s̲elect solid } m̲ap ᵍo̲rder solid (size c̲at size) ᵛp̲icture d̲isclose '{ x y → e̲nclose (d̲isclose x) c̲at d̲isclose y } r̲/ polygons }
Used in: ᵘf̲rame