﻿ Circles from Chords :)

 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)
 KingAshish Junior Member Posts: 43 Likes Given: 34 Likes Received: 4 in 3 posts Joined: Nov 2016 Country of Origin::
Hi everyone!
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

but I'm new at this!

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)

09-17-2017, 12:27 AM
Post: #2
(Print Post)
 johnno56 Member Posts: 151 Likes Given: 4 Likes Received: 26 in 24 posts Joined: Apr 2017 Country of Origin::
This is pretty cool... Did not expect the rotation... cool.

J

May your journey be free of incident.

Live long and prosper.
 « Next Oldest | Next Newest »

Forum Jump:

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