FastDot
FastDot Xpos, Ypos, RgbColour
 
Parameters:

    Xpos = The X coordinate of the dot
    Ypos = The Y coordinate of the dot
    RgbColour = The Rgb Colour of this dot
Returns: NONE
 

     FastDot draws a single pixel to the current surface much like the DotC command. But, that's where the similarity ends. Unlike DotC however, FastDot has it's safety code removed to make it faster!

      This means two things, it can only draw to a surface that has already been locked by Lockbuffer and that it has no clipping. Therefore, it assumes the coordinate of the pixels you'll be drawing, will be inside the screen bounds.


      Note: Before you can use FastDot correctly. After you lock the draw surface, it's highly recommended you read a pixel from this surface using Point(). This will ensure the address of the surface is seeded for FASTDOT and FastPoint.


Any improper use of this command may cause your program to crash !




FACTS:


      * FastDot has no clipping. So the coordinate you give it must be legal, or you should expect your program to crash!

      * FastDot can only draw to locked surfaces. See LockBuffer + UnLockbuffer + DotC if you have have problem.

      * FastDot will render to the current surface. FastDot can NOT be captured by CaptureToScene, or CaptureToWorld.


 
Example Source: Download This Example
; *=-----------------------------------------------------------------=*
;  This Example compares the speed of filling the entire screen
; with dots using the DotC against the FastDot command.
;
; On my test machine FastDot is about twice as fast as Dotc
; *=-----------------------------------------------------------------=*
;
  
;  Open a Screen (windowed) that is 500x * 400y pixels in size
  OpenScreen 500,400,32,1
  
  
; Set the Maxtest Variable to 50. This will be the number times
; the following tests will be performed
  
  MaxTests=100
  
  
  
  
; -------------------------------------------------
; -------------------------------------------------
; TEST 1 - Fill the Screen using DOTC command
; -------------------------------------------------
; -------------------------------------------------
  
  
; start of a Repeat/Until Loop
  Repeat
     Cls 0
     
   ; Add 1 to the frames counter (used the calc the average fill time bellow)
     Inc Frames
     
     
   ; Move the current base colour into the current colour variable
     CurrentColour=BaseColour
     
   ; Add 1 to the base colour value
     BaseColour=BaseColour+RGB(1,2,3)
     
     
   ; get the timer() value at the,
     Start_of_Dot_Fill_Time=Timer()
     
   ; Fill the Screen Using DotC.
   ; Lock the buffer prior to the doing any pixel fill usiong DotC.
     LockBuffer
   ; Ylp will loop down the screen Y axis
     For Ylp=0 To GetScreenHeight()-1
        
      ; Xlp will loop across the screen X axis
        For Xlp=0 To GetScreenWidth()-1
         ; Draw a dot/pixel at this position
           DotC Xlp,ylp,CurrentColour
        Next
      ; At the end of each row, chaneg the current row colour
        CurrentColour=CurrentColour + RGB(3,2,1)
     Next
   ; Once your done drawing, unlock the buffer again.
     UnLockBuffer
   ; Calc the time in millisecond filling the screen took
     Time_Dot_takes=Timer()-Start_of_Dot_Fill_Time
     
   ; Calc the Total Time
     TotalTime#=TotalTime#+Time_DOT_Takes
     
   ; Calc the average
     Test1_Average#=TotalTime#/frames
     
   ; Display the average
     Print "TEST #1 - Filling Screen With DOTC command"
     Print "Average Fill Time:"+Str$(Test1_Average#)
     Print "Frame:"+Str$(frames)
     
   ; Show the Screen to the user
     Sync
     
   ; Repeat/ Until the Space Key is pressed
  Until Frames=MaxTests
  
  
  
  
  
  
; -------------------------------------------------
; -------------------------------------------------
; TEST 2 - Fill the Screen using FastDOT command
; -------------------------------------------------
; -------------------------------------------------
  
  Frames=0
  TotalTime#=0
  
; start of a Repeat/Until Loop
  Repeat
     
     Cls 0
     
   ; Add 1 to the frames counter (used the calc the average fill time bellow)
     Inc Frames
     
     
   ; Move the current base colour into the current colour variable
     CurrentColour=BaseColour
     
   ; Subtract the same colour fromt eh base colour (so the colours move backward)
     BaseColour=BaseColour-RGB(1,2,3)
     
     
   ; get the timer() value at the,
     Start_of_Dot_Fill_Time=Timer()
     
   ; Fill the Screen Using DotC.
   ; Lock the buffer prior to the doing any pixel fill usiong DotC.
     LockBuffer
   ; Ylp will loop down the screen Y axis
     For Ylp=0 To GetScreenHeight()-1
        
      ; Xlp will loop across the screen X axis
        For Xlp=0 To GetScreenWidth()-1
         ; Draw a dot/pixel at this position
           FastDot Xlp,ylp,CurrentColour
        Next
      ; At the end of each row, chaneg the current row colour
        CurrentColour=CurrentColour + RGB(3,2,1)
     Next
   ; Once your done drawing, unlock the buffer again.
     UnLockBuffer
   ; Calc the time in millisecond filling the screen took
     Time_Dot_takes=Timer()-Start_of_Dot_Fill_Time
     
   ; Calc the Total Time
     TotalTime#=TotalTime#+Time_DOT_Takes
     
   ; Calc the average
     Test2_Average#=TotalTime#/frames
     
   ; Display the average
     Print "TEST #2 - Filling Screen With FastDOT command"
     Print "Average Fill Time:"+Str$(Test2_Average#)
     Print "Frame:"+Str$(frames)
     
   ; Show the Screen to the user
     Sync
     
   ; Repeat/ Until the Space Key is pressed
  Until Frames=MaxTests
  
  
  
  
  Cls 0
  Print "Results"
  Print "Test1    (dotc) average fill time:"+Str$(Test1_average#)
  Print "Test2 (Fastdot) average fill time:"+Str$(Test2_average#)
  
  s$=Str$(Test1_average#/Test2_average#)
  Print "Fastdot is "+s$+" Faster than DotC"
  
  
  Sync
  WaitKey
  
  End
  
  
 
Related Info: Box | Circle | DotC | FastDot2 | FastDot3 | FastDot4 | FastPoint | GetInk | Ink | Line | LockBuffer | Point | Tri | UnLockBuffer :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com