aboutsummaryrefslogtreecommitdiff
path: root/space.js
diff options
context:
space:
mode:
authorHolden Rohrer <holden.rohrer@gmail.com>2019-12-27 14:52:19 -0500
committerHolden Rohrer <holden.rohrer@gmail.com>2019-12-27 14:52:19 -0500
commit9ae02ad2c2676a5991c6c952952fc6fcfdb96304 (patch)
tree7f255b2eaaf9ee7c5cd532397f960001afb25b01 /space.js
parent310165f74d17631cfaaadc71e55000303ba0262d (diff)
integrated .loc with space.fetch (and dependencies)
Diffstat (limited to 'space.js')
-rw-r--r--space.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/space.js b/space.js
index 2b535fd..4a227cf 100644
--- a/space.js
+++ b/space.js
@@ -82,11 +82,21 @@ function Space(){
return row;
});
}
- this.comb = function(other, func, offset){
+
+ this.comb = function(other, func){ // other must have a valid .loc. If this.loc null, treated as offset
+ if (! other.loc) throw "The secondary space must have a valid .loc"
+ if (this.loc.length == 0) {
+ offset = [0, 0];
+ this.loc = other.loc;
+ } else {
+ offset = vec.sub(this.loc, other.loc);
+ if (this.data.length > 0)
+ this.loc = vec.elem(this.loc, other.loc, (a,b) => Math.min(a,b));
+ } // offset is position of other relative to this, so these are mainly definitional.
// Convert negative offsets of either sort into zero offsets with significant previous whitespace (translation)
for (let i = 0; i < -offset[0]; i++) this.data.unshift([]);
if (offset[0] < 0) offset[0] = 0;
- for (let row = 0; row < offset[0]+other.data.length; row++){ // offset[1] < 0 fix
+ for (let row = 0; row < this.data.length; row++){ // offset[1] < 0 fix
for (let i = 0; i < -offset[1]; i++) this.data[row].unshift('');
}
if (offset[1] < 0) offset[1] = 0;