added defaults for the origin

This commit is contained in:
Sander Hautvast 2021-02-18 22:44:28 +01:00
parent b1da7c2693
commit 64a90cb250
3 changed files with 11 additions and 5 deletions

View file

@ -14,7 +14,7 @@ The repl has the following syntax (It's work in progress, new capabilities will
* remove(x) removes bindings (when it's an object (eg vector), removes it from the matrix)
* remove(@x) removes an object using it's assigned index
* method calls:
* a = vector(0,0,12,1)
* a = vector(12,1)
> > vector@0{x0:1, y0: 2, x:12, y:1}
* a.type()
> > vector
@ -33,9 +33,9 @@ The repl has the following syntax (It's work in progress, new capabilities will
* cmdline: npm run start
* enter the following:
```
a=vector(0,0,0.5,0.5)
b=vector(0,0,-1,1)
c="a+b"
a = vector(0.5, 0.5)
b = vector(-1, 1)
c = "a+b"
```
* and press enter. Then using the mouse pointer move a or b.
* or type help()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 107 KiB

View file

@ -205,7 +205,13 @@ const method_call = function (object_wrapper, method_or_property) {
const functions = {
help: () => help(),
vector: (args) => create_vector({x0: args[0], y0: args[1], x: args[2], y: args[3]}),
vector: (args) => {
if (args.length === 2) {
return create_vector({x0: 0, y0: 0, x: args[0], y: args[1]});
} else {
return create_vector({x0: args[0], y0: args[1], x: args[2], y: args[3]});
}
},
remove: (args) => {
if (Object.prototype.hasOwnProperty.call(args[0], ['binding'])) {
delete state[args[0].binding];