36 lines
1 KiB
Text
36 lines
1 KiB
Text
1) define X & Y:
|
|
|
|
{def X 0 1 2 3 4 5 7 8 9}
|
|
-> X
|
|
{def Y 2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0}
|
|
-> Y
|
|
|
|
2) define a function returning a sequence of SVG points
|
|
|
|
{def curve
|
|
{lambda {:curve :kx :ky}
|
|
{S.map {{lambda {:curve :kx :ky :i}
|
|
{* :kx {S.get :i {{car :curve}}}}
|
|
{* :ky {S.get :i {{cdr :curve}}}} } :curve :kx :ky}
|
|
{S.serie 0 {- {S.length {X}} 1}} }}}
|
|
|
|
3) draw a polyline in a SVG context
|
|
|
|
{svg {@ width="580" height="300" style="background:#eee"}
|
|
{g {AXES 580 300}
|
|
{polyline {@ points="{curve {cons X Y} 30 0.9}"
|
|
stroke="#000" fill="transparent" stroke-width="1"}} }}
|
|
|
|
where
|
|
|
|
{def AXES
|
|
{lambda {:w :h}
|
|
{@ transform="translate({/ :w 2},{/ :h 2}) scale(1,-1)"}
|
|
{line {@ x1="-{/ :w 2}:w" y1="0"
|
|
x2="{/ :w 2}" y2="0"
|
|
stroke="red" fill="transparent"}}
|
|
{line {@ x1="0" y1="-{/ :h 2}"
|
|
x2="0" y2="{/ :h 2}"
|
|
stroke="green" fill="transparent"}} }}
|
|
|
|
4) the result can be seen in http://lambdaway.free.fr/lambdawalks/?view=plot4
|