From ecbb04d3fbee1f833d277d0d742f5244cdd04dee Mon Sep 17 00:00:00 2001 From: Alexander Iljin Date: Sun, 22 Jan 2017 22:30:56 +0300 Subject: [PATCH] charts.demo: add a red cosine wave to the demo chart --- demos/demos.factor | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/demos/demos.factor b/demos/demos.factor index 24ba490f5a..7555891dda 100644 --- a/demos/demos.factor +++ b/demos/demos.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2017 Alexander Ilin. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays charts charts.lines colors.constants -kernel literals math math.constants math.functions sequences ui -ui.gadgets ; +kernel literals locals math math.constants math.functions +sequences ui ui.gadgets ; IN: charts.demos CONSTANT: -pi $[ pi neg ] @@ -12,10 +12,22 @@ CONSTANT: -pi $[ pi neg ] pi 2 * swap / [ * pi - dup sin 2array ] curry map ${ pi $[ pi sin ] } suffix ; -: chart-demo ( -- ) +: cosine-wave ( steps -- seq ) + [ iota ] keep + pi 2 * swap / [ * pi - dup cos 2array ] curry map + ${ pi $[ pi cos ] } suffix ; + +>axes - line new COLOR: blue >>color 40 sine-wave >>data - add-gadget "Chart" open-window ; + line new COLOR: blue >>color n sine-wave >>data add-gadget + line new COLOR: red >>color n cosine-wave >>data add-gadget + "Chart" open-window ; + +PRIVATE> + +: chart-demo ( -- ) 40 (chart-demo) ; MAIN: chart-demo