include "asm.inc"
window 512,512,1
float bx,by, int bw=512,bh=512,col
float sx=-2.2,sy=-1.7,sw=3.4,sh=3.4
float t,gx,gy,zx,zy,nzx,r,v,b
t = ticks
for x=0 to bw
for y=0 to bh
gx=x/bw*sw+sx
gy=y/bh*sh+sy
zx=gx
zy=gy
for c=0 to 255
col = c
nzx = zx*zx - zy*zy + gx
zy = 2*zx*zy+gy
zx = nzx
if zx*zx + zy*zy > 4 then
col = c
exit for
end if
next
r = col
v = col*32
b = col*64
color r,v,b
setpixel x,y
next
next
color 255,255,255
text 0,0,14, str((ticks()-t)/1000,4) + " secondes"
waitkey
winExit
Can you please compile your O2 code to an exe for me, Peter?but sure!
include "asm.inc"
window 1024,768,1 '0=fullscreen, be careful with windowsXP due to the desctop icons!
float r,i,x,y,z t
int c[32]
for i=0 to 32
c[i] = RGB(i*8,i*14,i*8)
next
Sub Invers()
d = x*x + y*y
if d=0 then
r=100000
x=r
i=r
y=r
else
r=r/d
x=r
i=i/d
y=i
end if
End Sub
Sub Inside(float d, fac, z, it)
i = Abs(Log(d))*fac
if z = it then
r = GetR(c[i])
g = GetG(c[i])
b = GetB(c[i])
color r,g,b
else
color 0,0,0
end if
End Sub
Sub Julia_Init(float xss,yss,lt,rt,bm,tp,it,bb,inv,ins,fac,dx,dy,ci,cr)
dxpp = (rt-lt)/xss
dypp = (tp-bm)/yss
r=bm
for xr=0 to xss
i = lt
for yr=0 to yss
x = r
y = i
b = x
m = y
if inv=1 then Invers()
xs = x*x
ys = y*y
while key(27)=0
y = x*y
Y = y+y-cr
x = xs-ys-ci
xs = x*x
ys = y*y
d = xs+ys
if d < bb and z < it
z +=1
else
exit while
end if
wend
if ins=0
r = GetR(c[z])
g = GetG(c[z])
b = GetB(c[z])
color r,g,b
else
Inside(d, fac, z, it)
end if
setpixel xr+dx, yr+dy
z=0
r=b
i=m
i += dypp
next
r += dxpp
redraw
next
End Sub
lt=-2 : rt=2
bm=-2 : tp=2
t = ticks
Julia_Init(1024,768,lt,rt,bm,tp,20,30.0,1,1,5,1,1,-0.32,-0.043)
wintext "TIME: " + (ticks()-t)/1000 + " SECONDS"
waitkey
WinExit
'vonoroi.bas for SmallBASIC 2015-10-14 MGA/B+
'modified bluatigro code from JB 2015-09-07 vonoroi diagram
include "asm.inc"
window 800,600,1
int sq=800,s2=sq/2,points=240
int x[240],y[240],kl[240]
single t = ticks
for i=0 to points
x[i] = rand(32,sq)
y[i] = rand(32,sq)
g=127-127*(abs(s2-x[i])/s2)+127-127*(abs(s2-y[i])/s2)
kl[i] = RGB(255-x[i]/sq*255,g,y[i]/sq*255)
next
for xx=0 to sq
for yy=0 to sq
d = 307201
for i=0 to points
a=x[i]-xx: b=y[i]-yy
q=a*a+b*b
if q<d then
d=q
kkl = i
end if
next
PutPixel xx, yy, kl[kkl]
next
next
WinText "TIME: " + (ticks()-t)/1000 + " SECONDS"
waitkey
winExit
'vonoroi.bas for SmallBASIC 2015-10-14 MGA/B+
'modified bluatigro code from JB 2015-09-07 vonoroi diagram
actually, his name is Voronoy!
include "sdl.inc"
window 800,600,1
int sq=800,s2=sq/2,points=240
int x[240],y[240],kl[240]
single t = ticks
for i=0 to points
x[i] = rand(32,sq)
y[i] = rand(32,sq)
g=127-127*(abs(s2-x[i])/s2)+127-127*(abs(s2-y[i])/s2)
kl[i] = RGBA(255-x[i]/sq*255,g,y[i]/sq*255,255)
next
for xx=0 to sq
for yy=0 to sq
d = 307201
for i=0 to points
a=x[i]-xx: b=y[i]-yy
q=a*a+b*b
if q<d then
d=q
kkl = i
end if
next
PutPixel xx, yy, kl[kkl]
next
next
SetCaption "TIME: " + (ticks()-t)/1000 + " SECONDS"
waitkey
winExit
SetDIBSection is a tad unfair, we don't have the same conditions. ;D
TIME: 0.516 SECONDS
I am English learner! ;D
How long does Peter's latest big_julia take on your PC?
include "asm.inc"
window 600,500,1
sys ma=16
single xs=-2.5,ys=-2,zml=1.25
Function cfunc(sys p,w) as sys
pP=(p*1792)/w
sys red,green,blue
if pP <256
red=0
green=0
blue=pP
else if pP <512
red=0
green=pP-256
blue=255
else if pP <768
red=0
green=255
blue =255-(pP-512)
else if pP <1024
red= pP-768
green=255
blue=0
else if pP <1280
red=255
green=255-(pP-1024)
blue=0
else if pP <1536
red=255
green=0
blue=pP-1280
else
red=255
green=pP-1536
blue=255
end if
Return RGB(red,green+4,blue)
End Function
Sub funcpix(sys ix,iy, single x,y,zm)
single xC=(xs)+(single(ix)+.5)/100/zm)
single yC=(ys)+(single(iy)-.5)/100/zm)
single x0=(xs)+(single(ix)+.5)/100/zm)
single y0=(ys)+(single(iy)-.5)/100/zm)
single x2=xc*xc
single y2=yc*yc
sys it
while (x2+y2) < (2*2) and it < ma
yc = 2*xc*yc + y0
xc = x2 - y2 + x0
x2 = xc*xc
y2 = yc*yc
it +=1
wend
if it=ma
PutPixel ix,iy,rgb(41,60,194)
else
PutPixel ix,iy,cfunc(it,ma)
end if
End Sub
t = ticks
For i=0 to 600
For j=0 to 500
funcpix(i,j,xs,ys,zml)
Next
Next
color 255,255,255
text 0,0,12,"TIME: " + (ticks()-t)/1000 + " SECONDS"
WaitKey
WinExit
include "asm.inc"
window 800,600,1
Loadimage "bmp/potato.bmp"
int cells=1000
single headx, heady
single px[3000]
single py[3000]
single radX[3000]
single radY[3000]
single angle[3000]
single cRadius[3000]
single frequency[3000]
headx = scrw()/2
heady = scrh()/2
for i=0 to cells
radx[i] = Rand(-7,7)
rady[i] = Rand(-4,4)
frequency[i] = Rand(-9,9)
cRadius[i] = Rand(16,30)
next
while key(27)=0
cls 0,0,0
for i=0 to cells
if i=0
px[i]=headx+sin(angle[i])*radx[i]
py[i]=heady+cos(angle[i])*rady[i]
else
px[i]=px[i-1]+cos(angle[i])*radx[i]
py[i]=py[i-1]+sin(angle[i])*rady[i]
endif
drawimage 1,px[i],py[i]
angle[i] = angle[i] + rad(frequency[i])
next
color 255,255,255
text 316,32,12,"MANDEL POTATO"
redraw
wait 10
wend
winexit
include "asm.inc"
window 800,600,1
single x,y,zx,zy,cx,cy,tmp, sys MaxIter=512,zoom=150
ts = ticks
For y=0 to <scrH
For x=0 to <scrW
zx=0
zy=0
cx= (x-400)/zoom
cy= (y-300)/zoom
Iter = MaxIter
while zx * zx + zy * zy < 4 && iter > 0
tmp = zx * zx - zy * zy + cX
zy = 2 * zx * zy + cY
zx = tmp
iter--
wend
PutPixel x,y,iter+iter*256+iter*65536/5
Next
Next
color 255,255,255
text 0,0,12,"TIME: " (ticks()-ts)/1000 " SECONDS"
waitkey
winExit
FBSL's one is re-sizable
include "asm.inc"
window 800,480,1
Sub filledcircle(x1, y1, r)
r=r/2
for y=-r to r
for x=-r to r
if x*x+y*y <= r*r
setpixel x1+x, y1+y
end if
next
next
End Sub
float ts = ticks
color 255,255,255
text 10,10,10,"PRESS ANY KEY"
for i=40 to 680 step 80
color 200,200,255-i*10
filledcircle i-200,240,i-240
next
color 255,255,255
float tz = ticks
text 0,460,12,"Time: " (tz-ts)/1000 " seconds"
waitkey
winExit