( graphics DAY 05.04.2001 )

: line ( x1 y1 x2 y2 -- )
   WinDrawLine
;

: plot ( x y )
   2dup WinDrawLine
;

variable cx
variable cy
variable dd

: diag ( x y -- x1 y1 )
    1- swap 1+ swap
    2dup - 2* 2+ dd +!
;

: cplot ( x y )
   cy @ + swap cx @ + 
   swap 2dup WinDrawLine
;

: _circle ( rad )
   dup 1 < if drop cx @ cy @ 
              plot exit then
   0 swap dup
   1 swap - 2* dd ! \ x y d
   begin
   dd @
   if
     dd @ dup 0<
     if  
       2 pick - 2* 1- 0>
       if   diag
       else \ hor
         swap 1+ dup
         2* 1+ dd +!
         swap
       then
     else
       over + 2* 1- 0> 
       if   \ vert
         1- dup 2* negate 1+ dd +!
       else diag then
     then
   else diag 
   then
   2dup
   over negate over
   over negate over negate
   over negate over
   cplot cplot cplot cplot
   dup 0=
   until 2drop
;

: circle ( x y rad )
   >r cy ! cx !
   r> _circle
;

api: WinDrawRectangleFrame 

1     constant simpleFrame
0x401 constant roundFrame
0x702 constant boldRoundFrame
0x205 constant popupFrame
0x302 constant dialogFrame

: rect! ( x y w h rect )
    >r
    r@ 6 + w!
    r@ cell+ w!
    r@ 2+ w!
    r> w!
;

: frame ( x y w h type -- )
   >r rect1 rect!
      r> rect1 >abs 
      WinDrawRectangleFrame 
;

api: WinCreateOffscreenWindow 

: CreateOffScreen ( w h -- handle )
    0 rvarw 
    WinCreateOffscreenWindow
    wr> throw
;