Archimedean spiral

35 views
Skip to first unread message

CalmoSoft

unread,
Jul 31, 2017, 12:00:49 PM7/31/17
to ring...@googlegroups.com
Hello Bert, Mahmoud et All,

Here is the CalmoSoft Archimedean Spiral program.
The task is at the Rosetta Code:


Code:

load "guilib.ring"

new qapp 
       {
       win1 = new qwidget() {
                  setwindowtitle("Archimedean spiral")
                  setgeometry(100,100,500,600)
                  label1 = new qlabel(win1) {
                               setgeometry(10,10,400,400)
                               settext("")
                  }
                  new qpushbutton(win1) {
                         setgeometry(150,500,100,30)
                         settext("draw")
                         setclickevent("draw()")
                  }
                  show()
        }
        exec()
        }

func draw
       p1 = new qpicture()
               color = new qcolor() {
               setrgb(0,0,255,255)
       }
       pen = new qpen() {
                 setcolor(color)
                 setwidth(1)
       }
       new qpainter() {
              begin(p1)
              setpen(pen)

       deg2rad = atan(1) * 4 / 180  
       screensize = 600                 
       turns = 5                
       halfscrn = screensize / 2    
       sf = (turns * (screensize - 100)) / halfscrn 
 
       for r = 0 to turns * 360 step 0.05
            x = cos(r * deg2rad) * r / sf 
            y = sin(r * deg2rad) * r / sf
            drawpoint(halfscrn + x, halfscrn - y)  
       next

       endpaint()
       }
       label1 { setpicture(p1) show() }





Greetings,
Gal Zsolt
(~ CalmoSoft ~)
CalmoSoftSpiral.ring

Bert Mariani

unread,
Aug 1, 2017, 3:58:58 PM8/1/17
to The Ring Programming Language
Hello Calmo

Interesting program that Spiral Code !

Here is a Spiral - Animated version.
Cycles thru 4 colors..


On Monday, July 31, 2017 at 12:00:49 PM UTC-4, CalmoSoft wrote:
Hello Bert, Mahmoud et All,

CalmoSoftSpiral-2.ring

CalmoSoft

unread,
Aug 2, 2017, 12:00:16 AM8/2/17
to The Ring Programming Language
Hello Bert,

Very nice sample!
Just a little reflection:
It is impossible to leave the program.
Please add the code to the GitHub.
Reply all
Reply to author
Forward
0 new messages