Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REM -----------------------------------------------
- REM Mandel and buddhabrot program
- REM Written by: Johan Roos Tibbelin
- REM (sjfroos)
- REM Date: 2020-08-13 Last changed:2020-08-16
- REM -----------------------------------------------
- REM
- REM
- REM mandelbrot render precalc.
- INLINE brot%,32000
- REM Number of iterations per pixel is saved here
- DIM pixels%(320,200)
- REM pixel part of set or not
- DIM brot!(320,200)
- SETCOLOR 0,0,0,0
- SETCOLOR 15,7,7,7
- REM mandelmenu(x1,y1,x2,y2)
- REM foo=INP(2)
- REM END
- mandelbrot(-2.5,-1.2,2.5,1.2)
- REM BMOVE XBIOS(2),brot%,32000
- REPEAT
- UNTIL MOUSEK=2
- SETCOLOR 0,7,7,7
- SETCOLOR 15,0,0,0
- END
- PROCEDURE mandelbrot(x1,y1,x2,y2)
- FOR py=0 TO 199
- FOR px=0 TO 319
- IF x1=0 AND x2=0 AND y1=0 AND y2=0 THEN
- x0=3.5/320*px-2.5
- y0=2.4/200*py-1.2
- ELSE
- x0=(x2-x1)/320*px+x1
- y0=(y2-y1)/200*py+y1
- ENDIF
- x=0
- y=0
- iteration=0
- max_iteration=40
- WHILE (x*x+y*y<=2*2 AND iteration<max_iteration)
- xtemp=x*x-y*y+x0
- y=2*x*y+y0
- x=xtemp
- iteration=iteration+1
- WEND
- IF iteration=max_iteration THEN
- color=0
- brot!(px,py)=TRUE
- ELSE
- color=iteration MOD 15
- color=color+1
- brot!(px,py)=FALSE
- ENDIF
- COLOR color
- PLOT px,py
- pixels%(px,py)=iteration
- IF MOUSEK=2 THEN
- END
- ENDIF
- NEXT px
- NEXT py
- RETURN
- PROCEDURE mandelmenu(VAR x1,y1,x2,y2)
- BMOVE brot%,XBIOS(2),32000
- SETCOLOR 0,0,0,0
- SETCOLOR 15,7,7,7
- foo=EVNT_BUTTON(1,1,1,mx%,my%,bu%,kb%)
- foo=GRAF_RUBBERBOX(mx%,my%,1,1,w%,h%)
- PRINT "x:";mx%;" y:";my%;" w:";w%;" h:";h%
- x1=3.5/320*mx%-2.5
- y1=2.4/200*my%-1.2
- x2=3.5/320*(mx%+w%)-2.5
- y2=2.4/200*(my%+h%)-1.2
- PRINT "p1:";x1;",";y1;" p2:";x2;",";y2
- RETURN
- PROCEDURE brotpack
- DIM bsum%(8)
- FOR y%=0 TO 199
- FOR x%=0 TO 319 STEP 8
- FOR bit%=0 TO 7
- b%=brot!(x%+bit%,y%)*bsum%(bit%)
- NEXT bit%
- NEXT x%
- NEXT y%
- RETURN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement