You are not logged in or registered. Please login or register to use the full functionality of this board...
The QB64 Edition
Martin Fractals Screen Saver demo - Printable Version

+- The QB64 Edition (http://www.thejoyfulprogrammer.com/qb64/forum)
+-- Forum: QB64 (/forumdisplay.php?fid=483)
+--- Forum: QB64 Coders Delight (/forumdisplay.php?fid=8)
+---- Forum: Graphical Demos, Projects, and Special Effects (/forumdisplay.php?fid=10)
+----- Forum: Fractals (/forumdisplay.php?fid=352)
+----- Thread: Martin Fractals Screen Saver demo (/showthread.php?tid=168)



Martin Fractals Screen Saver demo - Waltersmind - 09-21-2014 05:23 AM

Here is a Martin Fractal graphical demo that I recreated from an old demo I found on a website that Anthony (ARB) shared a link to. I add my own twists to it so it is much different than the original, which was using SCREEN 12 for its graphics.

Here is the code:
Code Snippet: [Select]
DIM SHARED ScreenWidth AS _UNSIGNED INTEGER
DIM SHARED ScreenHeight AS _UNSIGNED INTEGER
DIM SHARED MainWindow AS _UNSIGNED LONG
DIM CenterX AS _FLOAT
DIM CenterY AS _FLOAT
DIM ParamA AS _FLOAT, ParamB AS _FLOAT, ParamC AS _FLOAT
DIM XOld AS _FLOAT, YOld AS _FLOAT
DIM XNew AS _FLOAT, YNew AS _FLOAT
DIM Scale AS _FLOAT
DIM CurrentCount AS _FLOAT
DIM CountMax AS _FLOAT
DIM NumPointsPlotted AS _UNSIGNED LONG
DIM PlottedMax AS _UNSIGNED LONG
DIM ColorChange AS _UNSIGNED LONG
DIM ColorChangeMax AS _UNSIGNED LONG
DIM Colr AS _UNSIGNED LONG

ScreenWidth = _DESKTOPWIDTH
ScreenHeight = _DESKTOPHEIGHT

MainWindow = _NEWIMAGE(ScreenWidth, ScreenHeight, 32)
SCREEN MainWindow

_FULLSCREEN
_MOUSEHIDE

CenterX = ScreenWidth / 2
CenterY = ScreenHeight / 2

CountMax = 10
PlottedMax = 5000
ColorChangeMax = 20000

DO

   LINE (0, 0)-(ScreenWidth - 1, ScreenHeight - 1), _RGB(255, 255, 255), BF

   ParamA = RND * 100 - 50
   ParamB = RND * 100 - 50
   ParamC = RND * 100 - 50

   XOld = 0: YOld = 0
   Colr = _RGB(RND * 255, RND * 255, RND * 255)
   ColorChange = 0
   CurrentCount = 0
   NumPointsPlotted = 0
   Scale = 6 - ABS(((ABS(ParamA) + ABS(ParamB) + ABS(ParamC)) / 3) / 10)

   DO

       PlotPoint XOld * Scale + CenterX, YOld * Scale + CenterY, Colr

       XNew = YOld - SGN(XOld) * SQR(ABS(ParamB * XOld - ParamC))
       YNew = ParamA - XOld

       XOld = XNew
       YOld = YNew

       NumPointsPlotted = NumPointsPlotted + 1

       IF NumPointsPlotted > PlottedMax THEN
           _LIMIT 60
           CurrentCount = CurrentCount + 0.0125
           NumPointsPlotted = 0
           _DISPLAY
       END IF

       ColorChange = ColorChange + 1

       IF ColorChange > ColorChangeMax THEN
           Colr = _RGB(RND * 255, RND * 255, RND * 255)
           ColorChange = 0
       END IF

       k$ = INKEY$

   LOOP WHILE k$ = "" AND CurrentCount < CountMax

   _DISPLAY

   PointsAcross = 16
   PointsDown = 8
   SectionWidth = ScreenWidth / (PointsAcross + 1)
   SectionHeight = ScreenHeight / (PointsDown + 1)
   MaxSize = SectionWidth * 1.5

   FOR ObjSize = 0 TO MaxSize STEP 2

       _LIMIT 60
       FOR y = SectionHeight TO ScreenHeight - SectionHeight / 2 STEP SectionHeight
           FOR x = SectionWidth TO ScreenWidth - SectionWidth / 2 STEP SectionWidth

               LINE (x - ObjSize, y - ObjSize)-(x + ObjSize, y + ObjSize), _RGBA(255, 255, 255, 32), BF
               IF k$ = CHR$(27) THEN SYSTEM
               k$ = INKEY$
           NEXT
       NEXT

       _DISPLAY
   NEXT


LOOP WHILE k$ <> CHR$(27)

SYSTEM


' ************************************************************​*************************************
' *                                                                                               *
' ************************************************************​*************************************
SUB PlotPoint (X AS _FLOAT, y AS _FLOAT, colr AS _UNSIGNED LONG)

Red = _RED32(colr)
Green = _GREEN32(colr)
Blue = _BLUE32(colr)
MaxI = 1
MaxRndSize = RND * 16

FOR i2 = 0 TO 7

   x1 = X + ((RND * MaxRndSize) - (MaxRndSize / 2))
   y1 = y + ((RND * MaxRndSize) - (MaxRndSize / 2))

   iMul = MaxI * (RND * 3)
   NewColr& = _RGBA(Red, Green, Blue, 8)

   LINE (INT(.5 + x1) - iMul, INT(.5 + y1) - iMul)-(INT(.5 + x1) + iMul, INT(.5 + y1) + iMul), NewColr&, BF

NEXT

END SUB

HERE ARE SOME SCREENSHOTS:

[attachment=256][attachment=257][attachment=258]
[attachment=259][attachment=260][attachment=261]
[attachment=262][attachment=263][attachment=264]
[attachment=265][attachment=266][attachment=267]
[attachment=268][attachment=269][attachment=270]
[attachment=271]