lambdaway
::
lib_plot
3
|
list
|
login
|
load
|
|
_h1 lib_plot {pre '{{SVG 600 600} {g {AXES 600 600} {circle {@ x="0" y="0" r="150" {stroke #000 1}}} {polyline {@ points="{S.map {lambda {:i} {* 200 :i} {* 200 :i :i :i}} {S.serie -1 1.01 0.01}}" {stroke #00f 4}}} }} } {{SVG 600 600} {g {AXES 600 600} {circle {@ x="0" y="0" r="150" {stroke #000 1}}} {polyline {@ points="{S.map {lambda {:i} {* 200 :i} {* 200 :i :i :i}} {S.serie -1 1.01 0.01}}" {stroke #00f 4}}} }} {pre {@ style="transform:rotate(-2deg)"} '{def superellipse {lambda {:a :b :i} :a{* 200 {pow {abs {cos {* {PI} :i}}} {/ 2 2.5}}} :b{* 200 {pow {abs {sin {* {PI} :i}}} {/ 2 2.5}}} }} -> {def superellipse {lambda {:a :b :i} :a{* 200 {pow {abs {cos {* {PI} :i}}} {/ 2 2.5}}} :b{* 200 {pow {abs {sin {* {PI} :i}}} {/ 2 2.5}}} }} {{SVG 600 600} {g {AXES 600 600} {polyline {@ points="{S.map {lambda {:i} {superellipse + + :i} } {S.serie -1 1.01 0.01}}" {stroke #f00 4}}} {polyline {@ points="{S.map {lambda {:i} {superellipse - + :i} } {S.serie -1 1.01 0.01}}" {stroke #0f0 4}}} {polyline {@ points="{S.map {lambda {:i} {superellipse - - :i} } {S.serie -1 1.01 0.01}}" {stroke #00f 4}}} {polyline {@ points="{S.map {lambda {:i} {superellipse + - :i} } {S.serie -1 1.01 0.01}}" {stroke #ff0 4}}} }}} {{hide} {def SVG {lambda {:w :h} svg {@ width=":wpx" height=":hpx" style="background:#eee; margin-left:-10px;"} }} {def AXES {lambda {:w :h} {@ transform="translate({/ :w 2} {/ :h 2}) scale(1,-1)"} {S.map {{lambda {:w :h :i} {line {@ x1="-{/ :w 2}" y1=":i" x2="{/ :w 2}" y2=":i" {stroke #f008" 1}}} {text {@ x="0" y=":i" transform="rotate(180) scale(-1,1)"} {round {/ :i -10}}} } :w :h} {S.serie -:h :h {/ :h {/ :h 50}}}} {S.map {{lambda {:w :h :i} {line {@ x1=":i" y1="-{/ :h 2}" x2=":i" y2="{/ :h 2}" {stroke #0f08" 1}}} {text {@ x=":i" y="0" transform="rotate(0) scale(1,-1)"} {round {/ :i 10}}} } :w :h} {S.serie -:w :w {/ :w {/ :w 50}}}} {line {@ x1="-{/ :w 2}" y1="0" x2="{/ :w 2}" y2="0" {stroke #f00 3}}} {line {@ x1="0" y1="-{/ :h 2}" x2="0" y2="{/ :h 2}" {stroke #0f0 3}}} }} {def stroke {lambda {:col :w} stroke=":col" fill="transparent" stroke-width=":w" }} } {pre {def draw_cyclic {lambda {:a :b} {{SVG 600 600} {g {AXES 600 600} {polyline {@ points="{S.map {cyclic :a :b} {S.serie -10 10 0.01}}" {stroke #888 4}}}}} {center {b p(t) = e{sup it} + {sup 1}/{sub 2}e{sup A*it} + {sup i}/{sub 3}e{sup B*it},
where A = :a & B = :b}} }} {def cyclic {lambda {:a :b :t} {* 150 {+ {cos :t} {* {/ 1 2} {cos {* :a :t}}} {* {/ 1 -3} {sin {* -:b :t}}}}} {* 150 {+ {sin :t} {* {/ 1 2} {sin {* :a :t}}} {* {/ 1 3} {cos {* -:b :t}}}}} }} } {draw_cyclic {floor {* 10 {random}}} {floor {* 5 {random}}}} {div {@ id="cyclic"}} {script var foo = function() { document.getElementById("cyclic").innerHTML = LAMBDATALK.eval_forms( "{draw_cyclic {floor {* 10 {random}}} {floor {* 5 {random}}}}") }; //setTimeout( foo, 10 ) //setInterval( foo, 2000 ) }
lambdaway v.20211111