demo.js 621 B

1234567891011121314151617181920212223242526272829303132333435
  1. addLine(0,0,100,100);
  2. // constants:
  3. a=7; b=6;
  4. // phase angle:
  5. phi=0.2*Math.PI;
  6. // iteration step:
  7. step=Math.PI/256;
  8. // width of plot (amplitude in X):
  9. w=100;
  10. // height of plot (amplitude in Y):
  11. h=100;
  12. // array of x,y coordinates on the curve:
  13. v=[];
  14. // loop:
  15. for (t=0.0; t<Math.PI*2; t+=step) {
  16. qDebug("t:" + t);
  17. // compute next x,y coordinate:
  18. x = w * Math.sin(a*t + phi);
  19. y = h * Math.sin(b*t);
  20. // append coordinate to our array of coordinates:
  21. v.push([x,y]);
  22. }
  23. // add a spline to the drawing, using
  24. // the computed coordinates as fit points:
  25. addSpline(v, true);
  26. // auto zoom:
  27. autoZoom();