From ca4fe5f490584e2ebb6b69e51e7d109c3ddd9592 Mon Sep 17 00:00:00 2001 From: Sander Hautvast Date: Tue, 9 Mar 2021 17:05:47 +0100 Subject: [PATCH] updated help and a fix for vector notation --- src/css/app.css | 4 ++-- src/js/functions.js | 19 ++++++++++++++++--- src/js/index.js | 4 ++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/css/app.css b/src/css/app.css index b53ed91..6607311 100644 --- a/src/css/app.css +++ b/src/css/app.css @@ -45,7 +45,7 @@ svg { right: 10px; bottom: 0; width: 40%; - height: 10em; + height: 20em; border: 2px solid darkgray; border-radius: 10px; z-index: 10; @@ -93,7 +93,7 @@ svg { color: greenyellow; position: absolute; bottom: 1.5em; - max-height: 9em; + max-height: 20em; width: 100%; overflow-y: visible; overflow-x: hidden; diff --git a/src/js/functions.js b/src/js/functions.js index 5af6def..b1b4285 100644 --- a/src/js/functions.js +++ b/src/js/functions.js @@ -59,9 +59,22 @@ export const show = function (vector) { const help = function () { return { description: - `- vector(, , , ): draws a vector from x0,y0 to x,y - - remove(|): removes an object, - a ref is @n where n is the reference number asigned to the object` + `- vector(x0, y0, x,y): draws a vector from x0,y0 to x,y + x0 and y0 default to 0 (the origin) + - [x,y] also draws a vector, but generally, [i,j,k...] defines an array + - remove(|): removes an object, + a ref is @n where n is the reference number asigned to the object + - "..." is a lazy expression + + Try the following: + a = [0.5, 0.5] + b = [-1,1] + c = "a+b" + a=a*2 + => when a is updated, c is too. + Now try dragging a using the mouse pointer and see what happens. + ` + } } diff --git a/src/js/index.js b/src/js/index.js index 88cde53..171be55 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -20,7 +20,7 @@ const bindings = {}; // binding -> {name:binding_name, evaluated: evaluated_l const references = {}; // for retrieval of objects by reference (@n, where n is a number) const command_input_element = document.getElementById('command_input'); const command_history_element = document.getElementById('command_history'); -command_input_element.value = ''; +command_input_element.value = 'help()'; let command_history = ['']; let command_history_index = 0; @@ -276,7 +276,7 @@ const visit = function (expr) { return references[expr.name]; } case 'array': { //unsure this is what I want - let array = expr.elements.map(x => x.value); + let array = expr.elements.map(x => visit(x)); if (array.length === 2) { return create_vector(0, 0, array[0], array[1]); } else {