NMV4GGIJSHARTJRLUHX7GTDBOKRYIPFGFAA77F2CAL4HAOIKAMDQC VMPZ6XVHIWAVIWHZ6WEXEZRZLDPQN7NWJIW3YHG5YRH4I2BXXMBAC 6QAAR2VPKVD3II6SKKLQBHRYOFX4NHA6HGJMBMFRPQCVE5OLKWJQC CHFKQM47XREZBR5LKV6J4G7FYXQD3SA5XGDAY7P4JF6IBCMUGG3QC F3QBAH24YMFWMCA3KJBBUWQTCVTCZW7ZWMSCNWJVQVSLK7BG7TGQC NQEZG66FQWQQOOYXN2GK7MHIQH25QBBNKE37GGDJBCHCSKWJZABQC VHUL3O55RPR6QD7IXPMJFWI5EOXHQYAMHCLP2FYAULPAOAWUVQ7QC CWLOBLWQJDZL5EMPWBHK3XRT2TZZ5U5M4WGMHC65MU5YHAAUJPHAC 7QP2V7ZBVZ7SKQ3SYV6NYA7V77G3Y7GF5V6EPIXLIYFSMFRWR4VAC LDXV64JUWYYYPCV6CWMGS3EFX4ZSO7TQ6X327EOQWC5Z6W75UMXQC draw e (s,v) = ATG.centerFull e hex ATG.& (1,1) ATG.% ATG.vcat[ ATG.word " cells demo" ATG.# ATG.color ATG.White ATG.Vivid, ATG.vcat $ select <$> total
draw e (s,v) = ATG.mergePlanes (ATG.centerFull e hex)[ ((1,3) , centerPlaneV (ATG.makeTransparent ' ' $ ATG.blankPlaneFull e) $ borderPlane $ paddingPlane (1,0) ui)
centerPlaneV :: ATG.Plane -> ATG.Plane -> ATG.PlanecenterPlaneV pa pb = ATG.mergePlanes pa [((y,1) , pb)]where(_,ah) = ATG.planeSize pa(_,bh) = ATG.planeSize pby = 1 + div (ah - bh) 2paddingPlane :: (Int,Int) -> ATG.DrawpaddingPlane (h,v) p = uncurry ATG.box (bimap (+h*2) (+v*2) $ ATG.planeSize p) ' ' ATG.*** pborderPlane :: ATG.DrawborderPlane p = ATG.vcat[ ATG.hcat [ ATG.cell '╭' , ATG.word $ replicate w '─' , ATG.cell '╮' ] ATG.# ATG.color ATG.Black ATG.Vivid, ATG.hcat [ ATG.box 1 h '│' ATG.# ATG.color ATG.Black ATG.Vivid , p , ATG.box 1 h '│' ATG.# ATG.color ATG.Black ATG.Vivid], ATG.hcat [ ATG.cell '╰' , ATG.word $ replicate w '─' , ATG.cell '╯' ] ATG.# ATG.color ATG.Black ATG.Vivid]where(w,h) = ATG.planeSize p
select :: Algo -> ATG.Planeselect x = ATG.hcat[ ATG.word (show $ fromEnum x) ATG.# ATG.color (if algo s == x then ATG.Yellow else ATG.White) ATG.Dull, ATG.word " ", ATG.word (toLower <$> show x) ATG.# ATG.color (if algo s == x then ATG.Cyan else ATG.White) ATG.Dull]
(widthFull,heightFull) = ATG.eTermDims e
write :: (Int,Int) -> (ATG.Coords,ATG.Cell)write (x,y)| n == focus s = (c , ATG.paletteColorCell k $ ATG.creaCell $ intToDigit $ fromEnum h)| otherwise = (c , ATG.paletteColorCell k $ ATG.creaCell $ " ·~+=≠co" !! fromEnum h)where
write :: (Int,Int) -> (ATG.Coords,ATG.Cell)write (x,y)| n == focus s = (c , ATG.paletteColorCell k $ ATG.creaCell $ intToDigit $ fromEnum h)| otherwise = (c , ATG.paletteColorCell k $ ATG.creaCell $ " ·~+=≠co" !! fromEnum h)whereh :: Hexh = get v n-- get index of node taking scroll into accountn :: Intn = shift v mx L . shift v my I $ coordToIndex v (mod (x - div y size * size) (3 * size) , mod y size)
-- get index of node taking scroll into accountn :: Intn = shift v mx L . shift v my I $ coordToIndex v (mod (x - div y size * size) (3 * size) , mod y size)
-- stretch, tilt, margin, translate to library coordinate system (1-based (y,x))c :: (Int,Int)c = join bimap succ (size - y , 2 * (x + size) + y)
(mx,my) = indexToCoord v $ center s
k :: Word8| 0 <- fromEnum h , play s = ATG.xterm6LevelRGB 0 1 0| 1 <- fromEnum h , play s = ATG.xterm6LevelRGB 0 1 1| 2 <- fromEnum h , play s = ATG.xterm6LevelRGB 1 1 2| 3 <- fromEnum h , play s = ATG.xterm6LevelRGB 2 1 3| 4 <- fromEnum h , play s = ATG.xterm6LevelRGB 3 1 4| 5 <- fromEnum h , play s = ATG.xterm6LevelRGB 4 2 5| 6 <- fromEnum h , play s = ATG.xterm6LevelRGB 5 3 5| 7 <- fromEnum h , play s = ATG.xterm6LevelRGB 5 4 5| 0 <- fromEnum h = ATG.xterm24LevelGray 2| 1 <- fromEnum h = ATG.xterm24LevelGray 5| 2 <- fromEnum h = ATG.xterm24LevelGray 8| 3 <- fromEnum h = ATG.xterm24LevelGray 11| 4 <- fromEnum h = ATG.xterm24LevelGray 14| 5 <- fromEnum h = ATG.xterm24LevelGray 17| 6 <- fromEnum h = ATG.xterm24LevelGray 23| 7 <- fromEnum h = ATG.xterm24LevelGray 23| otherwise = ATG.xterm24LevelGray 0
-- stretch, tilt, margin, translate to library coordinate system (1-based (y,x))c :: (Int,Int)c = join bimap succ (size - y , 2 * (x + size) + y)
ui :: ATG.Planeui = ATG.vcat[ ATG.word "cells demo" ATG.# ATG.color ATG.White ATG.Vivid, ATG.vcat $ select <$> total]where
k :: Word8| 0 <- fromEnum h , play s = ATG.xterm6LevelRGB 0 1 0| 1 <- fromEnum h , play s = ATG.xterm6LevelRGB 0 1 1| 2 <- fromEnum h , play s = ATG.xterm6LevelRGB 1 1 2| 3 <- fromEnum h , play s = ATG.xterm6LevelRGB 2 1 3| 4 <- fromEnum h , play s = ATG.xterm6LevelRGB 3 1 4| 5 <- fromEnum h , play s = ATG.xterm6LevelRGB 4 2 5| 6 <- fromEnum h , play s = ATG.xterm6LevelRGB 5 3 5| 7 <- fromEnum h , play s = ATG.xterm6LevelRGB 5 4 5| 0 <- fromEnum h = ATG.xterm24LevelGray 2| 1 <- fromEnum h = ATG.xterm24LevelGray 5| 2 <- fromEnum h = ATG.xterm24LevelGray 8| 3 <- fromEnum h = ATG.xterm24LevelGray 11| 4 <- fromEnum h = ATG.xterm24LevelGray 14| 5 <- fromEnum h = ATG.xterm24LevelGray 17| 6 <- fromEnum h = ATG.xterm24LevelGray 23| 7 <- fromEnum h = ATG.xterm24LevelGray 23| otherwise = ATG.xterm24LevelGray 0
select :: Algo -> ATG.Planeselect x = ATG.hcat[ ATG.word (show $ fromEnum x) ATG.# coloured x ATG.Yellow ATG.Dull, ATG.word " ", ATG.word (toLower <$> show x) ATG.# coloured x ATG.Cyan ATG.Dull]coloured :: Algo -> ATG.Color -> ATG.ColorIntensity -> ATG.Drawcoloured x k ki| algo s == x = ATG.color k ki| otherwise = ATG.color ATG.Black ATG.Vivid
ui :: Brick.Widget ()ui = defaultStyle $ Brick.vBox $ Brick.str "cells demo" : (Brick.raw . select <$> total)whereselect :: Algo -> Vty.Imageselect x = Vty.horizCat[ Vty.string (coloured x Vty.yellow) (show $ fromEnum x), Vty.string Vty.defAttr " ", Vty.string (coloured x Vty.cyan) (toLower <$> show x)]coloured :: Algo -> Vty.Color -> Vty.Attrcoloured x c| algo s == x = Vty.withForeColor Vty.defAttr c| otherwise = Vty.withForeColor Vty.defAttr Vty.brightBlack-- hex :: Vty.Image-- hex = Vty.vertCat [ Vty.horizCat [ M.findWithDefault (Vty.char Vty.defAttr ' ') (row,col) vtycellMap | col <- [0 .. 4*size] ] | row <- [0 .. 2*size] ]
vtycellMap :: M.Map (Int,Int) Vty.ImagevtycellMap = M.fromList [ ((size - y , 2*(x+size)+y) , Vty.char attr ch) | x <- [-size..size] , y <- [-size..size] , abs (x+y) <= size , let (attr,ch) = vtycell x y ]vtycell :: Int -> Int -> (Vty.Attr,Char)vtycell x y = (Vty.withForeColor Vty.defAttr col , ch)where
vtycellMap :: M.Map (Int,Int) Vty.ImagevtycellMap = M.fromList [ ((size - y , 2*(x+size)+y) , Vty.char attr ch) | x <- [-size..size] , y <- [-size..size] , abs (x+y) <= size , let (attr,ch) = vtycell x y ]
h = get v nn = shift v mx L . shift v my I $ coordToIndex v (mod (x - div y size * size) (3*size) , mod y size)(mx,my) = indexToCoord v $ center sch | n == focus s = intToDigit $ fromEnum h| otherwise = " ·~+=≠co" !! fromEnum hcol = k (fromEnum h)k :: Int -> Vty.Colork i| play s , 0 <- i = xrgb 0 1 0| play s , 1 <- i = xrgb 0 1 1| play s , 2 <- i = xrgb 1 1 2| play s , 3 <- i = xrgb 2 1 3| play s , 4 <- i = xrgb 3 1 4| play s , 5 <- i = xrgb 4 2 5| play s , 6 <- i = xrgb 5 3 5| play s , 7 <- i = xrgb 5 4 5| 0 <- i = xgray 2| 1 <- i = xgray 5| 2 <- i = xgray 8| 3 <- i = xgray 11| 4 <- i = xgray 14| 5 <- i = xgray 17| 6 <- i = xgray 23| 7 <- i = xgray 23| otherwise = xgray 0xrgb :: Int -> Int -> Int -> Vty.Colorxrgb r g b = Vty.rgbColor (r * 51) (g * 51) (b * 51)
h = get v nn = shift v mx L . shift v my I $ coordToIndex v (mod (x - div y size * size) (3*size) , mod y size)(mx,my) = indexToCoord v $ center sch | n == focus s = intToDigit $ fromEnum h| otherwise = " ·~+=≠co" !! fromEnum hcol = k (fromEnum h)
v = n * 10 + 8
k :: Int -> Vty.Colork i| play s , 0 <- i = xrgb 0 1 0| play s , 1 <- i = xrgb 0 1 1| play s , 2 <- i = xrgb 1 1 2| play s , 3 <- i = xrgb 2 1 3| play s , 4 <- i = xrgb 3 1 4| play s , 5 <- i = xrgb 4 2 5| play s , 6 <- i = xrgb 5 3 5| play s , 7 <- i = xrgb 5 4 5| 0 <- i = xgray 2| 1 <- i = xgray 5| 2 <- i = xgray 8| 3 <- i = xgray 11| 4 <- i = xgray 14| 5 <- i = xgray 17| 6 <- i = xgray 23| 7 <- i = xgray 23| otherwise = xgray 0
ui :: Brick.Widget ()ui = defaultStyle $ Brick.vBox $ Brick.str "cells demo" : (Brick.raw . select <$> total)where
-- xterm 6-level RGB cube (colors 16–231)xrgb :: Int -> Int -> Int -> Vty.Colorxrgb r g b = Vty.Color240 $ fromIntegral (36*r + 6*g + b)
select :: Algo -> Vty.Imageselect x = Vty.horizCat[ Vty.string (coloured x Vty.yellow) (show $ fromEnum x), Vty.string Vty.defAttr " ", Vty.string (coloured x Vty.cyan) (toLower <$> show x)]
-- xterm 24-level greyscale ramp (colors 232–255)xgray :: Int -> Vty.Colorxgray n = Vty.Color240 $ fromIntegral (216 + n)
coloured :: Algo -> Vty.Color -> Vty.Attrcoloured x c| algo s == x = Vty.withForeColor Vty.defAttr c| otherwise = Vty.withForeColor Vty.defAttr Vty.brightBlack