You are not logged in or registered. Please login or register to use the full functionality of this board...
The QB64 Edition
Splatter Art with Martin Fractals - 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: Splatter Art with Martin Fractals (/showthread.php?tid=169)



Splatter Art with Martin Fractals - Waltersmind - 09-21-2014 06:07 AM

Here is a modified version of the Martin Fractals Demo I posted before. This on looks like splatter art.

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, XOld2 AS _FLOAT, YOld AS _FLOAT, YOld2 AS _FLOAT
DIM XNew AS _FLOAT, XNew2 AS _FLOAT, YNew AS _FLOAT, YNew2 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 = 15
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: XOld2 = 0: YOld = 0
    Colr = _RGB(RND * 255, RND * 255, RND * 255)
    ColorChange = 0
    CurrentCount = 0
    NumPointsPlotted = 0
    Scale = 3

    DO

        PlotPoint XOld2 * Scale + CenterX, YOld2 * Scale + CenterY, Colr

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

        XNew2 = (YOld2 - SIN(XOld2) * SIN((ParamB * XOld + ParamC))) * 0.999995
        YNew2 = ParamA - XOld2

        XOld2 = XNew2
        YOld2 = YNew2

        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 5

    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=272][attachment=273][attachment=274]
[attachment=275][attachment=276][attachment=277]
[attachment=278][attachment=279][attachment=280]




RE: Splatter Art with Martin Fractals - Anthony.R.Brown - 10-09-2014 01:46 PM

Looks Great Walter...

It looks like the Floor after I have come back from a Night on the Beer! Smile

I am sure there is some Complex Math going on there to make all that Work!



Anthony.


RE: Splatter Art with Martin Fractals - Waltersmind - 10-09-2014 03:18 PM

Anthony,

There really isn't any complex math being used in this project. Here is the math behind it:


Code Snippet: [Select]
        PlotPoint XOld2 * Scale + CenterX, YOld2 * Scale + CenterY, Colr

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

        XNew2 = (YOld2 - SIN(XOld2) * SIN((ParamB * XOld + ParamC))) * 0.999995
        YNew2 = ParamA - XOld2

        XOld2 = XNew2
        YOld2 = YNew2

        XOld = XNew
        YOld = YNew


There are some multiplications, Additions, subtractions, a SQR(), a SGN(), and two SIN() functions.

If you think that is cool, check out the other fractal demo I posted. It is identical except with some minor changes in the algorithm.


Walter Whitman
The Joyful Programmer