Page 1 of 1

DrawChecker

Posted: Fri Feb 03, 2012 3:21 pm
by Guimauve
Hello everyone,

A tiny DrawChecker function.

Best regards
Guimauve

Code: Select all

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : DrawChecker
; File Name : DrawChecker.pb
; File version: 1.0.1
; Programmation : OK
; Programmed by : Guimauve
; Date : 29-01-2012
; Last Update : 03-02-2012
; PureBasic code : 4.60
; Plateform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Procedure DrawChecker(ImageID, Size.w, BoxCount.l, Color00.l, Color01.l) 
  
  If CreateImage(ImageID, Size, Size) 
    
    If StartDrawing(ImageOutput(ImageID)) 
      
      BoxSize.l = Size / BoxCount 
      
      For LineCount = 0 To BoxCount 
        
        For RowCount = 0 To BoxCount 
          
          If (LineCount + RowCount) & %1 = 1 
            Box(x, y, BoxSize, BoxSize, Color01) 
          Else 
            Box(x, y, BoxSize, BoxSize, Color00) 
          EndIf 
          
          x + BoxSize 
          
        Next 
        
        y + BoxSize 
        x = 0 
        
      Next 
      
      StopDrawing() 
      
    EndIf 
    
  EndIf 
  
EndProcedure 

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
; <<<<< !!! WARNING - YOU ARE NOW IN A TESTING ZONE - WARNING !!! <<<<< 
; <<<<< !!! WARNING - THIS CODE SHOULD BE COMMENTED - WARNING !!! <<<<< 
; <<<<< !!! WARNING - BEFORE THE FINAL COMPILATION. - WARNING !!! <<<<< 
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 

#Size = 512

If OpenWindow(0, 0, 0, #Size + 10, #Size + 10, "DrawChecker", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
  DrawChecker(0, #Size, 8, RGB(255,255,000), RGB(000,000,000))
  ImageGadget(0, 5, 5, #Size, #Size, ImageID(0))
  
  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
  
EndIf

; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<

Re: DrawChecker

Posted: Fri Feb 03, 2012 6:22 pm
by rsts
Nice :)

Thanks for sharing, especially for us drawing challenged types.

Re: DrawChecker

Posted: Fri Feb 03, 2012 9:59 pm
by Guimauve
Hello everyone,

A small correction. the previous code work only with even BoxCount. The new one work with even and odd BoxCount.

Best regards.
Guimauve