Line-filled circles and the Mandelbrot set

Post Reply
Henko
Posts: 793
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Line-filled circles and the Mandelbrot set

Post by Henko »

Someone pointed my attention to the following YouTube adres:

https://www.youtube.com/watch?v=qhbuKbxJsk8

Very interesting link. See the following snippet, whish displays 2000 patterns in quick succession.

Code: Select all

graphics ! refresh off
w=screen_width() ! h=screen_height()
R=floor(w-20)/2 ! xc=R+10 ! yc=xc ! pi2=8*atan(1)
for f=1 to 100 step .05
  rr=.5+.4*cos(f) ! g=.5+.4*cos(1.37*f) ! b=.5+.4*cos(.89*f)
  circle_modulo(xc,yc,R,200,f,rr,g,b)
  next f
'debug pause
end

def circle_modulo(xc,yc,R,mod,fac,cr,cg,cb)
draw color cr,cg,cb ! dt=.pi2/mod
graphics clear 1,1,1
for t=0 to .pi2 step dt
  draw circle xc+R*cos(t),yc+R*sin(t) size 2
  next t
for k=1 to mod 
  e=(fac*k)%mod
  tb=k*dt ! xk=xc+R*cos(tb) ! yk=yc+R*sin(tb)
  te=e*dt ! xe=xc+R*cos(te) ! ye=yc+R*sin(te)
  draw line xk,yk to xe,ye
  next k
draw circle xc,yc size R ! refresh
end def

User avatar
rbytes
Posts: 1336
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Line-filled circles and the Mandelbrot set

Post by rbytes »

That is hypnotic!
The only thing that gets me down is gravity...

User avatar
Mr. Kibernetik
Site Admin
Posts: 4596
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPad, iPhone, MacBook
Location: Russia
Flag: Russia

Re: Line-filled circles and the Mandelbrot set

Post by Mr. Kibernetik »

Very inspiring! Thank you, Henko.
The SPL version of what is shown at the video - animated OIDs: viewtopic.php?f=75&t=2117#p12756
.

User avatar
rbytes
Posts: 1336
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Line-filled circles and the Mandelbrot set

Post by rbytes »

The SPL version runs a lot faster and the colours are brighter.
I noticed that the Smart Basic version drew tiny circles at the nodes around the circumference. I added a line to draw them to see if they would have an effect on speed, but it isn't noticeable.
The only thing that gets me down is gravity...

User avatar
Mr. Kibernetik
Site Admin
Posts: 4596
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPad, iPhone, MacBook
Location: Russia
Flag: Russia

Re: Line-filled circles and the Mandelbrot set

Post by Mr. Kibernetik »

rbytes wrote:
Sun Jan 14, 2018 1:33 am
The SPL version runs a lot faster and the colours are brighter.
I noticed that the Smart Basic version drew tiny circles at the nodes around the circumference. I added a line to draw them to see if they would have an effect on speed, but it isn't noticeable.
SPL program has a #.delay function which makes program to run at 25 fps. Without delay it runs too fast to see anything :)

User avatar
rbytes
Posts: 1336
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Line-filled circles and the Mandelbrot set

Post by rbytes »

Here is the code modified to produce colors similar to the SPL version. I condensed Dutchman's palet function to the minimum size I could, but it still requires many lines to duplicate the single SPL command that converts hsv values to rgb. I have highlighted the function in green in the editor. Using it slows the drawing slightly.

Code: Select all

set toolbar off ! graphics ! graphics clear 0,0,0 ! refresh off
w=screen_width() ! h=screen_height()
o=floor(h-20)/2 ! yc=o+10 ! xc=o+150 ! pi2=8*atan(1)
for f=1 to 100 step .05
  rr=.6+.4*cos(f) ! g=.6+.4*cos(1.37*f) ! b=.6+.4*cos(.89*f)
  circle_modulo(xc,yc,o,200,f)
  next f
end

def circle_modulo(xc,yc,o,mod,fac)
dt=.pi2/mod
graphics clear 0,0,0
for t=0 to .pi2 step dt
  pal(t/.pi2,1,1,1)
  draw color pal.r,pal.g,pal.b
  draw circle xc+o*cos(t),yc+o*sin(t) size 2
  next t
for k=1 to mod
  e=(fac*k)%mod
  tb=k*dt ! xk=xc+o*cos(tb) ! yk=yc+o*sin(tb)
  te=e*dt ! xe=xc+o*cos(te) ! ye=yc+o*sin(te)
  pal(k/mod,1,1,1)
  draw color pal.r,pal.g,pal.b
  draw line xk,yk to xe,ye
  get touch 0 as x,y
  if x <> -1 then end
  next k
draw circle xc,yc size R ! refresh
end def

' condensed version of Dutchman's Palet function
'g'!def pal(tnt,sat,brt,iny)!tnt%=1
sat=abs(sat)!if sat>1 then sat%=1
iny=abs(iny)!if iny>1 then iny%=1
brt=abs(brt)!if brt>1 then brt%=1
tnt*=6!sect=int(0.5+tnt)!tnt%=1
on sect goto s1,s2,s3,s4,s5,s6
s1:b=1!r=0!g=tnt!goto satr
s2:g=1!r=0!b=1-tnt!goto satr
s3:g=1!b=0!r=tnt!goto satr
s4:r=1!b=0!g=1-tnt!goto satr
s5:r=1!g=0!b=tnt!goto satr
s6:b=1!g=0!r=1-tnt!satr:if sat<1 then
y=0.3*r+0.59*g+0.11*b!u=b-Y!u*=sat
v=r-Y!v*=sat!w=g-Y!w*=sat!r=y+v!g=y+w!b=y+u
if brt<>0 then!ysup=1-max(max(r,g),b)
ysup*=brt!r+=ysup!g+=ysup!b+=ysup!endif!endif
if iny<1 then!r*=iny!g*=iny!b*=iny!endif
y=0.3*r+0.59*g+0.11*b!enddef
Attachments
32F04991-D7B8-4110-B0AE-27E1032E75EF.png
32F04991-D7B8-4110-B0AE-27E1032E75EF.png (1.38 MiB) Viewed 1509 times
The only thing that gets me down is gravity...

Post Reply