updated help and a fix for vector notation
This commit is contained in:
parent
d7ecddbad5
commit
ca4fe5f490
3 changed files with 20 additions and 7 deletions
|
|
@ -45,7 +45,7 @@ svg {
|
||||||
right: 10px;
|
right: 10px;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
width: 40%;
|
width: 40%;
|
||||||
height: 10em;
|
height: 20em;
|
||||||
border: 2px solid darkgray;
|
border: 2px solid darkgray;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
|
|
@ -93,7 +93,7 @@ svg {
|
||||||
color: greenyellow;
|
color: greenyellow;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 1.5em;
|
bottom: 1.5em;
|
||||||
max-height: 9em;
|
max-height: 20em;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow-y: visible;
|
overflow-y: visible;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,22 @@ export const show = function (vector) {
|
||||||
const help = function () {
|
const help = function () {
|
||||||
return {
|
return {
|
||||||
description:
|
description:
|
||||||
`- vector(<x0>, <y0>, <x>, <y>): draws a vector from x0,y0 to x,y
|
`- vector(x0, y0, x,y): draws a vector from x0,y0 to x,y
|
||||||
- remove(<identifier>|<ref>): removes an object,
|
x0 and y0 default to 0 (the origin)
|
||||||
a ref is @n where n is the reference number asigned to the object`
|
- [x,y] also draws a vector, but generally, [i,j,k...] defines an array
|
||||||
|
- remove(<identifier>|<ref>): 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.
|
||||||
|
`
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 references = {}; // for retrieval of objects by reference (@n, where n is a number)
|
||||||
const command_input_element = document.getElementById('command_input');
|
const command_input_element = document.getElementById('command_input');
|
||||||
const command_history_element = document.getElementById('command_history');
|
const command_history_element = document.getElementById('command_history');
|
||||||
command_input_element.value = '';
|
command_input_element.value = 'help()';
|
||||||
let command_history = [''];
|
let command_history = [''];
|
||||||
let command_history_index = 0;
|
let command_history_index = 0;
|
||||||
|
|
||||||
|
|
@ -276,7 +276,7 @@ const visit = function (expr) {
|
||||||
return references[expr.name];
|
return references[expr.name];
|
||||||
}
|
}
|
||||||
case 'array': { //unsure this is what I want
|
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) {
|
if (array.length === 2) {
|
||||||
return create_vector(0, 0, array[0], array[1]);
|
return create_vector(0, 0, array[0], array[1]);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue