Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Animated String Art
#4
(07-11-2024, 08:36 PM)johnno56 Wrote: ...
This is a converted QB64 demo created by BPlus... 
...

   
click the image to zoom in

Hi Johnno,
Herewith a modified version :
Added some info and control keys so that you can play with the parameters in real time  Big Grin
      UP/DOWN to change number of lines
      R/F    to change radius of circle
      C      to change color
      L      to reset loop of time
      P      to pause animation
      ESC    to quit

Code:
'==========================================
' STRING ART ANIMATED
'
' original version in QB64 by BPlus
' converted to N7 by Johnno
' add some info and controls in N7 by Micha
'==========================================

'----------------
' INITIALIZATION
'----------------
set window "String Art Animated", 950, 600, false
set redraw off

randomize clock()

r = 250     'radius of circle
c = 300     'center of circle

n = 250     'number of lines
s = 360 / n 'distance in degree among lines

red = 175   'initial color element
green = 255 'initial color element
blue = 255  'initial color element

t = 1       'loop of time

'-----------
' MAIN LOOP
'-----------
do
    set color 0, 0, 0; cls        'clear screen

    'control of parameter
    if keydown(KEY_UP,true) and n<=245 then n=n+5
    if keydown(KEY_DOWN,true) and n>=10 then n=n-5
    if keydown(KEY_C,true) then
        red         = 32 + rnd(33, 255)
        green       = 32 + rnd(33, 255)
        blue        = 32 + rnd(33, 255)
    endif
    if keydown(KEY_R,true) and r<=245 then r=r+5
    if keydown(KEY_F,true) and r>=100 then r=r-5
    if keydown(KEY_P,true) then
        do;wait 1;until keydown(KEY_P,true)
    endif
    if keydown(KEY_L,true) then t=1
   
    'info
    set color 255,255,255 'white
    set caret 600,50
    wln "INFORMATION"
    wln "-----------------------------------"
    wln "number of lines (5-250)   = "+n
    wln "radius of circle (95-250) = "+r
    wln "loop of time (1-19)       = "+int(t)
    wln
    wln
    wln "control keys :"
    wln "  UP/DOWN to change number of lines"
    wln "  R/F     to change radius of circle"
    wln "  C       to change color"
    wln "  L       to reset loop of time"
    wln "  P       to pause animation"
    wln "  ESC     to quit"
           
    'draw lines inside a circle
    set color red, green , blue
    draw ellipse c, c, r, r
    for i = 1 to n
        a1 = rad(s * i)
        a2 = rad(s * i * t)
        draw line c + sin(a1) * r, c + cos(a1) * r, c + sin(a2) * r, c + cos(a2) * r
    next
  
    'change t value
    if t >= 20 then
        t = 1               'reset t
    else
        t = t + 1.25/100    'increment t by 1.25%
    endif

    redraw
    fwait 60  
until keydown(KEY_ESCAPE, true)
Reply


Messages In This Thread
Animated String Art - by johnno56 - 07-11-2024, 08:36 PM
RE: Animated String Art - by 1micha.elok - 07-11-2024, 11:53 PM
RE: Animated String Art - by johnno56 - 07-12-2024, 01:00 PM
RE: Animated String Art - by 1micha.elok - 07-13-2024, 02:24 PM
RE: Animated String Art - by johnno56 - 07-13-2024, 07:16 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)