You are not logged in or registered. Please login or register to use the full functionality of this board...
SIGN IN Join Our Community For FREE


Circles from Chords :)
09-16-2017, 11:06 AM (This post was last modified: 09-16-2017 11:09 AM by KingAshish.)
Post: #1
 (Print Post)
Rainbow Circles from Chords :)
Hi everyone! Smile
I've found that when the chords of the circle is rotated around it's boundaries then many small circles are formed inside that circle, creating a beautiful pattern. 4

I know that most of you had already knew this,
but I'm new at this!
Big Grin

Here's the code -
Code Snippet: [Select]
RANDOMIZE TIMER

_TITLE "Circles from Chords [Press Space for new Pattern]"
SCREEN _NEWIMAGE(700, 700, 32)
TYPE vector
   x AS SINGLE
   y AS SINGLE
END TYPE

TYPE chord
   startPos AS vector 'starting position
   endPos AS vector 'end position
   col AS _UNSIGNED LONG 'color of the chord
   ang AS _FLOAT
   dist AS _FLOAT 'angle between the two points of chords of a circle in radians.
   angInc AS _FLOAT 'speed
   currentAng AS _FLOAT
END TYPE

DIM CircleChords(10) AS chord, Center AS vector
Center.x = _WIDTH / 2
Center.y = _HEIGHT / 2
init:
CLS
faded = 255
FOR i = 0 TO UBOUND(CircleChords)
   CircleChords(i).col = _RGBA(RND * 256, RND * 256, RND * 256, 40)
   CircleChords(i).ang = ang#
   CircleChords(i).dist = (RND * _PI) + 0.5
   CircleChords(i).angInc = RND * .3 + 0.1
   ang# = ang# + _PI(2) / UBOUND(circlechords)
NEXT

DO
   f% = 0
   IF faded > 0 THEN
       FOR i = 0 TO UBOUND(circlechords)
           CircleChords(i).startPos.x = COS(CircleChords(i).ang + CircleChords(i).currentAng) * Center.x + Center.x
           CircleChords(i).startPos.y = SIN(CircleChords(i).ang + CircleChords(i).currentAng) * Center.y + Center.y
           CircleChords(i).endPos.x = COS(CircleChords(i).ang + CircleChords(i).dist + CircleChords(i).currentAng) * Center.x + Center.x
           CircleChords(i).endPos.y = SIN(CircleChords(i).ang + CircleChords(i).dist + CircleChords(i).currentAng) * Center.y + Center.y
           LINE (CircleChords(i).startPos.x, CircleChords(i).startPos.y)-(CircleChords(i).endPos.x, CircleChords(i).endPos.y), CircleChords(i).col
           CircleChords(i).currentAng = CircleChords(i).currentAng + CircleChords(i).angInc
       NEXT
       faded = faded - 1
   ELSE
       CLS
       DO
           FOR i = 0 TO UBOUND(circlechords)
               CircleChords(i).startPos.x = COS(CircleChords(i).ang + CircleChords(i).currentAng) * Center.x + Center.x
               CircleChords(i).startPos.y = SIN(CircleChords(i).ang + CircleChords(i).currentAng) * Center.y + Center.y
               CircleChords(i).endPos.x = COS(CircleChords(i).ang + CircleChords(i).dist + CircleChords(i).currentAng) * Center.x + Center.x
               CircleChords(i).endPos.y = SIN(CircleChords(i).ang + CircleChords(i).dist + CircleChords(i).currentAng) * Center.y + Center.y
               LINE (CircleChords(i).startPos.x, CircleChords(i).startPos.y)-(CircleChords(i).endPos.x, CircleChords(i).endPos.y), CircleChords(i).col
               CircleChords(i).currentAng = CircleChords(i).currentAng + CircleChords(i).angInc
           NEXT
           f% = f% + 1
       LOOP UNTIL f% > 300
   END IF
   '_LIMIT 40
   _DISPLAY
   IF _KEYHIT = ASC(" ") THEN GOTO init
LOOP

I hope you will enjoy it.


Attached File(s) Image(s)
   
Find all posts by this user
Like Post
09-17-2017, 12:27 AM
Post: #2
 (Print Post)
RE: Circles from Chords :)
This is pretty cool... Did not expect the rotation... cool.

J

May your journey be free of incident.

Live long and prosper.
Find all posts by this user
Like Post
The following 1 user Likes johnno56's post:
KingAshish



Forum Jump:


User(s) browsing this thread: 1 Guest(s)




QB64 Member Project - Martin Fractals version four
QB64 Member Project - Martin Fractals version one
QB64 Member Project - Splatter
QB64 Member Project - Sabotage
QB64 Member Project - Point Blank
QB64 Member Project - RGB Color Wheel
QB64 Member Project - Dakapo
QB64 Member Project - Full Color LED Sign
QB64 Member Project - Color Rotating Text
QB64 Member Project - Rubix's Magic
QB64 Member Project - Othello
QB64 Member Project - Inside Moves
QB64 Member Project - 9 Board
QB64 Member Project - Isolation
QB64 Member Project - Touche
QB64 Member Project - Kings Vallery version two
QB64 Member Project - Score 4
QB64 Member Project - Pivet version one
QB64 Member Project - Martin Fractals version two
QB64 Member Project - STxAxTIC 3D World
QB64 Member Project - Kobolts Monopoly
QB64 Member Project - Overboard
QB64 Member Project - Blokus
QB64 Member Project - Exit
QB64 Member Project - OpenGL Triangles
QB64 Member Project - Dreamy Clock
QB64 Member Project - Connect Four
QB64 Member Project - ARB Checkers
QB64 Member Project - Swirl
QB64 Member Project - Basic Dithering
QB64 Member Project - Red Scrolling LED Sign
QB64 Member Project - Algeria Weather
QB64 Member Project - Kings Court
QB64 Member Project - Quarto
QB64 Member Project - Foursight
QB64 Member Project - MAPTRIANGLE
QB64 Member Project - Pivot version two
QB64 Member Project - Amazon
QB64 Member Project - Qubic
QB64 Member Project - Kings Valley verion one
QB64 Member Project - Domain
QB64 Member Project - Line Thickness
QB64 Member Project - Rotating Background
QB64 Member Project - Spinning Color Wheel
QB64 Member Project - Input
QB64 Member Project - Color Triangles
QB64 Member Project - Martin Fractals version three
QB64 Member Project - Bowditch curve
QB64 Member Project - Spiro Roses