Loading ...
Sorry, an error occurred while loading the content.

38628Re: [libertybasic] SINE WAVE

Expand Messages
  • Patric t'Kindt
    Jul 7 1:22 AM
      Thanks, its better now, it was a 'quickie'




      ________________________________
      From: Stefan Pendl <pendl2megabit@...>
      To: libertybasic@yahoogroups.com
      Sent: Tuesday, 7 July, 2009 9:31:24
      Subject: RE: [libertybasic] SINE WAVE





      >
      > This is a nice application for sinusses, Lissajous:
      >

      I have changed some things:

      1) since you use PLACE there is no need to use UP and DOWN
      2) it is not necessary to call the WHEN event in a loop
      3) PROMPT allows for numerical and string variables
      4) changed the delay to use a timer, so it is the same on any machine
      5) added initial values to create a circle
      6) added graphics memory clean up

      '---code start (watch for line wraps)
      nomainwin
      TextboxColor$ = "yellow"
      aant1 = 1
      aant2 = 1
      fa = 90
      textbox #Meten.a, 630, 15, 150, 26
      textbox #Meten.b, 630, 45, 150, 26
      textbox #Meten.c, 630, 75, 150, 26
      open "Meten" for graphics_fs_ nsb as #Meten
      pie = asn(1) * 2
      print #Meten, "trapclose [einde]"
      print #Meten, "down"
      [begin]
      print #Meten, "when characterInput"
      print #Meten, "delsegment image"
      print #Meten, "discard"
      print #Meten, "fill palegray"
      prompt "Frequentie sin1"; aant1
      prompt "Frequentie sin2"; aant2
      IF aant1 = 0 AND aant2 = 0 THEN [einde]
      prompt "Phaseshift sin2"; fa
      faze=(fa/180) *pie
      gosub [assen]
      print #Meten, "size 1"
      x=0: y= 0
      print #Meten, "place "; 0 ; " "; 120
      print #Meten, "color darkcyan"
      FOR n = 0 TO 360
      x = n*2/3
      y = SIN(aant1 * (n/180*pie)) * 120 + 120
      print #Meten, "goto "; x ; " "; y
      NEXT n
      x=450: y= 200
      print #Meten, "place "; SIN(faze) * 120 + 360 ; " "; 240
      print #Meten, "color blue"
      FOR n = 0 TO 360
      y = n*2/3 +240
      x = SIN(aant2 * (n/180*pie) + faze) * 120 + 360
      print #Meten, "goto "; x ; " "; y
      NEXT n
      x=450: y=100
      print #Meten, "place "; SIN(faze) * 120 + 360 ; " "; 120
      print #Meten, "color red"
      FOR n = 0 TO 360
      x = SIN(aant2 * (n/180*pie) + faze) * 120 + 360
      y = SIN(aant1 * (n/180*pie)) * 120 + 120
      print #Meten, "goto "; x ; " "; y
      '******* delay *******
      timer 15, [stopDelay]
      wait
      [stopDelay]
      timer 0
      NEXT n
      print #Meten, "flush image"
      print #Meten, "when characterInput [begin]"
      print #Meten, "setfocus"
      wait
      [assen]
      print #Meten, "size 2"
      print #Meten, "color black"
      print #Meten, "line "; 0; " "; 240; " "; 480; " "; 240
      print #Meten, "line "; 240; " "; 0; " "; 240; " "; 480
      print #Meten, "line "; 0; " "; 120; " "; 480; " "; 120
      print #Meten, "line "; 360; " "; 0; " "; 360; " "; 480
      print #Meten, "line "; 480; " "; 480; " "; 480; " "; 0
      print #Meten, "line "; 0; " "; 480; " "; 480; " "; 480
      print #Meten.a, "Freq. sin1 = "; aant1
      print #Meten.b, "Freq. sin2 = "; aant2
      print #Meten.c, "Phaseshift = "; fa
      Return
      [einde]
      beep
      close #Meten
      end
      '---code end

      ---
      Stefan Pendl

      Liberty BASIC Assist 4.03 ........ http://www.libertyb asic.com/ assist.html
      Liberty BASIC 4.04 public beta ... http://www.libertyb asic.com/ lb404b3setup. exe

      Windows Vista Home Premium 32-bit SP2
      AMD Turion X2 RM-70 2GHz
      4GB RAM







      [Non-text portions of this message have been removed]
    • Show all 19 messages in this topic