FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

DRAWING

Make a panel animation


I'm trying to write an experiment in which I want people to pick a box with the mouse, then I want the box to appear to have a panel that slides up to reveal a prize (in the form of a pict resource) behind it (or not=black, means they picked the wrong one).

I have the placing of picts and the picking with the mouse and that stuff done fine. My problem is with the panel effect. I have tried drawing the pict, then a succesively smaller box, then a delay, then the pict again but it looks too choppy. Its close, but not believable since when the pict draws it flashes up for a bit on the panel area. What I really need is a way to have the pict draw in a line at a time perhaps. I don't have time for learning machine code, I'm too old, thats why I like FB.

My code attempt as it is...
  MyPict&=FN GETPICTURE (128)
  DIM rect.8
  CALL SETRECT(rect,0,0,145,145)

  COLOR=_zBlack
  FOR I=145 TO 0 STEP -5
    CALL DRAWPICTURE (MyPict&,rect)
    BOX FILL 0,0 TO 145,I
    DELAY 100
  NEXT I
Anyone have any ideas, sample code snips, places I should look?
Jon Tapp

My guess would be something like this :
LOCAL FN DrawPictPop(PictID)
DIM rect;0,t,l,b,r:'                               default rect to use
   t=143:l=0:r=145:b=145
   Hndl&=FN GETRESOURCE(_"PICT",PictID):'            get handle to pict
    LONG IF Hndl&:'                   did we get a handle for this PICT
     saveRgn&=FN NEWRGN:'                            build a new region
      LONG IF saveRgn&:'                  we need to check to make sure
       CALL GETCLIP(saveRgn&):'                save the original region
         FOR t=143 TO 0 STEP -2:'        draw the PICT higher each time
          CALL CLIPRECT(rect):'                 only update this region
          PICTURE(l,t),Hndl&:'            draw at specified coordinates
         NEXT t
       CALL SETCLIP(saveRgn&):'            restore the old region first
       CALL DISPOSERGN(saveRgn&):'   then get rid of the memory it used
      END IF
    CALL RELEASERESOURCE(Hndl&):'          free the memory PICT used
    END IF
END FN
Totally untested I might add but the logic is kinda there. The CLIPRGN is the area that the pict is allowed to draw into. Anything outside of that defined rect is not touched. This is usually simpler than fiddling with off screen gworlds.

If you wanted to specify the RECT if you have different areas, then you'd need to pass the rect coordinates to the function so then this routine would work anywhere in your window.
Mel Patrick

Here's some code I slapped together. Sorry it isn't elegant and isn't documented, but see if it does what you're looking for. There are some other things you should do with it, but this will give you some idea of the possibilities.
DIM gPictRect.8;0,gPrT,gPrL,gPrB,gPrR
DIM gclipRect.8;0,gCrT,gCrL,gCrB,gCrR

DIM gProgramEnds
DIM gPanelUp,gMoveTime&
DIM gMyPict&
DIM gIsOpen
END GLOBALS

LOCAL FN doEvents
  evnt = {EVENT}

  SELECT evnt
    CASE _nullEvt
      LONG IF gPanelUp
        LONG IF FN TICKCOUNT > gMoveTime&+2
          temp& = FN NEWRGN
          CALL GETCLIP(temp&)
          gCrT = 98+gPanelUp
          gCrB = 102 + gPanelUp
          myRgn& = FN NEWRGN
          CALL RECTRGN(myRgn&,gclipRect)
          CALL SETCLIP(myRgn&)
          CALL DRAWPICTURE(gMyPict&,gPictRect)
          CALL SETCLIP(temp&)
          CALL DISPOSERGN(myRgn&)
          CALL DISPOSERGN(temp&)
          DEC(gPanelUp)
          DEC(gPanelUp)
          gMoveTime& = FN TICKCOUNT
        END IF
      END IF
  END SELECT
END FN

LOCAL FN init
  CALL SETRECT(gPictRect,0,0,50,50)
  CALL SETRECT(gPictRect,200,100,250,150)
  gclipRect = gPictRect
  COLOR _zred
  pat = 128
  CALL PAINTRECT(gPictRect)
END FN

LOCAL FN makePicts
  CALL SETRECT(gPictRect,0,0,50,50)
  gMyPict& = FN OPENPICTURE(gPictRect)
  COLOR _zblue
  CALL PAINTRECT(gPictRect)
  PEN 7,2
  COLOR _zyellow
  CALL FRAMEOVAL(gPictRect)
  CALL CLOSEPICTURE

  CALL SETRECT(gPictRect,200,100,250,150)
  gclipRect = gPictRect
  COLOR _zred
  pat = 128
  CALL PAINTRECT(gPictRect)
END FN

LOCAL FN doMouse
  evnt = USR ABS(MOUSE(0))
  SELECT evnt
    CASE _click1
      LONG IF gIsOpen
        FN init
      XELSE
        gPanelUp = 48
        gMoveTime& = EVENT&
      END IF
      DEF TOGGLE(gIsOpen)
  END SELECT
END FN

LOCAL FN makeWindow
  WINDOW #1,"MouseDraw",,_doc
  PRINT: PRINT "Click to activate/reset.
  PRINT :PRINT "Press cmd-period to exit."
END FN

'----------------------- Main -------------------------------
FN makeWindow

FN makePicts

ON MOUSE FN doMouse
ON EVENT FN doEvents

DO
  HANDLEEVENTS
UNTIL gProgramEnds
Jay