module Math.Combinat.Diagrams.Tableaux where
import Math.Combinat.Tableaux
import Math.Combinat.Partitions
import Math.Combinat.Diagrams.Partitions
import Linear.Vector
import Data.Colour
import Diagrams.Core
import Diagrams.Prelude
import Diagrams.TwoD.Text
drawTableau :: (Renderable (Path V2 Double) b, Renderable (Text Double) b) => Tableau Int -> QDiagram b V2 Double Any
drawTableau = drawTableau' EnglishNotation black
drawTableau'
:: (Renderable (Path V2 Double) b, Renderable (Text Double) b)
=> PartitionConvention
-> Colour Double
-> Tableau Int
-> QDiagram b V2 Double Any
drawTableau' convention color tableau = numbers <> boxes where
part = tableauShape tableau
ps = fromPartition part :: [Int]
n = length ps
numbers = mconcat [ number j i a | i<-[(0::Int)..n1], (j,a)<-zip [(0::Int)..] (tableau!!i) ]
# lc color
number x y a = trafo x y $ scale (0.85 :: Double) $ text (show a) # lw none # lc color # fc color
v = 0.22 :: Double
trafo x y = case convention of
EnglishNotation -> translate (r2 (0.5 + fromIntegral x , 1 + v fromIntegral y))
EnglishNotationCCW -> translate (r2 (0.5 + fromIntegral y , v + fromIntegral x))
FrenchNotation -> translate (r2 (0.5 + fromIntegral x , v + fromIntegral y))
boxes = drawPartitionBoxes convention part