Vibrating rectangles

From Rosetta Code
Revision as of 04:09, 19 July 2018 by CalmoSoft (talk | contribs)
Vibrating rectangles is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Create Vibrating rectangles

This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified.

Ring

This example is incorrect. Please fix the code and remove this message.

Details: No task is given.

<lang ring>

This example is incorrect. It does not accomplish the given task. Please fix the code and remove this message.
  1. Project : Vibrating rectangles
  2. Date  : 2018/07/18
  3. Author : Gal Zsolt (~ CalmoSoft ~), Bert Mariani, Mahmoud Fayed
  4. Email  : <calmosoft@gmail.com>

Load "guilib.ring"

color1 = new qcolor() { setrgb( 255,0,0,255 ) } pen1 = new qpen() { setcolor(color1) setwidth(2) }

color2 = new qcolor() { setrgb( 0,255,0,255 ) } pen2 = new qpen() { setcolor(color2) setwidth(2) }

color3 = new qcolor() { setrgb( 0,0,255,255 ) } pen3 = new qpen() { setcolor(color3) setwidth(2) }

penArray = [pen1, pen2, pen3] penNbr = 1

New qapp {

  win1 =  new qwidget()
   {
             setwindowtitle("Drawing using QPixMap")
             setgeometry(100,100,500,500)
             label1 = new qlabel(win1)
             {
                          setgeometry(10,10,500,500)
                          settext("")
             }       
             Canvas = new qlabel(win1)
            {              
                           MonaLisa = new qPixMap2( 500,500)  
                           color = new qcolor(){ setrgb(255,0,0,255) }
                          daVinci = new qpainter() 
                          {
                                        begin(MonaLisa)               
                          }            
            setpixmap(MonaLisa)         
            }       

nCounter = 0 oTimer = new qTimer(win1) { setinterval(500) settimeoutevent("DrawCounter()") start() }

      show()      
   }
  exec()

} DrawCounter()

func DrawCounter()

       nCounter++
       if nCounter < 15
          Draw(penArray[penNbr])
       elseif nCounter % 15 = 0
           nCounter = 0
           penNbr++
           if penNbr > 3
              penNbr = 1
           ok       
           Draw(penArray[penNbr])
       ok

return

Func Draw(pen1)

        daVinci.setpen(penArray[penNbr])
        daVinci.drawrect(50+nCounter*10, 50+nCounter*10, 300-nCounter*20, 300-nCounter*20)
        Canvas.setpixmap(MonaLisa)      
        win1.show()                     

return</lang> Output:

Vibrating rectangles