Sunflower fractal: Difference between revisions

From Rosetta Code
Content added Content deleted
(Created page with "Draw [https://1drv.ms/u/s!AqDUIunCqVnIg1U89bApXAzPU9XH Sunflower fractal] <br> =={{header|Ring}}== {{draft task}} <lang ring> # Project : Sunflower fractal # Date : 2018/07...")
 
Line 1: Line 1:
Draw [https://1drv.ms/u/s!AqDUIunCqVnIg1U89bApXAzPU9XH Sunflower fractal]
Draw [https://1drv.ms/u/s!AqDUIunCqVnIg1U89bApXAzPU9XH Sunflower fractal]
<br>
<br>
=={{header|Microsoft Small Basic}}==
{{trans|Ring}}
<lang smallbasic>' Sunflower fractal - 24/07/2018
GraphicsWindow.Width=410
GraphicsWindow.Height=400
c=(Math.SquareRoot(5)+1)/2
numberofseeds=3000
For i=0 To numberofseeds
r=Math.Power(i,c)/numberofseeds
angle=2*Math.Pi*c*i
x=r*Math.Sin(angle)+200
y=r*Math.Cos(angle)+200
GraphicsWindow.DrawEllipse(x, y, i/numberofseeds*10, i/numberofseeds*10)
EndFor </lang>
{{out}}
[https://qzi5pw.am.files.1drv.com/y4mKFimj9qH4oJ9rq2z_WXCRXcFQUkLdLHMVLUkg8_4aybAgAPVNrWPtkdlZkIPuvgeIgKXIq4qC3kHpe0BPAdLB2f6mX0EPfGkRYS9yvA3Qc__CQ-DgR1-CgNMHoFDDJcwQZsj0sXNv0a2tKrPiNwO7eDItq-pzCO0A8jSBxaiaCDps_fycuVv6h6wiVQMK98TJELXi-nIEMfwFsBZCT6TWg?width=412&height=432&cropmode=none Sunflower fractal]

=={{header|Ring}}==
=={{header|Ring}}==
{{draft task}}
{{draft task}}

Revision as of 12:13, 24 July 2018

Draw Sunflower fractal

Microsoft Small Basic

Translation of: Ring

<lang smallbasic>' Sunflower fractal - 24/07/2018

 GraphicsWindow.Width=410
 GraphicsWindow.Height=400
 c=(Math.SquareRoot(5)+1)/2
 numberofseeds=3000
 For i=0 To numberofseeds
   r=Math.Power(i,c)/numberofseeds
   angle=2*Math.Pi*c*i
   x=r*Math.Sin(angle)+200
   y=r*Math.Cos(angle)+200
   GraphicsWindow.DrawEllipse(x, y, i/numberofseeds*10, i/numberofseeds*10)
 EndFor </lang>
Output:

Sunflower fractal

Ring

Sunflower fractal 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.

<lang ring>

  1. Project : Sunflower fractal
  2. Date  : 2018/07/24
  3. Author : Gal Zsolt (~ CalmoSoft ~)
  4. Email  : calmosoft@gmail.com

load "guilib.ring"

paint = null

new qapp

       {
       win1 = new qwidget() {
                 setwindowtitle("Sunflower fractal")
                 setgeometry(100,100,320,500)
                 label1 = new qlabel(win1) {
                             setgeometry(10,10,400,400)
                             settext("")
                 }
                 new qpushbutton(win1) {
                         setgeometry(100,400,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)
       }
       paint = new qpainter() {
                 begin(p1)
                 setpen(pen)
       c = (sqrt(5) + 1) / 2
       numberofseeds = 3000
       for i = 0 to numberofseeds
             r = pow(i, c ) / (numberofseeds)
             angle = 2 * 3.14 * c * i
             x = r * sin(angle) + 100
             y = r * cos(angle) + 100
            drawellipse(x, y, i / (numberofseeds / 10), i / (numberofseeds / 10))
       next
       endpaint()
       }
       label1 { setpicture(p1) show() }

</lang> Output:

Sunflower fractal