From 93fd01e805d8c75e2ffe04f743a83d30b84e5a22 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Fri, 3 Jan 2020 12:12:15 +0100 Subject: [PATCH] get rid of draw prefixes --- src/Draw/Code.hs | 14 +- src/Draw/Component.hs | 43 ++--- src/Draw/Elements.hs | 189 ++++++++++--------- src/Draw/Generic.hs | 6 +- src/Draw/Grid.hs | 44 +++-- src/Draw/PuzzleGrids.hs | 91 +++++---- src/Draw/PuzzleTypes.hs | 409 +++++++++++++++++++++------------------- src/Draw/Render.hs | 12 +- 8 files changed, 420 insertions(+), 388 deletions(-) diff --git a/src/Draw/Code.hs b/src/Draw/Code.hs index 8a110dc..e7d4931 100644 --- a/src/Draw/Code.hs +++ b/src/Draw/Code.hs @@ -3,7 +3,7 @@ {-# LANGUAGE TypeFamilies #-} module Draw.Code - ( drawCode + ( code , arrowRight , arrowRightL , arrowDown @@ -27,10 +27,10 @@ import Diagrams.Prelude hiding ( place import qualified Data.Map.Strict as Map -drawCode :: Backend' b => Code -> [TaggedComponent (Drawing b)] -drawCode cs = concat [collect Atop, collect West, collect North] +code :: Backend' b => Code -> [TaggedComponent (Drawing b)] +code cs = concat [collect Atop, collect West, collect North] where - parts = map drawCodePart cs + parts = map codePart cs collect p = let matching = map snd . filter ((==) p . fst) $ parts in if null matching then [] else [comp p $ mconcat matching] @@ -38,8 +38,8 @@ drawCode cs = concat [collect Atop, collect West, collect North] comp p d = TaggedComponent (Just Code) $ PlacedComponent p $ RawComponent fakeSize $ d -drawCodePart :: Backend' b => CodePart -> (Placement, Drawing b) -drawCodePart cp = case cp of +codePart :: Backend' b => CodePart -> (Placement, Drawing b) +codePart cp = case cp of Rows' rs -> (West, placeGrid g # centerX') where g = Map.fromList [ (C 1 r, arrowRight) | r <- rs ] Cols cs -> (North, placeGrid g # centerY') @@ -50,7 +50,7 @@ drawCodePart cp = case cp of where g = Map.fromList [ (N c 0, arrowDown) | c <- cs ] LabelsN g -> (Atop, placeGrid . fmap label . clues $ g) where - label c = drawChar c # scale 0.5 # fc gray # translate (r2 (1 / 3, -1 / 3)) + label c = char c # scale 0.5 # fc gray # translate (r2 (1 / 3, -1 / 3)) LRows' rs -> (West, placeGrid g # centerX') where g = Map.fromList [ (C 0 r, arrowRightL [l]) | (l, r) <- Map.toList rs ] diff --git a/src/Draw/Component.hs b/src/Draw/Component.hs index fc34efd..259b806 100644 --- a/src/Draw/Component.hs +++ b/src/Draw/Component.hs @@ -6,6 +6,7 @@ import qualified Data.Map.Strict as Map import Diagrams.Prelude hiding ( dot , place + , star ) import Data.Component @@ -24,13 +25,13 @@ import Draw.Style import Draw.Elements import Draw.Code -drawComponents :: Backend' b => [PlacedComponent (Drawing b)] -> Drawing b -drawComponents cs = snd $ go $ reverse cs +components :: Backend' b => [PlacedComponent (Drawing b)] -> Drawing b +components cs = snd $ go $ reverse cs where go [] = ((0 :: Int, 0 :: Int), mempty) go ((PlacedComponent p c) : pcs) = let - (tl , dc ) = drawComponent c + (tl , dc ) = component c (tls, dcs) = go pcs ntl = (max (fst tl) (fst tls), max (snd tl) (snd tls)) in @@ -46,24 +47,24 @@ drawComponents cs = snd $ go $ reverse cs (=!=) = beside unitY (|!|) = beside (negated unitX) -drawComponent :: Backend' b => Component (Drawing b) -> (Size, Drawing b) -drawComponent c = case c of +component :: Backend' b => Component (Drawing b) -> (Size, Drawing b) +component c = case c of RawComponent sz x -> (sz, x) Grid s g -> (cellSize g, grid (gridStyle s) g) - Regions g -> (cellSize g, drawAreas g) - CellGrid g -> (cellSize g, placeGrid . fmap drawDecoration $ g) - NodeGrid g -> (nodeSize g, placeGrid . fmap drawDecoration $ g) + Regions g -> (cellSize g, areas g) + CellGrid g -> (cellSize g, placeGrid . fmap decoration $ g) + NodeGrid g -> (nodeSize g, placeGrid . fmap decoration $ g) EdgeGrid g -> - (edgeSize g, placeGrid' . Map.mapKeys midPoint . fmap drawDecoration $ g) + (edgeSize g, placeGrid' . Map.mapKeys midPoint . fmap decoration $ g) FullGrid ns cs es -> ( nodeSize ns , mconcat - . map (snd . drawComponent) + . map (snd . component) $ [NodeGrid ns, CellGrid cs, EdgeGrid es] ) - Note ds -> ((0, 0), note $ hcatSep 0.2 $ map drawDecoration $ ds) + Note ds -> ((0, 0), note $ hcatSep 0.2 $ map decoration $ ds) Pyramid g -> (shiftSize g, shiftGrid g) - CellPyramid g -> (shiftSize g, placeGrid . fmap drawDecoration $ g) + CellPyramid g -> (shiftSize g, placeGrid . fmap decoration $ g) where gridStyle s = case s of GridDefault -> gDefault @@ -73,20 +74,20 @@ drawComponent c = case c of GridPlain -> gPlain GridPlainDashed -> gPlainDashed -drawDecoration :: Backend' b => Decoration -> Drawing b -drawDecoration d = case d of +decoration :: Backend' b => Decoration -> Drawing b +decoration d = case d of Blank -> mempty - Letter c -> drawChar c + Letter c -> char c Letters s -> text' s InvertedLetters s -> invert $ text' s DecKropkiDot k -> kropkiDot k AfternoonSouth -> afternoonSouth AfternoonWest -> afternoonWest - LightDiagonal diag -> lc (blend 0.5 gray white) $ drawPrimeDiag diag - DarkDiagonal diag -> lc gray $ drawPrimeDiag diag + LightDiagonal diag -> lc (blend 0.5 gray white) $ primeDiag diag + DarkDiagonal diag -> lc gray $ primeDiag diag SmallDot -> dot Dot -> scale 0.5 $ smallPearl MBlack - Star -> drawStar Data.Elements.Star + Star -> star Data.Elements.Star Shade -> fillBG gray DarkShade -> fillBG (blend 0.5 gray black) Black -> fillBG black @@ -105,6 +106,6 @@ drawDecoration d = case d of Ship dir -> shipEnd dir LabeledArrow dir w -> labeledArrow dir $ text' w InvertedLabeledArrow dir w -> invert $ labeledArrow dir $ text' w - Tent -> draw tent - Tree -> drawTree Data.Elements.Tree - Myopia dirs -> drawMyopia dirs + Tent -> draw tentDia + Tree -> tree Data.Elements.Tree + Myopia dirs -> myopia dirs diff --git a/src/Draw/Elements.hs b/src/Draw/Elements.hs index 031985b..2d75d1c 100644 --- a/src/Draw/Elements.hs +++ b/src/Draw/Elements.hs @@ -13,6 +13,7 @@ module Draw.Elements where import Diagrams.Prelude hiding ( N , arrow , gap + , star ) import qualified Diagrams.Prelude as D import Diagrams.TwoD.Offset @@ -41,11 +42,11 @@ pearl m = draw $ circle 0.35 # lwG 0.05 # fc (c m) smallPearl :: Backend' b => MasyuPearl -> Drawing b smallPearl = scale 0.4 . pearl -drawEnd :: Backend' b => MEnd -> Drawing b -drawEnd MEnd = smallPearl MBlack +end :: Backend' b => MEnd -> Drawing b +end MEnd = smallPearl MBlack -drawBigEnd :: Backend' b => MEnd -> Drawing b -drawBigEnd MEnd = pearl MBlack +bigEnd :: Backend' b => MEnd -> Drawing b +bigEnd MEnd = pearl MBlack shipSquare :: Backend' b => Drawing b shipSquare = draw $ square 0.7 # lwG 0.05 # fc black @@ -69,17 +70,17 @@ dr :: Path V2 Double dr = fromVertices [p2 (1 / 2, -1 / 2), p2 (-1 / 2, 1 / 2)] -- | Both diagonals of a centered unit square. -cross :: Path V2 Double -cross = ur <> dr +crossPath :: Path V2 Double +crossPath = ur <> dr -- | Draw a cross. -drawCross :: Backend' b => Bool -> Drawing b -drawCross True = draw $ stroke cross # scale 0.8 # lwG edgewidth -drawCross False = mempty +cross :: Backend' b => Bool -> Drawing b +cross True = draw $ stroke crossPath # scale 0.8 # lwG edgewidth +cross False = mempty -- | Draw a Compass clue. -drawCompassClue :: Backend' b => CompassC -> Drawing b -drawCompassClue (CC n e s w) = texts <> (draw $ stroke cross # lwG onepix) +compassClue :: Backend' b => CompassC -> Drawing b +compassClue (CC n e s w) = texts <> (draw $ stroke crossPath # lwG onepix) where tx Nothing _ = mempty tx (Just x) v = text' (show x) # scale 0.5 # translate (r2 v) @@ -87,9 +88,9 @@ drawCompassClue (CC n e s w) = texts <> (draw $ stroke cross # lwG onepix) mconcat . zipWith tx [n, e, s, w] $ [(0, f), (f, 0), (0, -f), (-f, 0)] f = 3 / 10 -drawSlovakClue :: Backend' b => SlovakClue -> Drawing b -drawSlovakClue (SlovakClue s c) = - centerY' (drawInt s === draw (strutY 0.1) === dots c) <> fillBG gray +slovakClue :: Backend' b => SlovakClue -> Drawing b +slovakClue (SlovakClue s c) = + centerY' (int s === draw (strutY 0.1) === dots c) <> fillBG gray where dots n = draw $ centerX $ hcat' with { _sep = 0.04 } (replicate n $ d) d = circle 0.1 # lwG 0.02 # fc white @@ -106,8 +107,8 @@ thermo [] = error "invalid empty thermometer" -- | Draw a list of thermometers, given as lists of @(Int, Int)@ cell -- coordinates. -drawThermos :: Backend' b => [Thermometer] -> Drawing b -drawThermos = mconcat . map (thermo . map toPoint) +thermos :: Backend' b => [Thermometer] -> Drawing b +thermos = mconcat . map (thermo . map toPoint) arrowTip :: Path V2 Double arrowTip = @@ -126,14 +127,14 @@ arrow vs = if length vs < 2 then mempty else draw arr -- | Draw a list of arrows, given as lists of @(Int, Int)@ cell -- coordinates. -drawArrows :: Backend' b => [Thermometer] -> Drawing b -drawArrows = mconcat . map (arrow . map toPoint) +arrows :: Backend' b => [Thermometer] -> Drawing b +arrows = mconcat . map (arrow . map toPoint) -- | @drawTight d t@ draws the tight-fit value @t@, using @d@ to -- draw the components. -drawTight :: Backend' b => (a -> Drawing b) -> Tightfit a -> Drawing b -drawTight d (Single x) = d x -drawTight d (UR x y) = +tight :: Backend' b => (a -> Drawing b) -> Tightfit a -> Drawing b +tight d (Single x) = d x +tight d (UR x y) = stroke ur # lwG onepix # draw @@ -146,7 +147,7 @@ drawTight d (UR x y) = where t = 1 / 5 s = 2 / 3 -drawTight d (DR x y) = +tight d (DR x y) = stroke dr # lwG onepix # draw @@ -175,41 +176,41 @@ stackWordsRight = vcat' (with & catMethod .~ Distrib & sep .~ 1) . map (alignR' . text') -- | Mark a word in a grid of letters. -drawMarkedWord :: Backend' b => MarkedWord -> Drawing b -drawMarkedWord (MW s e) = draw $ lwG onepix . stroke $ expandTrail' +markedWord :: Backend' b => MarkedWord -> Drawing b +markedWord (MW s e) = draw $ lwG onepix . stroke $ expandTrail' with { _expandCap = LineCapRound } 0.4 t where t = fromVertices [p2i s, p2i e] # translate (r2 (1 / 2, 1 / 2)) -- | Apply 'drawMarkedWord' to a list of words. -drawMarkedWords :: Backend' b => [MarkedWord] -> Drawing b -drawMarkedWords = mconcat . map drawMarkedWord +markedWords :: Backend' b => [MarkedWord] -> Drawing b +markedWords = mconcat . map markedWord -- | Draw a slalom clue. -drawSlalomClue :: (Show a, Backend' b) => a -> Drawing b -drawSlalomClue x = +slalomClue :: (Show a, Backend' b) => a -> Drawing b +slalomClue x = text' (show x) # scale 0.75 <> (draw $ circle 0.4 # fc white # lwG onepix) -drawSlalomDiag :: Backend' b => SlalomDiag -> Drawing b -drawSlalomDiag d = draw $ stroke (v d) # lwG edgewidth +slalomDiag :: Backend' b => SlalomDiag -> Drawing b +slalomDiag d = draw $ stroke (v d) # lwG edgewidth where v SlalomForward = ur v SlalomBackward = dr -- | Draw an @Int@. -drawInt :: Backend' b => Int -> Drawing b -drawInt s = text' (show s) +int :: Backend' b => Int -> Drawing b +int s = text' (show s) -- | Draw a character. -drawChar :: Renderable (Path V2 Double) b => Char -> QDrawing b V2 Double Any -drawChar c = text' [c] +char :: Renderable (Path V2 Double) b => Char -> QDrawing b V2 Double Any +char c = text' [c] -drawCharFixed :: Backend' b => Char -> Drawing b -drawCharFixed c = textFixed [c] +charFixed :: Backend' b => Char -> Drawing b +charFixed c = textFixed [c] -drawCharOpaque :: Backend' b => Char -> Drawing b -drawCharOpaque c = drawChar c <> circle 0.5 # lwG 0 # fc white # draw +charOpaque :: Backend' b => Char -> Drawing b +charOpaque c = char c <> circle 0.5 # lwG 0 # fc white # draw placeTL :: Backend' b => Drawing b -> Drawing b placeTL = moveTo (p2 (-0.4, 0.4)) . scale 0.5 . alignTL' @@ -219,14 +220,14 @@ hintTL = placeTL . text' -- | Stack a list of words into a unit square. Scaled such that at least -- three words will fit. -drawWords :: Backend' b => [String] -> Drawing b -drawWords ws = +words :: Backend' b => [String] -> Drawing b +words ws = spread' (-1.0 *^ unitY) (map (centerXY' . scale 0.4 . text') ws) # centerY' -- | Fit a line drawing into a unit square. -- For example, a Curve Data clue. -drawCurve :: Backend' b => [Edge N] -> Drawing b -drawCurve = +curve :: Backend' b => [Edge N] -> Drawing b +curve = draw . lwG onepix . fit 0.6 . centerXY . mconcat . map (stroke . edge) -- | Draw a shadow in the style of Afternoon Skyscrapers. @@ -245,10 +246,10 @@ afternoonWest = reflectAbout (p2 (0, 0)) (direction $ r2 (1, 1)) afternoonSouth -- | Draws the digits of a tapa clue, ordered -- left to right, top to bottom. -drawTapaClue :: Backend' b => TapaClue -> Drawing b -drawTapaClue (TapaClue [x]) = drawInt x -drawTapaClue (TapaClue xs) = - fit' 0.8 . atPoints (p (length xs)) . map drawInt $ xs +tapaClue :: Backend' b => TapaClue -> Drawing b +tapaClue (TapaClue [x]) = int x +tapaClue (TapaClue xs) = + fit' 0.8 . atPoints (p (length xs)) . map int $ xs where p n = mconcat . pathVertices $ centerXY (p' n) p' 2 = p2 (-1 / 4, 1 / 4) ~~ p2 (1 / 4, -1 / 4) @@ -257,8 +258,8 @@ drawTapaClue (TapaClue xs) = p' 1 = error "singleton clues handled separately" p' _ = error "invalid tapa clue" -drawPrimeDiag :: Backend' b => PrimeDiag -> Drawing b -drawPrimeDiag (PrimeDiag d) = stroke p # lwG (3 * onepix) # draw +primeDiag :: Backend' b => PrimeDiag -> Drawing b +primeDiag (PrimeDiag d) = stroke p # lwG (3 * onepix) # draw where p = case d of (False, False) -> mempty @@ -266,27 +267,27 @@ drawPrimeDiag (PrimeDiag d) = stroke p # lwG (3 * onepix) # draw (False, True ) -> dr (True , True ) -> ur <> dr -drawAnglePoly :: Backend' b => Int -> Drawing b -drawAnglePoly 3 = draw $ strokePath (triangle 0.3) # fc black -drawAnglePoly 4 = draw $ strokePath (square 0.25) # fc gray -drawAnglePoly 5 = draw $ strokePath (pentagon 0.2) # fc white -drawAnglePoly _ = error "expected 3..5" +anglePoly :: Backend' b => Int -> Drawing b +anglePoly 3 = draw $ strokePath (triangle 0.3) # fc black +anglePoly 4 = draw $ strokePath (square 0.25) # fc gray +anglePoly 5 = draw $ strokePath (pentagon 0.2) # fc white +anglePoly _ = error "expected 3..5" -fish :: Double -> Angle Double -> Trail' Loop V2 Double -fish off startAngle = closeLine $ half <> half # reverseLine # reflectY +fishTrail :: Double -> Angle Double -> Trail' Loop V2 Double +fishTrail off startAngle = closeLine $ half <> half # reverseLine # reflectY where half = arc (angleDir startAngle) endAngle # translateY (-off) endAngle = ((180 @@ deg) ^-^ acosA off ^-^ startAngle) -drawFish :: Backend' b => Fish -> Drawing b -drawFish Fish = - draw $ fit 0.6 . centerXY . fc black . strokeLoop $ fish 0.7 (30 @@ deg) +fish :: Backend' b => Fish -> Drawing b +fish Fish = + draw $ fit 0.6 . centerXY . fc black . strokeLoop $ fishTrail 0.7 (30 @@ deg) -drawStar :: Backend' b => Star -> Drawing b -drawStar Star = draw $ fc black . stroke . star (StarSkip 2) $ pentagon 0.3 +star :: Backend' b => Star -> Drawing b +star Star = draw $ fc black . stroke . D.star (StarSkip 2) $ pentagon 0.3 -drawTree :: Backend' b => Tree -> Drawing b -drawTree Tree = draw $ fit 0.5 $ centerXY $ scaleY 0.5 $ fc black $ mconcat +tree :: Backend' b => Tree -> Drawing b +tree Tree = draw $ fit 0.5 $ centerXY $ scaleY 0.5 $ fc black $ mconcat [ rect 0.1 0.6 # moveTo (p2 (0.5, 0.7)) , circle 0.1 # moveTo (p2 (0.4, 0.9)) , circle 0.2 # moveTo (p2 (0.6, 1.0)) @@ -296,8 +297,8 @@ drawTree Tree = draw $ fit 0.5 $ centerXY $ scaleY 0.5 $ fc black $ mconcat , circle 0.1 # moveTo (p2 (0.7, 1.4)) ] -drawTent :: Backend' b => PlacedTent -> Drawing b -drawTent (Tent d) = draw $ tent <> lwG linewidth (stroke conn) +tent :: Backend' b => PlacedTent -> Drawing b +tent (Tent d) = draw $ tentDia <> lwG linewidth (stroke conn) where conn :: Path V2 Double conn = p2 (0, 0) ~~ p2 @@ -308,8 +309,8 @@ drawTent (Tent d) = draw $ tent <> lwG linewidth (stroke conn) L -> (-1, 0) ) -tent :: Backend' b => Diagram b -tent = fit 0.7 $ centerXY $ lwG 0 $ mconcat +tentDia :: Backend' b => Diagram b +tentDia = fit 0.7 $ centerXY $ lwG 0 $ mconcat [ rect 10 (1 / 4) # fc black , shape [(-2, 0), (0, 4), (2, 0), (-2, 0)] # fc white , shape [(-4, 0), (0, 8), (4, 0), (-4, 0)] # fc black @@ -352,7 +353,7 @@ placeNoteBR (x, _) d = miniloop :: Backend' b => Drawing b miniloop = - (drawThinEdges (map unorient out) <> grid gSlither g) # centerXY' # scale 0.4 + (thinEdges (map unorient out) <> grid gSlither g) # centerXY' # scale 0.4 where g = sizeGrid (1, 1) (out, _) = edgesM g @@ -360,9 +361,9 @@ miniloop = dominoBG :: Colour Double dominoBG = blend 0.3 black white -drawDomino :: Backend' b => (Int, Int) -> Drawing b -drawDomino (x, y) = - (drawInt x # smash' ||| strutX 0.65 # draw ||| drawInt y # smash') +domino :: Backend' b => (Int, Int) -> Drawing b +domino (x, y) = + (int x # smash' ||| strutX 0.65 # draw ||| int y # smash') # centerXY' # scale 0.6 <> strokePath (rect 0.8 0.5) @@ -377,21 +378,21 @@ instance ToPoint DominoC where toPoint (DominoC (C x y)) = p2 ((1.0 * fromIntegral x), (0.7 * fromIntegral y)) -drawDominos :: Backend' b => DigitRange -> Drawing b -drawDominos = - centerXY' . placeGrid . Map.mapKeys DominoC . fmap drawDomino . dominoGrid +dominos :: Backend' b => DigitRange -> Drawing b +dominos = + centerXY' . placeGrid . Map.mapKeys DominoC . fmap domino . dominoGrid -drawPill :: Backend' b => Int -> Drawing b -drawPill x = - drawInt x +pill :: Backend' b => Int -> Drawing b +pill x = + int x # scale 0.6 <> strokePath (roundedRect 0.8 0.5 0.2) # lwG 0 # fc dominoBG # draw -drawPills :: Backend' b => DigitRange -> Drawing b -drawPills (DigitRange a b) = centerXY' . onGrid 1.0 0.7 drawPill $ placed +pills :: Backend' b => DigitRange -> Drawing b +pills (DigitRange a b) = centerXY' . onGrid 1.0 0.7 pill $ placed where n = b - a + 1 root = head [ x | x <- [n, n - 1 ..], x * x <= n ] @@ -405,20 +406,20 @@ polyominoGrid = placeGrid . fmap (scale 0.8) . fmap Just c -> (text' [c] # fc white # lc white) <> fillBG black ) -drawPentominos :: Backend' b => Drawing b -drawPentominos = centerXY' . scale 0.5 . polyominoGrid $ pentominoGrid +pentominos :: Backend' b => Drawing b +pentominos = centerXY' . scale 0.5 . polyominoGrid $ pentominoGrid -drawLITS :: Backend' b => Drawing b -drawLITS = centerXY' . scale 0.5 . polyominoGrid $ litsGrid +lITS :: Backend' b => Drawing b +lITS = centerXY' . scale 0.5 . polyominoGrid $ litsGrid -drawLITSO :: Backend' b => Drawing b -drawLITSO = centerXY' . scale 0.5 . polyominoGrid $ litsoGrid +lITSO :: Backend' b => Drawing b +lITSO = centerXY' . scale 0.5 . polyominoGrid $ litsoGrid -drawCrossing :: Backend' b => Crossing -> Drawing b -drawCrossing = const $ drawChar '+' +crossing :: Backend' b => Crossing -> Drawing b +crossing = const $ char '+' -drawBahnhofClue :: Backend' b => BahnhofClue -> Drawing b -drawBahnhofClue = either drawInt drawCrossing +bahnhofClue :: Backend' b => BahnhofClue -> Drawing b +bahnhofClue = either int crossing kropkiDot :: Backend' b => KropkiDot -> Drawing b kropkiDot KNone = mempty @@ -428,8 +429,8 @@ kropkiDot c = draw $ circle 0.1 # lwG 0.03 # fc (col c) # smash col KBlack = blend 0.98 black white col KNone = error "can't reach" -drawFraction :: Backend' b => Fraction -> Drawing b -drawFraction f = centerX' $ case f of +fraction :: Backend' b => Fraction -> Drawing b +fraction f = centerX' $ case f of FInt a -> text' a # scale 0.8 FFrac a b -> frac a b FComp a b c -> (text' a # scale 0.8) ||| draw (strutX (1 / 10)) ||| frac b c @@ -448,8 +449,8 @@ drawFraction f = centerX' $ case f of slash :: Path V2 Double slash = fromVertices [p2 (-1 / 3, -1 / 2), p2 (1 / 3, 1 / 2)] -drawMyopia :: Backend' b => Myopia -> Drawing b -drawMyopia = foldMap d' +myopia :: Backend' b => Myopia -> Drawing b +myopia = foldMap d' where d' = draw . lwG onepix . scale (1 / 3) . d d U = a (0, 0) (0, 1) @@ -471,9 +472,9 @@ greaterClue (_ : rs) = g rs drawRel REqual = text' "=" placeholder = draw $ circle 0.35 # lwG onepix # dashingG [0.05, 0.05] 0 -drawCages +cages :: (Backend' b, Eq a, Ord a) => Grid C a -> Map.Map a (Drawing b) -> Drawing b -drawCages g m = hints <> (mconcat . map cage . Map.elems) byChar +cages g m = hints <> (mconcat . map cage . Map.elems) byChar where hints = placeGrid diff --git a/src/Draw/Generic.hs b/src/Draw/Generic.hs index 0166d07..52cfeb6 100644 --- a/src/Draw/Generic.hs +++ b/src/Draw/Generic.hs @@ -1,5 +1,5 @@ module Draw.Generic - ( drawGeneric + ( generic ) where @@ -13,8 +13,8 @@ import Data.GridShape import Data.PuzzleTypes import qualified Parse.PuzzleTypes as Parse -drawGeneric :: PuzzleType -> (Value, Maybe Value) -> Parser [TaggedComponent a] -drawGeneric t (p, ms) = case t of +generic :: PuzzleType -> (Value, Maybe Value) -> Parser [TaggedComponent a] +generic t (p, ms) = case t of Yajilin -> do g <- fst Parse.yajilin p msol <- traverse (snd Parse.yajilin) ms diff --git a/src/Draw/Grid.hs b/src/Draw/Grid.hs index 4bd5855..961c278 100644 --- a/src/Draw/Grid.hs +++ b/src/Draw/Grid.hs @@ -23,7 +23,15 @@ import qualified Data.AffineSpace as AS import Data.Util import Data.Grid -import Data.GridShape hiding ( edge ) +import qualified Data.GridShape as Data +import Data.GridShape ( C + , ShiftC + , N + , Edge' + , Coord + , Edge(..) + , Dir(..) + ) import Draw.Draw hiding ( border ) import Draw.Style @@ -132,11 +140,11 @@ cageDashing (CageParams on off w _) = -- -- `inner` consists of the individual inner segments. irregularGridPaths :: Grid C a -> (Path V2 Double, Path V2 Double) -irregularGridPaths m = (path' (map revEdge outer), path inner) +irregularGridPaths m = (path' (map Data.revEdge outer), path inner) where - (outer, inner) = edges (Map.keysSet m) (`Map.member` m) - path es = mconcat . map (conn . ends) $ es - path' es = case loops (map ends' es) of + (outer, inner) = Data.edges (Map.keysSet m) (`Map.member` m) + path es = mconcat . map (conn . Data.ends) $ es + path' es = case loops (map Data.ends' es) of Just ls -> mconcat . map (pathFromLoopVertices . map toPoint) $ ls Nothing -> mempty pathFromLoopVertices = @@ -150,9 +158,9 @@ offsetBorder off cs = pathFromLoopVertices = pathFromLocTrail . mapLoc (wrapLoop . closeLine) . fromVertices outer :: [Edge' N] - (outer, _) = edges cs (`elem` cs) + (outer, _) = Data.edges cs (`elem` cs) loop :: [N] - loop = case loops (map ends' outer) of + loop = case loops (map Data.ends' outer) of Just [l] -> tail l _ -> error "broken cage" corners :: [P2 Double] -> [(P2 Double, P2 Double, P2 Double)] @@ -198,7 +206,7 @@ midPoint -> P2 Double midPoint e = c .+^ 0.5 *^ (d .-. c) where - (a, b) = ends e + (a, b) = Data.ends e c = toPoint a d = toPoint b @@ -219,8 +227,8 @@ solEdgeStyle = solstyle :: (HasStyle a, InSpace V2 Double a) => a -> a solstyle = lc (blend 0.8 black white) . lwG (3 * onepix) -drawEdges :: (ToPoint k, Backend' b) => [Edge k] -> Drawing b -drawEdges es = +edges :: (ToPoint k, Backend' b) => [Edge k] -> Drawing b +edges es = Drawing (\cfg -> edgeStyle cfg . stroke . mconcat . map edge $ es) dirPath :: Dir -> Path V2 Double @@ -237,11 +245,11 @@ edgeDecorationThin dir = Drawing (\_ -> thinEdgeStyle . stroke . dirPath $ dir) edgeDecorationSol :: Backend' b => Dir -> Drawing b edgeDecorationSol dir = Drawing (\_ -> solEdgeStyle . stroke . dirPath $ dir) -drawThinEdges :: (ToPoint k, Backend' b) => [Edge k] -> Drawing b -drawThinEdges = draw . thinEdgeStyle . stroke . mconcat . map edge +thinEdges :: (ToPoint k, Backend' b) => [Edge k] -> Drawing b +thinEdges = draw . thinEdgeStyle . stroke . mconcat . map edge -drawAreas :: (Backend' b, Eq a) => Grid C a -> Drawing b -drawAreas = drawEdges . borders +areas :: (Backend' b, Eq a) => Grid C a -> Drawing b +areas = edges . borders cage :: Backend' b => [C] -> Drawing b cage cs = Drawing dcage @@ -257,14 +265,14 @@ fillBG c = draw $ square 1 # lwG onepix # fc c # lc c shadeGrid :: Backend' b => Grid C (Maybe (Colour Double)) -> Drawing b shadeGrid = placeGrid . fmap fillBG . clues -drawShade :: Backend' b => Grid C Bool -> Drawing b -drawShade = shadeGrid . fmap f +shade :: Backend' b => Grid C Bool -> Drawing b +shade = shadeGrid . fmap f where f True = Just gray f False = Nothing -drawAreasGray :: Backend' b => Grid C Char -> Drawing b -drawAreasGray = drawAreas <> shadeGrid . fmap cols +areasGray :: Backend' b => Grid C Char -> Drawing b +areasGray = areas <> shadeGrid . fmap cols where cols c | isUpper c = Just (blend 0.1 black white) | otherwise = Nothing diff --git a/src/Draw/PuzzleGrids.hs b/src/Draw/PuzzleGrids.hs index dbe97ae..0c1eae4 100644 --- a/src/Draw/PuzzleGrids.hs +++ b/src/Draw/PuzzleGrids.hs @@ -4,17 +4,17 @@ {-# LANGUAGE ConstraintKinds #-} module Draw.PuzzleGrids - ( drawIntGrid - , drawCharGrid + ( intGrid + , charGrid , outsideIntGrid - , drawSlitherGrid - , drawTightGrid + , slitherGrid + , tightGrid , sudokugrid - , drawWordsClues - , drawOutsideGrid - , drawMultiOutsideGrid - , drawOutsideGridN - , drawMultiOutsideGridN + , wordsClues + , outsideGrid + , multiOutsideGrid + , outsideGridN + , multiOutsideGridN , placeOutside , placeMultiOutside , placeMultiOutsideGW @@ -35,8 +35,17 @@ import Data.Maybe ( maybeToList ) import Data.Foldable ( fold ) -import Data.Grid -import Data.GridShape +import qualified Data.Grid as Data +import Data.Grid ( Grid + , OutsideClues + , clues + , size + ) +import Data.GridShape ( C + , N + , FromCoord(..) + , ToCoord(..) + ) import Data.Elements import Data.Sudoku @@ -48,25 +57,25 @@ import Draw.Grid import Draw.GridShape import Draw.Elements -drawCharGrid :: Backend' b => Grid C (Maybe Char) -> Drawing b -drawCharGrid = placeGrid . fmap drawChar . clues <> grid gDefault +charGrid :: Backend' b => Grid C (Maybe Char) -> Drawing b +charGrid = placeGrid . fmap char . clues <> grid gDefault -drawIntGrid :: Backend' b => Grid C (Maybe Int) -> Drawing b -drawIntGrid = placeGrid . fmap drawInt . clues <> grid gDefault +intGrid :: Backend' b => Grid C (Maybe Int) -> Drawing b +intGrid = placeGrid . fmap int . clues <> grid gDefault -drawSlitherGrid :: Backend' b => Grid C (Maybe Int) -> Drawing b -drawSlitherGrid = placeGrid . fmap drawInt . clues <> grid gSlither +slitherGrid :: Backend' b => Grid C (Maybe Int) -> Drawing b +slitherGrid = placeGrid . fmap int . clues <> grid gSlither sudokugrid :: Backend' b => Grid C a -> Drawing b -sudokugrid = drawEdges . sudokubordersg <> grid gDefault +sudokugrid = edges . sudokubordersg <> grid gDefault -drawWordsClues :: Backend' b => Grid C (Maybe [String]) -> Drawing b -drawWordsClues = placeGrid . fmap drawWords . clues +wordsClues :: Backend' b => Grid C (Maybe [String]) -> Drawing b +wordsClues = placeGrid . fmap Draw.Elements.words . clues -drawTightGrid +tightGrid :: Backend' b => (t -> Drawing b) -> Grid C (Tightfit t) -> Drawing b -drawTightGrid d g = - (placeGrid . fmap (drawTight d) $ g) <> grid gDefault g <> draw +tightGrid d g = + (placeGrid . fmap (tight d) $ g) <> grid gDefault g <> draw (phantom' (strokePath $ p2i (-1, -1) ~~ p2i (sx + 1, sy + 1))) where (sx, sy) = size (Map.mapKeys toCoord g) @@ -94,7 +103,7 @@ placeSideGrid placeSideGrid mrg off dir1 dir2 base cs = withConfig place_ where place_ cfg = - let minDiam = diameter dir1 (diagram cfg (drawChar 'M') :: D V2 Double) + let minDiam = diameter dir1 (diagram cfg (char 'M') :: D V2 Double) elDiam = max minDiam (maxDiam dir1 cfg (fold cs)) step = elDiam + mrg offset = off elDiam @@ -109,7 +118,7 @@ placeMultiOutside ocs = foldMap (\(cs, dir1, base, dir2) -> placeSideGrid mrg off (r2i dir1) (r2i dir2) (toPoint base) cs ) - (outsideClues ocs) + (Data.outsideClues ocs) where mrg = 1 / 3 off elDiam = 1 / 2 * elDiam - 1 / 2 * mrg @@ -122,7 +131,7 @@ placeMultiOutsideGW ocs = foldMap (\(cs, dir1, base, dir2) -> placeSideGrid 0 (const (1 / 4)) (r2i dir1) (r2i dir2) (toPoint base) cs ) - (outsideClues ocs) + (Data.outsideClues ocs) placeOutside :: (Backend' b, ToPoint k, FromCoord k, ToCoord k, Ord k) @@ -130,35 +139,35 @@ placeOutside -> Drawing b placeOutside = placeMultiOutside . fmap maybeToList -drawOutsideGrid :: Backend' b => OutsideClues C (Maybe String) -> Drawing b -drawOutsideGrid = +outsideGrid :: Backend' b => OutsideClues C (Maybe String) -> Drawing b +outsideGrid = placeOutside . fmap (fmap (scale outsideScale . text')) <> grid gDefault - . outsideGrid + . Data.outsideGrid -drawOutsideGridN :: Backend' b => OutsideClues N (Maybe String) -> Drawing b -drawOutsideGridN = +outsideGridN :: Backend' b => OutsideClues N (Maybe String) -> Drawing b +outsideGridN = placeOutside . fmap (fmap (scale outsideScale . text')) <> grid gDefault - . cellGrid - . outsideGrid + . Data.cellGrid + . Data.outsideGrid -drawMultiOutsideGrid :: Backend' b => OutsideClues C [String] -> Drawing b -drawMultiOutsideGrid = +multiOutsideGrid :: Backend' b => OutsideClues C [String] -> Drawing b +multiOutsideGrid = placeMultiOutside . fmap (fmap (scale outsideScale . text')) <> grid gDefault - . outsideGrid + . Data.outsideGrid -drawMultiOutsideGridN :: Backend' b => OutsideClues N [String] -> Drawing b -drawMultiOutsideGridN = +multiOutsideGridN :: Backend' b => OutsideClues N [String] -> Drawing b +multiOutsideGridN = placeMultiOutside . fmap (fmap (scale outsideScale . text')) <> grid gDefault - . cellGrid - . outsideGrid + . Data.cellGrid + . Data.outsideGrid outsideIntGrid :: Backend' b => OutsideClues C [Int] -> Drawing b -outsideIntGrid = drawMultiOutsideGrid . fmap (fmap show) +outsideIntGrid = multiOutsideGrid . fmap (fmap show) diff --git a/src/Draw/PuzzleTypes.hs b/src/Draw/PuzzleTypes.hs index e9dcd02..a75993b 100644 --- a/src/Draw/PuzzleTypes.hs +++ b/src/Draw/PuzzleTypes.hs @@ -86,6 +86,8 @@ import Diagrams.Prelude hiding ( Loop , N , coral , size + , star + , end ) import Data.Char ( isUpper ) @@ -100,12 +102,23 @@ import Draw.PuzzleGrids import Draw.Draw import Draw.Grid import qualified Draw.Pyramid as DPyr -import Draw.Elements +import Draw.Elements hiding ( dominos ) +import qualified Draw.Elements import Draw.Lib import Draw.Widths -import Data.Grid -import Data.GridShape +import qualified Data.Grid as Data +import Data.Grid ( Grid + , AreaGrid + , ShadedGrid + , OutsideClues(..) + , clues + ) +import Data.GridShape ( C(..) + , N + , Edge + , ToCoord(..) + ) import Data.Elements import qualified Data.Pyramid as Pyr @@ -113,18 +126,18 @@ unimplemented :: Backend' b => String -> (p, s) -> Drawing b unimplemented _ _ = mempty lits :: Backend' b => Drawers b AreaGrid ShadedGrid -lits = Drawers (grid gDefault <> drawAreasGray) - ((drawAreas <> grid gDefault) . fst <> drawShade . snd) +lits = Drawers (grid gDefault <> areasGray) + ((areas <> grid gDefault) . fst <> shade . snd) geradeweg :: Backend' b => Drawers b (Grid C (Maybe Int)) (Loop C) geradeweg = Drawers - drawIntGrid + intGrid ( placeGrid - . fmap drawInt + . fmap int . clues . fst <> solstyle - . drawEdges + . edges . snd <> grid gDefault . fst @@ -132,16 +145,16 @@ geradeweg = Drawers fillomino :: Backend' b => Drawers b (Grid C (Maybe Int)) (Grid C Int) fillomino = Drawers - (placeGrid . fmap drawInt . clues <> grid gDashed) - ((placeGrid . fmap drawInt <> drawEdges . borders <> grid gDashed) . snd) + (placeGrid . fmap int . clues <> grid gDashed) + ((placeGrid . fmap int <> edges . Data.borders <> grid gDashed) . snd) fillominoCheckered :: Backend' b => Drawers b (Grid C (Maybe Int)) (Grid C Int) fillominoCheckered = Drawers - (placeGrid . fmap drawInt . clues <> grid gDashed) + (placeGrid . fmap int . clues <> grid gDashed) ( ( placeGrid - . fmap drawInt - <> drawEdges - . borders + . fmap int + <> edges + . Data.borders <> grid gDashed <> shadeGrid . checker @@ -149,7 +162,7 @@ fillominoCheckered = Drawers . snd ) where - checker = fmap pickColour . colour + checker = fmap pickColour . Data.colour pickColour 1 = Nothing pickColour 2 = Just gray pickColour _ = Just red @@ -157,15 +170,15 @@ fillominoCheckered = Drawers fillominoLoop :: Backend' b => Drawers b (Grid C (Maybe Int)) (Grid C Int, Loop C) fillominoLoop = Drawers - (placeGrid . fmap drawInt . clues <> grid gDashed) + (placeGrid . fmap int . clues <> grid gDashed) ( ( placeGrid - . fmap drawInt + . fmap int . fst <> solstyle - . drawEdges + . edges . snd - <> drawEdges - . borders + <> edges + . Data.borders . fst <> grid gDashed . fst @@ -174,41 +187,41 @@ fillominoLoop = Drawers ) masyu :: Backend' b => Drawers b (Grid C (Maybe MasyuPearl)) (Loop C) -masyu = Drawers p (solstyle . drawEdges . snd <> p . fst) +masyu = Drawers p (solstyle . edges . snd <> p . fst) where p = placeGrid . fmap pearl . clues <> grid gDefault nurikabe :: Backend' b => Drawers b (Grid C (Maybe Int)) ShadedGrid -nurikabe = Drawers drawIntGrid (drawIntGrid . fst <> drawShade . snd) +nurikabe = Drawers intGrid (intGrid . fst <> shade . snd) latintapa :: Backend' b => Drawers b (Grid C (Maybe [String])) (Grid C (Maybe Char)) -latintapa = Drawers l (l . fst <> placeGrid . fmap drawChar . clues . snd) - where l = grid gDefault <> drawWordsClues +latintapa = Drawers l (l . fst <> placeGrid . fmap char . clues . snd) + where l = grid gDefault <> wordsClues sudoku :: Backend' b => Drawers b (Grid C (Maybe Int)) (Grid C (Maybe Int)) -sudoku = Drawers (placeGrid . fmap drawInt . clues <> sudokugrid) - ((placeGrid . fmap drawInt . clues <> sudokugrid) . snd) +sudoku = Drawers (placeGrid . fmap int . clues <> sudokugrid) + ((placeGrid . fmap int . clues <> sudokugrid) . snd) thermosudoku :: Backend' b => Drawers b (Grid C (Maybe Int), [Thermometer]) (Grid C (Maybe Int)) thermosudoku = Drawers ( placeGrid - . fmap drawInt + . fmap int . clues . fst <> sudokugrid . fst - <> drawThermos + <> thermos . snd ) ( placeGrid - . fmap drawInt + . fmap int . clues . snd <> sudokugrid . snd - <> drawThermos + <> thermos . snd . fst ) @@ -216,13 +229,13 @@ thermosudoku = Drawers killersudoku :: Backend' b => Drawers b (AreaGrid, Map.Map Char Int, Grid C (Maybe Int)) (Grid C Int) -killersudoku = Drawers (p <> placeGrid . fmap drawInt . clues . trd3) - (placeGrid . fmap drawInt . snd <> p . fst) +killersudoku = Drawers (p <> placeGrid . fmap int . clues . trd3) + (placeGrid . fmap int . snd <> p . fst) where fst3 (x, _, _) = x trd3 (_, _, z) = z - p = sudokugrid . fst3 <> cages - cages (g, m, _) = drawCages (Map.filter (/= '.') g) (Map.map drawInt m) + p = sudokugrid . fst3 <> cages' + cages' (g, m, _) = cages (Map.filter (/= '.') g) (Map.map int m) pyramid :: Backend' b => Drawers b Pyr.Pyramid Pyr.PyramidSol pyramid = Drawers DPyr.pyramid (DPyr.pyramid . merge) @@ -234,20 +247,20 @@ kpyramid = Drawers DPyr.kpyramid (DPyr.kpyramid . merge) slither :: Backend' b => Drawers b (Grid C (Maybe Int)) (Loop N) slither = - Drawers drawSlitherGrid (drawSlitherGrid . fst <> solstyle . drawEdges . snd) + Drawers slitherGrid (slitherGrid . fst <> solstyle . edges . snd) liarslither :: Backend' b => Drawers b (Grid C (Maybe Int)) (Loop N, Grid C Bool) liarslither = Drawers - drawSlitherGrid + slitherGrid ( placeGrid - . fmap (solstyle . drawCross) + . fmap (solstyle . cross) . snd . snd - <> drawSlitherGrid + <> slitherGrid . fst <> solstyle - . drawEdges + . edges . fst . snd ) @@ -260,21 +273,21 @@ tightfitskyscrapers (Grid C (Tightfit Int)) tightfitskyscrapers = Drawers ( placeOutside - . fmap (fmap drawInt) + . fmap (fmap int) . fst - <> drawTightGrid (const mempty) + <> tightGrid (const mempty) . snd ) - (placeOutside . fmap (fmap drawInt) . fst . fst <> drawTightGrid drawInt . snd + (placeOutside . fmap (fmap int) . fst . fst <> tightGrid int . snd ) wordgrid :: Backend' b => Grid C (Maybe Char) -> [String] -> Drawing b -wordgrid g ws = stackWords ws `besidesR'` drawCharGrid g +wordgrid g ws = stackWords ws `besidesR'` charGrid g wordloop :: Backend' b => Drawers b (Grid C (Maybe Char), [String]) (Grid C (Maybe Char)) -wordloop = Drawers (uncurry wordgrid) (drawCharGrid . snd) +wordloop = Drawers (uncurry wordgrid) (charGrid . snd) wordsearch :: Backend' b @@ -284,40 +297,40 @@ wordsearch (Grid C (Maybe Char), [MarkedWord]) wordsearch = Drawers (uncurry wordgrid) - (solstyle . drawMarkedWords . snd . snd <> drawCharGrid . fst . snd) + (solstyle . markedWords . snd . snd <> charGrid . fst . snd) curvedata :: Backend' b => Drawers b (Grid C (Maybe [Edge N])) [Edge C] curvedata = Drawers - (placeGrid . fmap drawCurve . clues <> grid gDefault) + (placeGrid . fmap curve . clues <> grid gDefault) ( placeGrid - . fmap drawCurve + . fmap curve . clues . fst <> solstyle - . drawEdges + . edges . snd <> grid gDefault . fst ) doubleback :: Backend' b => Drawers b AreaGrid (Loop C) -doubleback = Drawers p (solstyle . drawEdges . snd <> p . fst) - where p = grid gDefault <> drawAreasGray +doubleback = Drawers p (solstyle . edges . snd <> p . fst) + where p = grid gDefault <> areasGray slalom :: Backend' b => Drawers b (Grid N (Maybe Int)) (Grid C SlalomDiag) slalom = Drawers p - (p . fst <> placeGrid . fmap (solstyle . drawSlalomDiag) . snd) - where p = placeGrid . fmap drawSlalomClue . clues <> grid gDefault . cellGrid + (p . fst <> placeGrid . fmap (solstyle . slalomDiag) . snd) + where p = placeGrid . fmap slalomClue . clues <> grid gDefault . Data.cellGrid compass :: Backend' b => Drawers b (Grid C (Maybe CompassC)) AreaGrid compass = Drawers - (placeGrid . fmap drawCompassClue . clues <> grid gDashed) + (placeGrid . fmap compassClue . clues <> grid gDashed) ( placeGrid - . fmap drawCompassClue + . fmap compassClue . clues . fst - <> (grid gDashed <> drawAreasGray) + <> (grid gDashed <> areasGray) . snd ) @@ -326,18 +339,18 @@ meanderingnumbers meanderingnumbers = Drawers ( grid gDefault . fst - <> drawAreas + <> areas . fst <> placeGrid - . fmap drawInt + . fmap int . clues . snd ) - (drawIntGrid . snd <> drawAreas . fst . fst) + (intGrid . snd <> areas . fst . fst) tapa :: Backend' b => Drawers b (Grid C (Maybe TapaClue)) ShadedGrid -tapa = Drawers tapaGrid (tapaGrid . fst <> drawShade . snd) - where tapaGrid = placeGrid . fmap drawTapaClue . clues <> grid gDefault +tapa = Drawers tapaGrid (tapaGrid . fst <> shade . snd) + where tapaGrid = placeGrid . fmap tapaClue . clues <> grid gDefault japanesesums :: Backend' b @@ -348,42 +361,42 @@ japanesesums = Drawers (outsideIntGrid . fst <> n) n (ocs, ds) = placeNoteTL (0, h ocs) (text' ds # scale noteScale) japcells = placeGrid . fmap japcell japcell (Left Black) = fillBG gray - japcell (Right x ) = drawInt x - h = snd . outsideSize + japcell (Right x ) = int x + h = snd . Data.outsideSize coral :: Backend' b => Drawers b (OutsideClues C [String]) ShadedGrid coral = - Drawers drawMultiOutsideGrid (drawMultiOutsideGrid . fst <> drawShade . snd) + Drawers multiOutsideGrid (multiOutsideGrid . fst <> shade . snd) maximallengths :: Backend' b => Drawers b (OutsideClues C (Maybe Int)) (Loop C) -maximallengths = Drawers g (solstyle . drawEdges . snd <> g . fst) - where g = placeOutside . fmap (fmap drawInt) <> grid gDefault . outsideGrid +maximallengths = Drawers g (solstyle . edges . snd <> g . fst) + where g = placeOutside . fmap (fmap int) <> grid gDefault . Data.outsideGrid labyrinth :: Backend' b => Drawers b (Grid C (Maybe Int), [Edge N], String) (Grid C (Maybe Int)) -labyrinth = Drawers (placeGrid . fmap drawInt . clues . fst3 <> p <> n) - (placeGrid . fmap drawInt . clues . snd <> p . fst) +labyrinth = Drawers (placeGrid . fmap int . clues . fst3 <> p <> n) + (placeGrid . fmap int . clues . snd <> p . fst) where - p (g, e, _) = drawEdges e <> grid gPlain g + p (g, e, _) = edges e <> grid gPlain g n (g, _, ds) = placeNoteTR (size' g) (text' ds # scale noteScale) - size' = size . Map.mapKeys toCoord + size' = Data.size . Map.mapKeys toCoord fst3 (x, _, _) = x bahnhof :: Backend' b => Drawers b (Grid C (Maybe BahnhofClue)) [Edge C] bahnhof = Drawers - (placeGrid . fmap drawBahnhofClue . clues <> grid gDefault) + (placeGrid . fmap bahnhofClue . clues <> grid gDefault) ( placeGrid - . fmap drawBahnhofStation + . fmap bahnhofStation . clues . fst <> solstyle - . drawEdges + . edges . snd <> grid gDefault . fst ) - where drawBahnhofStation = either drawInt (const mempty) + where bahnhofStation = either int (const mempty) blackoutDominos :: Backend' b @@ -391,12 +404,12 @@ blackoutDominos blackoutDominos = Drawers p ( ( placeGrid - . fmap drawInt + . fmap int . clues . fst <> grid gDashedThick . fst - <> drawAreas + <> areas . snd <> shadeGrid . fmap cols @@ -405,8 +418,8 @@ blackoutDominos = Drawers . snd ) where - p (g, ds) = (placeGrid . fmap drawInt . clues <> grid gDashedThick $ g) - `aboveT'` drawDominos ds + p (g, ds) = (placeGrid . fmap int . clues <> grid gDashedThick $ g) + `aboveT'` Draw.Elements.dominos ds cols 'X' = Just gray cols _ = Nothing @@ -425,37 +438,37 @@ angleLoop = Drawers . fst ) where - cs = placeGrid . fmap drawAnglePoly . clues - gr = grid gPlainDashed . cellGrid + cs = placeGrid . fmap anglePoly . clues + gr = grid gPlainDashed . Data.cellGrid anglers :: Backend' b => Drawers b (OutsideClues C (Clue Int), Grid C (Maybe Fish)) [Edge C] -anglers = Drawers (p <> g) (p . fst <> solstyle . drawEdges . snd <> g . fst) +anglers = Drawers (p <> g) (p . fst <> solstyle . edges . snd <> g . fst) where p = placeOutside - . fmap (fmap drawInt') + . fmap (fmap int') . fst <> placeGrid - . fmap drawFish' + . fmap fish' . clues . snd g = grid gDefault . snd - drawInt' x = drawInt x <> draw (square 0.6 # lc white # fc white) - drawFish' x = drawFish x <> draw (square 0.6 # lc white # fc white) + int' x = int x <> draw (square 0.6 # lc white # fc white) + fish' x = fish x <> draw (square 0.6 # lc white # fc white) cave :: Backend' b => Drawers b (Grid C (Maybe Int)) ShadedGrid cave = Drawers - (grid gPlainDashed <> placeGrid . fmap drawInt . clues) - ( drawEdges - . edgesGen (/=) not + (grid gPlainDashed <> placeGrid . fmap int . clues) + ( edges + . Data.edgesGen (/=) not . snd <> placeGrid - . fmap drawInt + . fmap int . clues . fst - <> drawShade + <> shade . snd <> grid gStyle . fst @@ -469,36 +482,36 @@ skyscrapers => Drawers b (OutsideClues C (Maybe Int), String) (Grid C (Maybe Int)) skyscrapers = Drawers (g . fst <> n) - (g . fst . fst <> placeGrid . fmap drawInt . clues . snd) + (g . fst . fst <> placeGrid . fmap int . clues . snd) where - g = placeOutside . fmap (fmap drawInt) <> grid gDefault . outsideGrid - n (oc, s) = placeNoteTR (outsideSize oc) (text' s) + g = placeOutside . fmap (fmap int) <> grid gDefault . Data.outsideGrid + n (oc, s) = placeNoteTR (Data.outsideSize oc) (text' s) shikaku :: Backend' b => Drawers b (Grid C (Maybe Int)) AreaGrid -shikaku = Drawers p (drawAreas . snd <> p . fst) - where p = placeGrid . fmap drawInt . clues <> grid gDashed +shikaku = Drawers p (areas . snd <> p . fst) + where p = placeGrid . fmap int . clues <> grid gDashed slovaksums :: Backend' b => Drawers b (Grid C (Maybe SlovakClue), String) (Grid C (Maybe Int)) slovaksums = Drawers (p . fst <> n) - (placeGrid . fmap drawInt . clues . snd <> p . fst . fst) + (placeGrid . fmap int . clues . snd <> p . fst . fst) where n (g, ds) = placeNoteTR (size' g) (text' ds # scale noteScale) - p = grid gDefault <> placeGrid . fmap drawSlovakClue . clues - size' = size . Map.mapKeys toCoord + p = grid gDefault <> placeGrid . fmap slovakClue . clues + size' = Data.size . Map.mapKeys toCoord skyscrapersStars :: Backend' b => Drawers b (OutsideClues C (Maybe Int), Int) (Grid C (Either Int Star)) skyscrapersStars = Drawers (g <> n) - (g . fst <> placeGrid . fmap (either drawInt drawStar) . snd) + (g . fst <> placeGrid . fmap (either int star) . snd) where - g = (placeOutside . fmap (fmap drawInt) <> grid gDefault . outsideGrid) . fst + g = (placeOutside . fmap (fmap int) <> grid gDefault . Data.outsideGrid) . fst n (oc, s) = - placeNoteTR (outsideSize oc) (drawInt s ||| strutX' 0.2 ||| drawStar Star) + placeNoteTR (Data.outsideSize oc) (int s ||| strutX' 0.2 ||| star Star) summon :: Backend' b @@ -506,12 +519,12 @@ summon b (AreaGrid, OutsideClues C (Maybe Int), String) (Grid C (Maybe Int)) -summon = Drawers (p <> n) (placeGrid . fmap drawInt . clues . snd <> p . fst) +summon = Drawers (p <> n) (placeGrid . fmap int . clues . snd <> p . fst) where p (g, oc, _) = grid gDefault g - <> drawAreasGray g - <> (placeOutside . al . fmap (fmap (scale 0.7 . drawInt)) $ oc) + <> areasGray g + <> (placeOutside . al . fmap (fmap (scale 0.7 . int)) $ oc) al :: Backend' b => OutsideClues k (Maybe (Drawing b)) @@ -519,7 +532,7 @@ summon = Drawers (p <> n) (placeGrid . fmap drawInt . clues . snd <> p . fst) al (OC l r b t) = OC l (map (fmap alignL') r) b t n (g, _, ds) = placeNoteBR (size' g) (text' ds # scale 0.7) - size' = size . Map.mapKeys toCoord + size' = Data.size . Map.mapKeys toCoord baca :: Backend' b @@ -534,12 +547,12 @@ baca = Drawers (inside <> outside) (outside . fst <> placeGrid . fmap drawVal . snd <> inside . fst) where - inside (g, _, _) = placeGrid . fmap (fc gray . drawChar) . clues $ g + inside (g, _, _) = placeGrid . fmap (fc gray . char) . clues $ g outside (g, tl, br) = grid gDefault g - <> (placeMultiOutside . fmap (fmap drawInt) $ tl) - <> (placeOutside . fmap (fmap drawChar) $ br) - drawVal (Right c) = drawChar c + <> (placeMultiOutside . fmap (fmap int) $ tl) + <> (placeOutside . fmap (fmap char) $ br) + drawVal (Right c) = char c drawVal (Left _) = fillBG gray buchstabensalat @@ -547,23 +560,23 @@ buchstabensalat => Drawers b (OutsideClues C (Maybe Char), String) (Grid C (Maybe Char)) buchstabensalat = Drawers (p <> n) - (p . fst <> placeGrid . fmap drawChar . clues . snd) + (p . fst <> placeGrid . fmap char . clues . snd) where p = - (placeOutside . fmap (fmap drawChar) <> grid gDefault . outsideGrid) . fst - n (ocs, ls) = placeNoteTR (outsideSize ocs) (text' ls # scale noteScale) + (placeOutside . fmap (fmap char) <> grid gDefault . Data.outsideGrid) . fst + n (ocs, ls) = placeNoteTR (Data.outsideSize ocs) (text' ls # scale noteScale) doppelblock :: Backend' b => Drawers b (OutsideClues C (Maybe Int)) (Grid C (Either Black Int)) doppelblock = Drawers (p <> n) (p . fst <> placeGrid . fmap drawVal . snd) where - p = drawOutsideGrid . fmap (fmap show) + p = outsideGrid . fmap (fmap show) n ocs = placeNoteTL (0, h) (text' ds # scale noteScale) where - h = snd (outsideSize ocs) + h = snd (Data.outsideSize ocs) ds = "1-" ++ show (h - 2) - drawVal (Right c) = drawInt c + drawVal (Right c) = int c drawVal (Left _) = fillBG gray sudokuDoppelblock @@ -576,27 +589,27 @@ sudokuDoppelblock = Drawers p (p . fst <> placeGrid . fmap drawVal . snd) where p = placeOutside - . fmap (fmap (scale outsideScale . drawInt)) + . fmap (fmap (scale outsideScale . int)) . snd - <> (grid gDefault <> drawAreas) + <> (grid gDefault <> areas) . fst - drawVal (Right c) = drawInt c + drawVal (Right c) = int c drawVal (Left _) = fillBG gray dominos :: Backend' b => Drawers b (Grid C (Clue Int), DigitRange) AreaGrid dominos = Drawers p ( placeGrid - . fmap drawInt + . fmap int . clues . fst . fst - <> (grid gDashed <> drawAreasGray) + <> (grid gDashed <> areasGray) . snd ) where - p (g, r) = ((placeGrid . fmap drawInt . clues <> grid gDashed) $ g) - `aboveT'` drawDominos r + p (g, r) = ((placeGrid . fmap int . clues <> grid gDashed) $ g) + `aboveT'` Draw.Elements.dominos r dominoPills :: Backend' b @@ -604,73 +617,73 @@ dominoPills dominoPills = Drawers p ( placeGrid - . fmap drawInt + . fmap int . clues . fst3 . fst - <> (grid gDashed <> drawAreasGray) + <> (grid gDashed <> areasGray) . snd ) where fst3 (a, _, _) = a p (g, ds, ps) = - ((placeGrid . fmap drawInt . clues <> grid gDashed) $ g) - `aboveT'` (drawDominos ds ||| strutX' 0.5 ||| drawPills ps) + ((placeGrid . fmap int . clues <> grid gDashed) $ g) + `aboveT'` (Draw.Elements.dominos ds ||| strutX' 0.5 ||| pills ps) numberlink :: Backend' b => Drawers b (Grid C (Maybe Int)) [Edge C] numberlink = Drawers - drawIntGrid + intGrid ( placeGrid - . fmap drawInt' + . fmap int' . clues . fst <> solstyle - . drawEdges + . edges . snd <> grid gDefault . fst ) - where drawInt' x = drawInt x <> draw (square 0.7 # lc white # fc white) + where int' x = int x <> draw (square 0.7 # lc white # fc white) loopki :: Backend' b => Drawers b (Grid C (Maybe MasyuPearl)) (Loop N) -loopki = Drawers p (solstyle . drawEdges . snd <> p . fst) +loopki = Drawers p (solstyle . edges . snd <> p . fst) where p = placeGrid . fmap (scale 0.5 . pearl) . clues <> grid gSlither scrabble :: Backend' b => Drawers b (Grid C Bool, [String]) (Grid C (Maybe Char)) scrabble = Drawers p - (placeGrid . fmap drawCharFixed . clues . snd <> gr . fst . fst) + (placeGrid . fmap charFixed . clues . snd <> gr . fst . fst) where p (g, ws) = stackWords ws `besidesR'` gr g - gr = grid gDefault <> drawShade + gr = grid gDefault <> shade neighbors :: Backend' b => Drawers b (Grid C Bool, Grid C (Maybe Int)) (Grid C Int) neighbors = Drawers - (placeGrid . fmap drawInt . clues . snd <> (grid gDefault <> drawShade) . fst) - (placeGrid . fmap drawInt . snd <> (grid gDefault <> drawShade) . fst . fst) + (placeGrid . fmap int . clues . snd <> (grid gDefault <> shade) . fst) + (placeGrid . fmap int . snd <> (grid gDefault <> shade) . fst . fst) starbattle :: Backend' b => Drawers b (AreaGrid, Int) (Grid C (Maybe Star)) starbattle = Drawers (p <> n) - ((p <> n) . fst <> placeGrid . fmap drawStar . clues . snd) + ((p <> n) . fst <> placeGrid . fmap star . clues . snd) where - p = (drawAreas <> grid gDefault) . fst + p = (areas <> grid gDefault) . fst n (g, k) = - placeNoteTR (size' g) (drawInt k ||| strutX' 0.2 ||| drawStar Star) - size' = size . Map.mapKeys toCoord + placeNoteTR (size' g) (int k ||| strutX' 0.2 ||| star Star) + size' = Data.size . Map.mapKeys toCoord heyawake :: Backend' b => Drawers b (AreaGrid, Grid C (Maybe Int)) (Grid C Bool) -heyawake = Drawers (as <> cs) (as . fst <> drawShade . snd <> cs . fst) +heyawake = Drawers (as <> cs) (as . fst <> shade . snd <> cs . fst) where - as = (drawAreas <> grid gDefault) . fst - cs = placeGrid . fmap drawInt . clues . snd + as = (areas <> grid gDefault) . fst + cs = placeGrid . fmap int . clues . snd pentominous :: Backend' b => Drawers b (Grid C (Maybe Char)) (Grid C Char) pentominous = Drawers - (placeGrid . fmap drawChar . clues <> grid gDashed) - (placeGrid . fmap drawChar . clues . fst <> (drawAreas <> grid gDashed) . snd) + (placeGrid . fmap char . clues <> grid gDashed) + (placeGrid . fmap char . clues . fst <> (areas <> grid gDashed) . snd) colorakari :: Backend' b => Drawers b (Grid C (Maybe Char)) (Grid C (Maybe Char)) @@ -701,11 +714,11 @@ colorakari = Drawers persistenceOfMemory :: Backend' b => Drawers b (AreaGrid, (Grid C (Maybe MEnd))) (Loop C) persistenceOfMemory = Drawers - (ends_ <> areas) - (ends_ . fst <> solstyle . drawEdges . snd <> areas . fst) + (ends_ <> areas') + (ends_ . fst <> solstyle . edges . snd <> areas' . fst) where - ends_ = placeGrid . fmap drawEnd . clues . snd - areas = (drawAreas <> grid gDashed <> shadeGrid . fmap cols) . fst + ends_ = placeGrid . fmap end . clues . snd + areas' = (areas <> grid gDashed <> shadeGrid . fmap cols) . fst cols c | isUpper c = Just (blend 0.25 black white) | otherwise = Nothing @@ -747,33 +760,33 @@ abctje = Drawers h' = map (\(x, y) -> (show x, y : [])) kropki :: Backend' b => Drawers b (Map.Map (Edge N) KropkiDot) (Grid C Int) -kropki = Drawers (p <> n) (placeGrid . fmap drawInt . snd <> p . fst) +kropki = Drawers (p <> n) (placeGrid . fmap int . snd <> p . fst) where p = placeGrid' . Map.mapKeys midPoint . fmap kropkiDot <> grid gDefault - . sizeGrid + . Data.sizeGrid . sz n g = placeNoteTR (w, h) (text' ds # scale noteScale) where (w, h) = sz g ds = "1-" ++ show h - sz m = edgeSize m + sz m = Data.edgeSize m statuepark :: Backend' b => Drawers b (Grid C (Maybe MasyuPearl)) (Grid C Bool) -statuepark = Drawers p (p . fst <> drawShade . snd) +statuepark = Drawers p (p . fst <> shade . snd) where p = placeGrid . fmap pearl . clues <> grid gDashed pentominousBorders :: Backend' b => Drawers b (Grid C (), [Edge N]) (Grid C Char) -pentominousBorders = Drawers (drawEdges . snd <> grid gDashed . fst) - ((drawAreas <> grid gDashed) . snd) +pentominousBorders = Drawers (edges . snd <> grid gDashed . fst) + ((areas <> grid gDashed) . snd) smallHintRooms :: Backend' b => (AreaGrid, Grid C (Maybe Int)) -> Drawing b smallHintRooms = - ( (drawAreas <> grid gDashed) + ( (areas <> grid gDashed) . fst <> placeGrid . fmap hintTL @@ -786,19 +799,19 @@ nanroSignpost :: Backend' b => Drawers b (AreaGrid, Grid C (Maybe Int)) (Grid C Int) nanroSignpost = Drawers smallHintRooms - (placeGrid . fmap drawInt . snd <> smallHintRooms . fst) + (placeGrid . fmap int . snd <> smallHintRooms . fst) tomTom :: Backend' b => Drawers b (AreaGrid, Grid C (Maybe String)) (Grid C Int) -tomTom = Drawers p (placeGrid . fmap drawInt . snd <> p . fst) +tomTom = Drawers p (placeGrid . fmap int . snd <> p . fst) where p = - ((drawAreas <> grid gDashed) . fst <> placeGrid . fmap hintTL . clues . snd) + ((areas <> grid gDashed) . fst <> placeGrid . fmap hintTL . clues . snd) horseSnake :: Backend' b => Drawers b (Grid C (Maybe (Either MEnd Int))) [Edge C] -horseSnake = Drawers p (solstyle . drawEdges . snd <> p . fst) +horseSnake = Drawers p (solstyle . edges . snd <> p . fst) where - p = (placeGrid . fmap (either drawBigEnd drawInt) . clues <> grid gDashed) + p = (placeGrid . fmap (either bigEnd int) . clues <> grid gDashed) illumination :: Backend' b @@ -812,7 +825,7 @@ illumination = Drawers . fmap (const (smallPearl MWhite)) . clues . fst - <> drawEdges + <> edges . snd ) . snd @@ -820,16 +833,16 @@ illumination = Drawers . fst ) where - p = placeOutside . fmap (fmap drawFraction) <> grid gDashed . outsideGrid + p = placeOutside . fmap (fmap fraction) <> grid gDashed . Data.outsideGrid pentopia :: Backend' b => Drawers b (Grid C (Maybe Myopia)) (Grid C Bool) -pentopia = Drawers p (p . fst <> drawShade . snd) - where p = placeGrid . fmap drawMyopia . clues <> grid gDefault +pentopia = Drawers p (p . fst <> shade . snd) + where p = placeGrid . fmap myopia . clues <> grid gDefault greaterWall :: Backend' b => Drawers b ([GreaterClue], [GreaterClue]) (Grid C Bool) greaterWall = Drawers - ((placeMultiOutsideGW <> grid gDefault . outsideGrid) . munge) + ((placeMultiOutsideGW <> grid gDefault . Data.outsideGrid) . munge) undefined where munge (rs, cs) = OC @@ -844,7 +857,7 @@ galaxies b (Grid C (), Grid N (), Grid C (), Map.Map (Edge N) ()) AreaGrid -galaxies = Drawers p (p . fst <> drawAreas . snd) +galaxies = Drawers p (p . fst <> areas . snd) where p = (gals <> grid gDashed . fst4) gal = const (kropkiDot KWhite) @@ -862,7 +875,7 @@ mines = Drawers p = grid gDefault <> placeGrid - . fmap (\i -> drawInt i <> fillBG lightgray) + . fmap (\i -> int i <> fillBG lightgray) . clues tents @@ -871,14 +884,14 @@ tents b (OutsideClues C (Maybe Int), Grid C (Maybe Tree)) (Grid C (Maybe PlacedTent)) -tents = Drawers p (p . fst <> placeGrid . fmap drawTent . clues . snd) +tents = Drawers p (p . fst <> placeGrid . fmap tent . clues . snd) where p = placeOutside - . fmap (fmap drawInt) + . fmap (fmap int) . fst <> placeGrid - . fmap drawTree + . fmap tree . clues . snd <> grid gDashed @@ -896,27 +909,27 @@ pentominoSums pentominoSums = Drawers p (solgrid ||| const (strutX' 1.0) ||| table) where p (ocs, ds) = - ( ( (drawMultiOutsideGrid ocs <> n (ocs, ds)) + ( ( (multiOutsideGrid ocs <> n (ocs, ds)) ||| strutX' 1.0 ||| emptyTable ocs ) - `aboveT'` drawPentominos + `aboveT'` pentominos ) n (ocs, ds) = placeNoteTL (0, h ocs) (text' ds # scale noteScale) - h = snd . outsideSize + h = snd . Data.outsideSize emptyTable = mappingTable . emptys - emptys = map (\k -> (k, "")) . nub . sort . concat . outsideValues + emptys = map (\k -> (k, "")) . nub . sort . concat . Data.outsideValues solgrid = - skel . fst3 . snd <> drawMultiOutsideGrid . trd3 . snd <> cells . fst3 . snd + skel . fst3 . snd <> multiOutsideGrid . trd3 . snd <> cells . fst3 . snd fst3 (x, _, _) = x trd3 (_, _, z) = z - skel = skeletonStyle . drawEdges . skeletons . lefts + skel = skeletonStyle . edges . Data.skeletons . lefts skeletonStyle = lc white . lwG (3 * onepix) lefts = clues . fmap (either Just (const Nothing)) cells = placeGrid . fmap (\v -> case v of Left _ -> fillBG gray - Right x -> drawInt x + Right x -> int x ) table ((cs, _), (_, m, _)) = mappingTable m' where @@ -926,13 +939,13 @@ pentominoSums = Drawers p (solgrid ||| const (strutX' 1.0) ||| table) coralLits :: Backend' b => Drawers b (OutsideClues C [String]) (Grid C (Maybe Char)) coralLits = Drawers - (\ocs -> drawMultiOutsideGrid ocs `aboveT'` drawLITS) + (\ocs -> multiOutsideGrid ocs `aboveT'` lITS) ( skeletonStyle - . drawEdges - . skeletons + . edges + . Data.skeletons . clues . snd - <> drawMultiOutsideGrid + <> multiOutsideGrid . fst <> placeGrid . fmap (const (fillBG gray)) @@ -945,12 +958,12 @@ coralLitso :: Backend' b => Drawers b (OutsideClues C [String]) (Grid C (Either Black Char)) coralLitso = Drawers - (\ocs -> drawMultiOutsideGrid ocs `aboveT'` drawLITSO) - ( drawMultiOutsideGrid + (\ocs -> multiOutsideGrid ocs `aboveT'` lITSO) + ( multiOutsideGrid . fst <> skeletonStyle - . drawEdges - . skeletons + . edges + . Data.skeletons . rights . snd <> placeGrid @@ -971,29 +984,29 @@ snake (Grid C (Maybe (Either MEnd Black))) snake = Drawers p s where - cs = placeOutside . fmap (fmap drawInt) . fst - p = cs <> placeGrid . fmap drawBigEnd . clues . snd <> grid gDefault . snd + cs = placeOutside . fmap (fmap int) . fst + p = cs <> placeGrid . fmap bigEnd . clues . snd <> grid gDefault . snd s = cs . fst <> grid gDefault . snd <> placeGrid - . fmap (either (drawBigEnd <> gr) gr) + . fmap (either (bigEnd <> gr) gr) . clues . snd gr = const (fillBG gray) countryRoad :: Backend' b => Drawers b (AreaGrid, Grid C (Maybe Int)) (Loop C) countryRoad = - Drawers smallHintRooms (solstyle . drawEdges . snd <> smallHintRooms . fst) + Drawers smallHintRooms (solstyle . edges . snd <> smallHintRooms . fst) japsummasyu :: Backend' b => Drawers b (OutsideClues C [String]) () japsummasyu = Drawers ( placeMultiOutside . fmap (fmap (scale outsideScale . text')) <> grid gPlainDashed - . outsideGrid + . Data.outsideGrid ) (unimplemented "japsummasyu solution") @@ -1001,24 +1014,24 @@ arrowsudoku :: Backend' b => Drawers b (AreaGrid, Grid C (Maybe Int), [Thermometer]) (Grid C Int) arrowsudoku = Drawers - ( drawAreas + ( areas . fst3 <> placeGrid - . fmap drawInt + . fmap int . clues . snd3 - <> drawArrows + <> arrows . trd3 <> grid gDefault . fst3 ) - ( drawAreas + ( areas . fst3 . fst <> placeGrid - . fmap drawInt + . fmap int . snd - <> drawThermos + <> thermos . trd3 . fst <> grid gDefault @@ -1037,7 +1050,7 @@ dualloop = Drawers p (s . snd <> p . fst) where p = placeGrid - . fmap drawInt + . fmap int . clues . fst <> placeGrid @@ -1047,6 +1060,6 @@ dualloop = Drawers p (s . snd <> p . fst) <> grid gDashDash . fst smallClue x = - scale (2 / 3) (drawInt x <> circle 0.5 # fc white # lwG 0 # draw) + scale (2 / 3) (int x <> circle 0.5 # fc white # lwG 0 # draw) gDashDash = GridStyle LineDashed LineDashed Nothing VertexNone - s = solstyle . drawEdges . fst <> solstyle . drawEdges . snd + s = solstyle . edges . fst <> solstyle . edges . snd diff --git a/src/Draw/Render.hs b/src/Draw/Render.hs index 9c3c08a..4c12c30 100644 --- a/src/Draw/Render.hs +++ b/src/Draw/Render.hs @@ -24,8 +24,8 @@ import Parse.Component import Draw.Generic import Data.PuzzleTypes import Draw.CmdLine -import Draw.Code -import Draw.Component +import qualified Draw.Code as Draw +import qualified Draw.Component as Draw import Draw.Draw import Draw.Lib ( Backend' ) import Parse.Puzzle ( TypedPuzzle(..) ) @@ -86,11 +86,11 @@ decodeAndDraw params b = case backend fmt of codeComponents <- case (code, mc) of (True, Just c) -> mapLeft ("solution code parse failure: " ++) $ do parsedCode <- parseEither parseCode c - return $ drawCode parsedCode + return $ Draw.code parsedCode _ -> pure [] t' <- checkType (mrt `mplus` mt) if isGeneric t' - then parseEither (drawGeneric t') (p, ms) + then parseEither (generic t') (p, ms) else do (pzl, msol) <- parseEither (compose t') (p, ms) let @@ -140,6 +140,6 @@ render config components code oc = fmap (bg white) $ d oc DrawExample -> sideBySide <$> d DrawPuzzle <*> d DrawSolution fixup = alignPixel . border borderwidth sideBySide x y = x ||| strutX 2.0 ||| y - pzl = drawComponents $ extractPuzzle code components - msol = fmap drawComponents $ extractSolution code components + pzl = Draw.components $ extractPuzzle code components + msol = fmap Draw.components $ extractSolution code components