home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 November / CPNL0711.ISO / beeld / screen / hcf.exe / Basic / Basic_!LineExtend.bas < prev    next >
BASIC Source File  |  2004-01-31  |  2KB  |  82 lines

  1. w0 = Image(0).Width
  2. h0 = Image(0).Height
  3. w = 0
  4. h = 0
  5. if __LastPointStartX > w0 Then   ' is the mouse pointer outside of the image?
  6.    w = __LastPointStartX          ' then use the new size
  7. endif 
  8. if __LastPointEndX > w0 Then
  9.    w = __LastPointEndX 
  10. endif 
  11. if __LastPointStartY > h0 Then
  12.    h = __LastPointStartY 
  13. endif 
  14. if __LastPointEndY > h0 Then
  15.    h = __LastPointEndY 
  16. endif 
  17. if w > 0 or h > 0 then
  18.    if h = 0 then
  19.       h = h0
  20.    endif  
  21.    if w = 0 then
  22.       w = w0
  23.    endif  
  24.    v = CreateImage( w, h )                ' create a temp image with the new size
  25.    Image(v).Color = _ColorWhite         ' the "outside" color
  26.    Image(v).DrawImage( 0,0, w0,h0, 0 )  ' copy the old image to the temp image
  27.    Image(0).Resample( w,h )                ' resample the old image
  28.    Image(0).DrawImage( 0,0, w ,h , v )  ' copy the temp image to the old image
  29.    Image(v).Delete()                       ' delete the temp image
  30. endif
  31.  
  32. w0 = Image(0).Width
  33. h0 = Image(0).Height
  34. w  = 0
  35. h  = 0
  36. lx = 0
  37. ly = 0
  38. if __LastPointEndX < 0 Then
  39.    lx = __LastPointEndX * -1
  40.    w  = lx + w0
  41. endif 
  42. if __LastPointEndY < 0 Then
  43.    ly = __LastPointEndY * -1
  44.    h  = ly + h0
  45. endif 
  46. if w > 0 or h > 0 then
  47.    if h = 0 then
  48.       h = h0
  49.    endif  
  50.    if w = 0 then
  51.       w = w0
  52.    endif  
  53.    v = CreateImage( w, h )                ' create a temp image with the new size
  54.    Image(v).Color = _ColorWhite         ' the "outside" color
  55.    Image(v).DrawImage( lx,ly, w0,h0, 0 )' copy the old image to the temp image
  56.    Image(0).Resample( w,h )                ' resample the old image
  57.    Image(0).DrawImage( 0,0, w ,h , v )  ' copy the temp image to the old image
  58.    Image(v).Delete()                       ' delete the temp image
  59. endif
  60.  
  61.  
  62. Pen.GradientMode = _GradientModeForwardDiagonal
  63. Pen.Width  = __PenWidth
  64. Pen.StartCap = _LineCapArrowAnchor
  65.  
  66. if __LastMouseButton = _LeftMouseButton Then
  67.         Pen.StartColor   = __ForegroundColor
  68.         Pen.EndColor     = __ForegroundColor
  69. else    
  70.     if __LastMouseButton = _RightMouseButton Then
  71.         Pen.StartColor   = __BackgroundColor
  72.         Pen.EndColor     = __BackgroundColor
  73.     else    
  74.         Pen.StartColor   = __ForegroundColor
  75.         Pen.EndColor     = __ForegroundColor
  76.         Pen.StartTolerance = 128
  77.         Pen.EndTolerance   = 128
  78.     endif  
  79. endif
  80.  
  81. Image(0).Line( __LastPointStartX,__LastPointStartY,  __LastPointEndX+lx,__LastPointEndY+ly )
  82.