about summary refs log tree commit diff stats
path: root/js/games/nluqo.github.io/~bh/downloads/csls-programs/plot
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2023-08-23 07:52:19 -0400
committerelioat <elioat@tilde.institute>2023-08-23 07:52:19 -0400
commit562a9a52d599d9a05f871404050968a5fd282640 (patch)
tree7d3305c1252c043bfe246ccc7deff0056aa6b5ab /js/games/nluqo.github.io/~bh/downloads/csls-programs/plot
parent5d012c6c011a9dedf7d0a098e456206244eb5a0f (diff)
downloadtour-562a9a52d599d9a05f871404050968a5fd282640.tar.gz
*
Diffstat (limited to 'js/games/nluqo.github.io/~bh/downloads/csls-programs/plot')
-rw-r--r--js/games/nluqo.github.io/~bh/downloads/csls-programs/plot36
1 files changed, 36 insertions, 0 deletions
diff --git a/js/games/nluqo.github.io/~bh/downloads/csls-programs/plot b/js/games/nluqo.github.io/~bh/downloads/csls-programs/plot
new file mode 100644
index 0000000..bb144b9
--- /dev/null
+++ b/js/games/nluqo.github.io/~bh/downloads/csls-programs/plot
@@ -0,0 +1,36 @@
+to plot :inputs
+keyword :inputs [maxharm 5 deltax 2 yscale 75 cycles 1 xrange 230 skip 2]
+localmake "xscale :cycles*180/:xrange
+splitscreen clearscreen hideturtle penup
+setpos list (-:xrange) 0
+pendown
+for [x :deltax [2*:xrange] :deltax] ~
+    [setpos list (xcor+:deltax) (:yscale * series :maxharm)]
+end
+
+;; Compute the Fourier series values
+
+to series :harmonic
+if :harmonic < 1 [output 0]
+output (term :harmonic)+(series :harmonic-:skip)
+end
+
+to term :harmonic
+output (sin :xscale * :harmonic * :x) / :harmonic
+end
+
+;; Handle keyword inputs
+
+.macro keyword :inputs :defaults
+if or (wordp :inputs) (numberp first :inputs) ~
+   [make "inputs sentence (first :defaults) :inputs]
+output `[local ,[filter [not numberp ?] :defaults]
+         setup.values ,[:defaults]
+         setup.values ,[:inputs]]
+end
+
+to setup.values :list
+if emptyp :list [stop]
+make first :list first butfirst :list
+setup.values butfirst butfirst :list
+end