Poly Demo #5
#1
Code:
' polygon demo 5.bas for QB64 (B+=MGA) 2017-10-02

RANDOMIZE TIMER
CONST xmax = 700
CONST ymax = 700

SCREEN _NEWIMAGE(xmax, ymax, 32)
_TITLE "Polygon Demo 5: poly globe by bplus, spacebar will recycle whole thing again..."


horizon% = ymax / 2 + 80
land& = _NEWIMAGE(xmax, ymax, 32)
_DEST land&
FOR i = 0 TO horizon%
    midInk 0, 0, 128, 40, 200, 255, i / horizon%
    LINE (0, i)-(xmax, i)
NEXT
FOR i = horizon% TO ymax
    midInk 40, 200, 255, 50, 200, 50, (i - horizon%) / (ymax - horizon%)
    LINE (0, i)-(xmax, i)
NEXT
_DEST 0
WHILE 1
    x0 = xmax / 2: y0 = ymax / 2 + 80: a = 0
    _PUTIMAGE , land&, 0
    radius = 240: side = 300
    nV = 3
    FOR i = 1 TO 60
        midInk 65, 65, 65, 255, 255, 255, i / 20
        turtlePolygon x0, y0, radius, a, nV, side
        nV = nV + 1
        radius = radius + .25 * radius * (1 / 2) ^ i
        side = side - .1 * side
    NEXT
    dx = -150 / 500: dr = -140 / 500: ds = -200 / 500
    FOR j = 1 TO 500
        _PUTIMAGE , land&, 0
        radius = 240 + j * dr: side = 300 + j * dr
        nV = 3
        FOR i = 1 TO 60
            midInk 65, 65, 65, 255, 255, 255, i / 20
            turtlePolygon x0 + j * dx, y0, radius, a, nV, side
            nV = nV + 1
            radius = radius + .25 * radius * (1 / 2) ^ i
            side = side - .1 * side
        NEXT
        _DISPLAY
        _LIMIT 50
    NEXT
    FOR i = 1 TO 10
        midInk 255, 255, 255, 225, 255, 220, i / 10
        LINE (0, 0)-(xmax, ymax), , BF
        _DISPLAY
    NEXT
    a = 0
    WHILE 1
        IF _KEYHIT = 32 THEN EXIT WHILE
        _PUTIMAGE , land&, 0
        x0 = xmax / 2 - 150: y0 = ymax / 2 + 80
        radius = 100
        nV = 3
        side = 100
        FOR i = 1 TO 60
            turtlePolygon x0, y0, radius, a, nV, side
            nV = nV + 1
            radius = radius + .25 * radius * (1 / 2) ^ i
            side = side - .1 * side
        NEXT
        a = a + _PI(1 / 180)
        _DISPLAY
        _LIMIT 17
    WEND
WEND
SUB turtlePolygon (xOrigin, yOrigin, radius, RadianAngleOffset, nVertex, side)
    polyAngle = _PI(2) / nVertex
    p2 = polyAngle / 2
    x1 = xOrigin + radius * COS(-_PI(1 / 2))
    y1 = yOrigin + radius * SIN(-_PI(1 / 2))
    DO
        x2 = x1 + side * COS(p2)
        y2 = y1 + side * SIN(p2)
        LINE (x1, y1)-(x2, y2)
        p2 = p2 + polyAngle + RadianAngleOffset
        x1 = x2: y1 = y2
        sideCnt = sideCnt + 1
        IF sideCnt = nVertex THEN EXIT DO
    LOOP
END SUB
SUB midInk (r1%, g1%, b1%, r2%, g2%, b2%, fr##)
    COLOR _RGB(r1% + (r2% - r1%) * fr##, g1% + (g2% - g1%) * fr##, b1% + (b2% - b1%) * fr##)
END SUB

At first I thought I had a mistake on my hands...
B += x
Reply
#2
I found no error. Ran flawlessly as usual.... Big Grin

J
May your journey be free of incident.

Live long and prosper.
Reply
#3
Hi Johnno, 

Thanks, I had another idea in mind when I started (kind of boring compared to this actually) but Fate had another idea for me, fortunately!

BTW, this was created late at night with favorite music playing in background. So maybe ideal conditions for viewing this is the same.
B += x
Reply
#4
Oh I see... Create an air of curiosity, then cut it off in its tracks, just to invoke a response... Very clever.... "I had another idea in mind" then the train of thought went off on a tangent to music... Both the "idea" and the "music" type was just left "hanging"...  Because of my location on this planet I will probably be left in suspense until sun up on your side of the planet... Oh well, it's WAY faster than "snail mail"... lol
May your journey be free of incident.

Live long and prosper.
Reply
#5
I am not sure what I left hanging but I can fill in more details.

The idea I started with before what I created in post above was to just spin the polygon globe after I got it as a globe. BTW I got the polygon globe idea from looking at Geometric Art images on the Internet.

The background music was Moody Blues mixes, In Search of the Lost Chord was a favorite in early 70's. I had about 5 of their albums by mid 70's. The night of the creation of code above, I was catching up what they had done since. Apparently they are still around doing tours even...

I hope this takes care of the trains, I hate to keep people hanging.

Who knew you could turn a polygon globe inside out? That was the fortunate fate I encountered while trying to just spin the polygon globe.
B += x
Reply
#6
Moody Blues... One of my favourites!! I didn't get into the albums basically the popular singles... Cool group... STILL performing? I knew that Justin had done "War of the Worlds" some years back but had no idea they were still touring... Golden oldies never die....

Turning geometric shapes inside out completely messes with the brain... I personally would not have gone there... But, it's good to know, that some did...

I may have a solution to the "lag" in communications... One possible option is that, both our families move to somewhere more central - say Hawaii? I'm not a big beach or surf fan, but I could probably get used to it... But, then there is this little problem of a fault line and an active volcano... I like warm weather but not THAT warm... lol

I'm obviously operating on minimum caffeine levels, as is revealed by my outlandish suggestions, so I best take care of it. Have a great day.

J
May your journey be free of incident.

Live long and prosper.
Reply