Polygon Demo bplus B = B + ... Offline This member has written at least 1,268 posts and created at least 154 threads on this forum since joining inApr 2017. 09-17-2017, 10:04 PM Code:```' polygon demo.bas for QB64 (B+=MGA) 2017-09-17 CONST xmax = 700 CONST ymax = 700 SCREEN _NEWIMAGE(xmax, ymax, 32) _TITLE "Polygon Demo by bplus" x0 = xmax / 2: y0 = ymax / 2 FOR n = 3 TO 9    radius = 345    CLS    rr = RND * 75: gg = RND * 75: bb = RND * 75    FOR a = 0 TO _PI(2) STEP _PI(1 / 20)        radius = radius - 8        pc& = _RGB(radius / 345 * 200 + rr, radius / 345 * 200 + gg, radius / 345 * 200 + bb)        COLOR pc&        polygon x0, y0, radius, n, a        PAINT (x0, y0), pc&, pc&        _LIMIT 10    NEXT    SLEEP 2 NEXT SUB polygon (xOrigin, yOrigin, radius, nVertex, RadianAngleOffset)    polyAngle = _PI(2) / nVertex    x1 = xOrigin + radius * COS(polyAngle + RadianAngleOffset)    y1 = yOrigin + radius * SIN(polyAngle + RadianAngleOffset)    FOR i = 2 TO nVertex + 1        x2 = xOrigin + radius * COS(i * polyAngle + RadianAngleOffset)        y2 = yOrigin + radius * SIN(i * polyAngle + RadianAngleOffset)        LINE (x1, y1)-(x2, y2)        x1 = x2: y1 = y2    NEXT END SUB``` Attached Files Thumbnail(s) B += x KingAshish Registered Offline This member has written at least 58 posts and created at least 15 threads on this forum since joining inNov 2016. 09-17-2017, 10:18 PM Hi bplus! I've made some changes to your demo. Code:```' polygon demo.bas for QB64 (B+=MGA) 2017-09-17 CONST xmax = 700 CONST ymax = 700 SCREEN _NEWIMAGE(xmax, ymax, 32) _TITLE "Polygon Demo by bplus" CLS , _RGB(255, 255, 255) x0 = xmax / 2: y0 = ymax / 2 canvas& = _NEWIMAGE(xmax, ymax, 32) FOR n = 3 TO 9     radius = 500     rr = RND * 75: gg = RND * 75: bb = RND * 75     FOR a = 0 TO _PI(2) STEP _PI(1 / 30)         radius = radius - 8         '      pc& = _RGB(radius / 345 * 200 + rr, radius / 345 * 200 + gg, radius / 345 * 200 + bb)         '     COLOR pc&         IF g = 0 THEN pc& = _RGB(10, 0, 0): g = 1 ELSE pc& = _RGB(255, 255, 255): g = 0         _DEST canvas&         CLS , 1         COLOR pc&         polygon x0, y0, radius, n, a         PAINT (x0, y0), pc&, pc&         _DEST 0         _PUTIMAGE , canvas&         _LIMIT 10     NEXT     SLEEP 2 NEXT SUB polygon (xOrigin, yOrigin, radius, nVertex, RadianAngleOffset) polyAngle = _PI(2) / nVertex x1 = xOrigin + radius * COS(polyAngle + RadianAngleOffset) y1 = yOrigin + radius * SIN(polyAngle + RadianAngleOffset) FOR i = 2 TO nVertex + 1     x2 = xOrigin + radius * COS(i * polyAngle + RadianAngleOffset)     y2 = yOrigin + radius * SIN(i * polyAngle + RadianAngleOffset)     LINE (x1, y1)-(x2, y2)     x1 = x2: y1 = y2 NEXT END SUB``` johnno56 Registered Offline This member has written at least 261 posts and created at least 17 threads on this forum since joining inApr 2017. 09-18-2017, 07:19 AM Both version are very cool. QB64 could use a polygon command... One strange thing about version #2.... After watching it I had this irresistible urge to bury a cat in the back yard... Problem is, we don't have a cat, or a shovel.... J May your journey be free of incident. Live long and prosper. bplus B = B + ... Offline This member has written at least 1,268 posts and created at least 154 threads on this forum since joining inApr 2017. 09-18-2017, 11:23 AM Another use of polygons that might be reminiscent of another recent graphics post: Code:```' polygon demo 2.bas for QB64 (B+=MGA) 2017-09-17 RANDOMIZE TIMER CONST xmax = 700 CONST ymax = 700 SCREEN _NEWIMAGE(xmax, ymax, 32) _TITLE "Polygon Demo 2, by bplus" x0 = xmax / 2: y0 = ymax / 2 WHILE 1    CLS    top = INT(RND * 50) + 9    FOR i = 1 TO top        radius = RND * 345        n = INT(RND * 9) + 3        stepper = _PI(1 / (RND * 25 + 1))        COLOR _RGBA(RND * 255, RND * 255, RND * 255, RND * 255)        FOR a = 0 TO _PI(2) STEP stepper            polygon x0, y0, radius, n, a        NEXT    NEXT    _DISPLAY    _DELAY 2 WEND SUB polygon (xOrigin, yOrigin, radius, nVertex, RadianAngleOffset)    polyAngle = _PI(2) / nVertex    x1 = xOrigin + radius * COS(polyAngle + RadianAngleOffset)    y1 = yOrigin + radius * SIN(polyAngle + RadianAngleOffset)    FOR i = 2 TO nVertex + 1        x2 = xOrigin + radius * COS(i * polyAngle + RadianAngleOffset)        y2 = yOrigin + radius * SIN(i * polyAngle + RadianAngleOffset)        LINE (x1, y1)-(x2, y2)        x1 = x2: y1 = y2    NEXT END SUB``` Attached Files Thumbnail(s)   B += x bplus B = B + ... Offline This member has written at least 1,268 posts and created at least 154 threads on this forum since joining inApr 2017. 09-18-2017, 12:46 PM I love recursive: Code:```' polygon demo 3.bas for QB64 (B+=MGA) 2017-09-17 RANDOMIZE TIMER CONST xmax = 700 CONST ymax = 700 SCREEN _NEWIMAGE(xmax, ymax, 32) _TITLE "Polygon Demo 3, by bplus" x0 = xmax / 2: y0 = ymax / 2 WHILE 1    CLS    n = INT(RND * 5) + 3    radius = RND * 100 + n * 10 + 40    stepper = _PI(1 / (2 * n))    FOR a = 0 TO _PI(2) STEP stepper        COLOR _RGBA(RND * 255, RND * 255, RND * 255, 5 + RND * 80)        polygon x0, y0, radius, n, a    NEXT    _DISPLAY    _DELAY 2.5 WEND SUB polygon (xOrigin, yOrigin, radius, nVertex, RadianAngleOffset)    polyAngle = _PI(2) / nVertex    x1 = xOrigin + radius * COS(polyAngle + RadianAngleOffset)    y1 = yOrigin + radius * SIN(polyAngle + RadianAngleOffset)    FOR i = 2 TO nVertex + 1        x2 = xOrigin + radius * COS(i * polyAngle + RadianAngleOffset)        y2 = yOrigin + radius * SIN(i * polyAngle + RadianAngleOffset)        LINE (x1, y1)-(x2, y2)        IF radius > nVertex * 4 - 5 THEN            polygon x1, y1, radius * .4, nVertex, RadianAngleOffset        END IF        x1 = x2: y1 = y2    NEXT END SUB``` Attached Files Thumbnail(s)   B += x bplus B = B + ... Offline This member has written at least 1,268 posts and created at least 154 threads on this forum since joining inApr 2017. 09-19-2017, 02:30 AM This post was last modified: 09-19-2017, 02:31 AM by bplus.Edited 0 times A moving experience with polygons: Code:```' polygon demo 4.bas for QB64 (B+=MGA) 2017-09-18 RANDOMIZE TIMER CONST xmax = 700 CONST ymax = 700 SCREEN _NEWIMAGE(xmax, ymax, 32) _TITLE "Polygon Demo 4 by bplus, Toggles: press spacebar + main poly 6 to 10, press enter + thick 1 to 6" COMMON SHARED dradius, thick dradius = .315: thick = 0 x0 = xmax / 2: y0 = ymax / 2: a = _PI(-.5): n = 6 COLOR _RGB(50, 150, 200) WHILE 1    CLS    IF _KEYHIT = 32 THEN        IF n = 10 THEN n = 6: dradius = .3 ELSE n = n + 1: dradius = dradius - .025    END IF    IF _KEYHIT = 13 THEN        IF thick = 5 THEN thick = 0 ELSE thick = thick + 1    END IF    radius = 240    polygon x0, y0, radius, n, a    a = a + _PI(1 / 180)    _DISPLAY    _LIMIT 10 WEND SUB polygon (xOrigin, yOrigin, radius, nVertex, RadianAngleOffset)    polyAngle = _PI(2) / nVertex    x1 = xOrigin + radius * COS(RadianAngleOffset)    y1 = yOrigin + radius * SIN(RadianAngleOffset)    FOR i = 1 TO nVertex        x2 = xOrigin + radius * COS(i * polyAngle + RadianAngleOffset)        y2 = yOrigin + radius * SIN(i * polyAngle + RadianAngleOffset)        SELECT CASE i MOD 7            CASE 1: COLOR _RGB(255, 0, 0)            CASE 2: COLOR _RGB(255, 255, 0)            CASE 3: COLOR _RGB(0, 0, 255)            CASE 4: COLOR _RGB(0, 165, 0)            CASE 5: COLOR _RGB(128, 0, 128)            CASE 6: COLOR _RGB(0, 128, 128)            CASE 0: COLOR _RGB(200, 100, 0)        END SELECT        FOR j = 0 TO thick            LINE (x2 + j, y2 + j)-(x1 + j, y1 + j)        NEXT        IF radius > 5 THEN            polygon x1, y1, radius * dradius, nVertex - 1, -2.3 * RadianAngleOffset        END IF        x1 = x2: y1 = y2    NEXT END SUB``` remember these are just still shots... Attached Files Thumbnail(s)  B += x bplus B = B + ... Offline This member has written at least 1,268 posts and created at least 154 threads on this forum since joining inApr 2017. 09-20-2017, 03:19 AM Sometimes color can get in the way: Code:```' polygon demo 4B.bas for QB64 (B+=MGA) 2017-09-18 RANDOMIZE TIMER CONST xmax = 700 CONST ymax = 700 SCREEN _NEWIMAGE(xmax, ymax, 32) _TITLE "Polygon Demo 4B: Just the lines! by bplus, spacebar toggles main poly 3 to 10" COMMON SHARED dradius, thick dradius = .315: thick = 0 x0 = xmax / 2: y0 = ymax / 2: a = _PI(-.5): n = 3 COLOR _RGB(50, 150, 200) WHILE 1    CLS    IF _KEYHIT = 32 THEN        IF n = 10 THEN n = 3: dradius = .315 ELSE n = n + 1: dradius = dradius - .013    END IF    radius = 240    polygon x0, y0, radius, n, a    a = a + _PI(1 / 180)    _DISPLAY    _LIMIT 10 WEND SUB polygon (xOrigin, yOrigin, radius, nVertex, RadianAngleOffset)    polyAngle = _PI(2) / nVertex    x1 = xOrigin + radius * COS(RadianAngleOffset)    y1 = yOrigin + radius * SIN(RadianAngleOffset)    FOR i = 1 TO nVertex        x2 = xOrigin + radius * COS(i * polyAngle + RadianAngleOffset)        y2 = yOrigin + radius * SIN(i * polyAngle + RadianAngleOffset)        LINE (x2 + j, y2 + j)-(x1 + j, y1 + j)        IF radius > 5 THEN            polygon x1, y1, radius * dradius, nVertex + 1, -2.3 * RadianAngleOffset        END IF        x1 = x2: y1 = y2    NEXT END SUB``` Attached Files Thumbnail(s) B += x bplus B = B + ... Offline This member has written at least 1,268 posts and created at least 154 threads on this forum since joining inApr 2017. 09-20-2017, 03:24 AM A new twist: Code:```'elliptical  polygon demo.bas for QB64 (B+=MGA) 2017-09-19 CONST xmax = 700 CONST ymax = 700 SCREEN _NEWIMAGE(xmax, ymax, 32) _TITLE "Elliptical Polygon Demo by bplus" x0 = xmax / 2: y0 = ymax / 2 FOR n = 7 TO 3 STEP -1    xRadius = 345    yRadius = 10    CLS    rr = RND * 75: gg = RND * 75: bb = RND * 75    FOR a = 0 TO _PI(2) STEP _PI(1 / 20)        xRadius = xRadius - 8        yRadius = yRadius + 8        pc& = _RGB(xRadius / 345 * 200 + rr, xRadius / 345 * 200 + gg, 255 - (xRadius / 345 * 200 + bb))        COLOR pc&        polygon x0, y0, xRadius, yRadius, n, a        PAINT (x0, y0), pc&, pc&        _LIMIT 10    NEXT    SLEEP 2 NEXT SUB polygon (xOrigin, yOrigin, xRadius, yRadius, nVertex, RadianAngleOffset)    polyAngle = _PI(2) / nVertex    x1 = xOrigin + xRadius * COS(polyAngle + RadianAngleOffset)    y1 = yOrigin + yRadius * SIN(polyAngle + RadianAngleOffset)    FOR i = 2 TO nVertex + 1        x2 = xOrigin + xRadius * COS(i * polyAngle + RadianAngleOffset)        y2 = yOrigin + yRadius * SIN(i * polyAngle + RadianAngleOffset)        LINE (x1, y1)-(x2, y2)        x1 = x2: y1 = y2    NEXT END SUB``` Attached Files Thumbnail(s) B += x bplus B = B + ... Offline This member has written at least 1,268 posts and created at least 154 threads on this forum since joining inApr 2017. 09-20-2017, 03:31 AM hmm... Code:```' Elliptical polygon demo 2.bas for QB64 (B+=MGA) 2017-09-19 RANDOMIZE TIMER CONST xmax = 700 CONST ymax = 700 SCREEN _NEWIMAGE(xmax, ymax, 32) _TITLE "Elliptical Polygon Demo 2, by bplus" x0 = xmax / 2: y0 = ymax / 2 WHILE 1    CLS    top = INT(RND * 50) + 9    FOR i = 1 TO top        xRadius = RND * 345        yRadius = RND * 345        n = INT(RND * 9) + 3        stepper = _PI(1 / (RND * 20 + 1))        COLOR _RGBA(RND * 255, RND * 255, RND * 255, RND * 255)        FOR a = 0 TO _PI(2) STEP stepper            polygon x0, y0, xRadius, yRadius, n, a        NEXT    NEXT    _DISPLAY    _DELAY 2 WEND SUB polygon (xOrigin, yOrigin, xRadius, yRadius, nVertex, RadianAngleOffset)    polyAngle = _PI(2) / nVertex    x1 = xOrigin + xRadius * COS(polyAngle + RadianAngleOffset)    y1 = yOrigin + yRadius * SIN(polyAngle + RadianAngleOffset)    FOR i = 2 TO nVertex + 1        x2 = xOrigin + xRadius * COS(i * polyAngle + RadianAngleOffset)        y2 = yOrigin + yRadius * SIN(i * polyAngle + RadianAngleOffset)        LINE (x1, y1)-(x2, y2)        x1 = x2: y1 = y2    NEXT END SUB``` Attached Files Thumbnail(s)  B += x johnno56 Registered Offline This member has written at least 261 posts and created at least 17 threads on this forum since joining inApr 2017. 09-20-2017, 09:13 AM Ohh... Now you're just showing off... Brilliant demos! J May your journey be free of incident. Live long and prosper. Waltersmind A computer programming hobbyist and enthusiast Offline This member has written at least 816 posts and created at least 109 threads on this forum since joining inJun 2014. 09-21-2017, 02:37 AM @Everyone Please continue showing off! The provides the community with a lot more cool projects to play with. Dedicated to empowering computer programming hobbyists, tinkerers, amateurs, and enthusiasts. bplus B = B + ... Offline This member has written at least 1,268 posts and created at least 154 threads on this forum since joining inApr 2017. 09-21-2017, 03:11 AM Hey Walter! you are back, I was getting concerned. B += x Waltersmind A computer programming hobbyist and enthusiast Offline This member has written at least 816 posts and created at least 109 threads on this forum since joining inJun 2014. 09-21-2017, 03:44 AM @bplus I am not back just yet. I have been in the process of moving the last four days and putting everything in storage. My wife and I are staying at a local campground until the house we are waiting on is ready. It should be about 1-2 weeks. During that time, I do not have an electrical source to get on my laptop, so the only time I can get on is during my lunch at work, or after closing. So during the little mini-vacation, my wife and I are taking, I will not be on here very much. I haven't been out camping in over 20 years. I really did miss it. It has been so peaceful and I have been sleeping well. The local campground we are at has restrooms, showers, and laundry facilities, so I am not doing without, except for electricity. I do have an inverter that plugs into the car lighter port, but one of the wires is broke and I have to fix it. If I ever think about fixing it, I may be able to get online on the laptop at night, since I get my internet through my cell phone anyway. I was out of work the last two days, so I haven't had the chance to get on. Plus I have been too busy and extremely tired to even think about. I was up over 40 hours packing, loading the Uhaul, Unloading the Uhaul, and finding a place to stay. The first night at the campground, we were so exhausted, we slept in the car. There was no way I could stay awake any longer. Last night, we got the first tent up to sleep in, and we cooked pork chops on the grill. They were delicious. We will set up the second tent to store our supplies (clothes, shower stuff, and food) tonight. After 18 years of marriage, this is the first time my wife and ever camped out together. It was fun. Dedicated to empowering computer programming hobbyists, tinkerers, amateurs, and enthusiasts. bplus B = B + ... Offline This member has written at least 1,268 posts and created at least 154 threads on this forum since joining inApr 2017. 09-21-2017, 04:24 AM Wow! allot going on. Food does taste better outdoors. B += x Waltersmind A computer programming hobbyist and enthusiast Offline This member has written at least 816 posts and created at least 109 threads on this forum since joining inJun 2014. 09-21-2017, 04:27 AM @bplus Yes, cooking food outdoors does taste a lot better. My wife and I have been joking about living like this for the rest of our lives. But again, it is only a little joke. Dedicated to empowering computer programming hobbyists, tinkerers, amateurs, and enthusiasts. « Next Oldest | Next Newest » 