aboutsummaryrefslogtreecommitdiff
path: root/src/p.bqn
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-09-15 21:41:46 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-09-15 21:41:46 -0400
commit1f27d70428f7e23ef472a38e60a99eb1530849d4 (patch)
tree8fcdce51177623f467e97a490ac101c8a391904c /src/p.bqn
parentfb6ec1d8b083cd2b335828ae22e978b1b13986fa (diff)
Support temporary syntax •SetPlot "scatter"
Diffstat (limited to 'src/p.bqn')
-rw-r--r--src/p.bqn14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/p.bqn b/src/p.bqn
index 9d399262..2c9972e4 100644
--- a/src/p.bqn
+++ b/src/p.bqn
@@ -3,8 +3,13 @@
width ← 384
pad ← 2⥊10
+opts_type ← @
+InitPlot ← {𝕤⋄ opts_type ↩ "line" }
+SetPlot ← {𝕤⋄ opts_type ↩ 𝕩 }
+
pa ← At "class=Paren|stroke=currentColor|stroke-width=1"
pg ← At "class=red|style=fill:none|stroke-width=1"
+pc ← At "class=red|r=4"
rc ← At "class=code|stroke-width=1|rx=5"
gr ← "g" At "font-family=BQN,monospace|font-size=18px"
Path ← "path" Elt ⊣∾"d"≍○<⊢
@@ -25,10 +30,15 @@ Plot ← {
ar ← 1⍟((÷4)⊸>∨1.5⊸<) ÷˜´ 1⊑¨win # height÷width
dim ← width (⊣≍×) ar
Scale ← ({¬𝕏}⌾(1⊸⊑) {𝕩÷˜𝕨-˜⊢}´¨ win) {𝕎𝕩}¨ ⊢
- line ← {'M'⌾⊑ ∾⥊ "L "∾¨⎉1𝕩}¨ (/≠¨⊏xy) ⊔ FmtNum ⍉> dim×Scale pts
+ line ← (/≠¨⊏xy) ⊔ FmtNum ⍉> dim×Scale pts
+ draw ← ("line"‿"scatter"⊸⊐⌾<opts_type) ⊑ ⟨
+ (pg Path {'M'⌾⊑ ∾⥊ "L "∾¨⎉1𝕩})¨
+ ("circle"Elt pc∾"cx"‿"cy"≍˘⊢)¨ <˘∘∾
+ ⟩
((-pad)∾dim+2×pad) SVG gr Enc ∾⥊¨ ⟨
<"rect" Elt rc∾(Pos-pad÷2)∾"width"‿"height"≍˘FmtNum dim+pad
pa⊸Path¨ ((0⊸≤∧≤⟜1)/·<∘∾˘("M "⊸∾˘"VH")∾¨·FmtNum dim(×∾˘⌽∘⊣)(=⌜˜↕2)⊸×) Scale 0
- pg⊸Path¨ line
+ Draw line
}
+Plot‿InitPlot‿SetPlot