Ticket #18 (closed defect: fixed)

Opened 6 years ago

Last modified 5 years ago

Odd behaviour with renderFill

Reported by: anonymous Owned by: coconnor
Priority: major Milestone:
Component: Uncategorized Version:
Keywords: renderFill Cc:

Description

I'm trying to draw a box on the screen. It should look like this:

+--------+
|XXXXXXXX|
|XXXXXXXX|
|XXXXXXXX|
|XXXXXXXX|
|XXXXXXXX|
|XXXXXXXX|
|XXXXXXXX|
|XXXXXXXX|
+--------+

Here is what I see instead:

+--------+
|XXXXXXXX|
|||||||XXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXX

+--------+

Here is the code to produce this:

module Main
    where

import Graphics.Vty

main :: IO ()
main = do
    vty <- mkVty
    (sx, sy) <- getSize vty
    play vty sx sy

play :: Vty -> Int -> Int -> IO ()
play vty sx sy = 
    let 
        testScreen = pic {
            pCursor = NoCursor
          , pImage = box 10 10 }
    in do
      update vty testScreen
      k <- getEvent vty
      case k of
        EvKey KEsc [] -> shutdown vty >> return ()
        EvResize nx ny -> play vty nx ny
        _ -> play vty sx sy

dumpA = setFG white $ setBG black $ attr

box :: Int -> Int -> Image
box w h =
    let
        corner = renderChar dumpA '+'
        vertLine = renderFill dumpA '|' 1 (h - 2)
        horizLine = corner <|> renderHFill dumpA '-' (w - 2) <|> corner
        centerArea = vertLine <|> renderFill dumpA 'X' (w - 2) (h - 2) <|> vertLine
    in 
        horizLine <-> centerArea <-> horizLine

I'm using GHC 6.10.2 and Vty 3.1.8.4

Attachments

Types.hs.diff (401 bytes) - added by mikesteele81@… 6 years ago.
Here's a patch that fixes the problem for me. I haven't done much testing other than to get the above code to do what I expected.

Change History

Changed 6 years ago by anonymous

  • keywords renderFill added

Changed 6 years ago by anonymous

  • summary changed from Odd behaviour with fillRegion to Odd behaviour with renderFill

Changed 6 years ago by mikesteele81@…

Here's a patch that fixes the problem for me. I haven't done much testing other than to get the above code to do what I expected.

Changed 6 years ago by coconnor

  • status changed from new to assigned

Resolved in darcs. Thanks!

Changed 5 years ago by coconnor

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.