How to resolve the algorithm Polyspiral step by step in the FutureBasic programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Polyspiral step by step in the FutureBasic programming language
Table of Contents
Problem Statement
A Polyspiral is a spiral made of multiple line segments, whereby each segment is larger (or smaller) than the previous one by a given amount. Each segment also changes direction at a given angle.
Animate a series of polyspirals, by drawing a complete spiral then incrementing the angle, and (after clearing the background) drawing the next, and so on. Every spiral will be a frame of the animation. The animation may stop as it goes full circle or continue indefinitely. The given input values may be varied. If animation is not practical in your programming environment, you may show a single frame instead.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Polyspiral step by step in the FutureBasic programming language
Source code in the futurebasic programming language
local fn DoIt
NSInteger i, t
double length, incr, x1, y1, x2, y2, twopi, angle, w, h
pen 2.0, fn ColorRed, NSLineCapStyleButt, NULL, 0
incr = 0 : twopi = 2 * pi
w = 600 : h = 600
t = 150
while ( t > 0 )
incr = ( incr + 0.05 mod twopi )
x1 = w / 2
y1 = h / 2
length = 1.0
angle = incr
line to x1, y1
cls
for i = 1 to 300
x2 = x1 + cos( angle ) * length
y2 = y1 + sin( angle ) * length
line to x1, y1 to x2, y2
x1 = x2 : y1 = y2
length = length + 1.0
angle = ( angle + incr mod twopi )
next
t--
wend
end fn
window 1, @"Rosetta Code Polyspiral", fn CGRectMake( 0, 0, 600, 600 )
WindowSetBackgroundColor( 1, fn ColorBlack )
fn DoIt
HandleEvents
You may also check:How to resolve the algorithm Password generator step by step in the Haskell programming language
You may also check:How to resolve the algorithm Matrix digital rain step by step in the C programming language
You may also check:How to resolve the algorithm URL encoding step by step in the Apex programming language
You may also check:How to resolve the algorithm Long year step by step in the zkl programming language
You may also check:How to resolve the algorithm Range extraction step by step in the UNIX Shell programming language