StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
StackGenVis/frontend/node_modules/abs-svg-path/index.js

68 lines
991 B

4 years ago
module.exports = absolutize
/**
* redefine `path` with absolute coordinates
*
* @param {Array} path
* @return {Array}
*/
function absolutize(path){
var startX = 0
var startY = 0
var x = 0
var y = 0
return path.map(function(seg){
seg = seg.slice()
var type = seg[0]
var command = type.toUpperCase()
// is relative
if (type != command) {
seg[0] = command
switch (type) {
case 'a':
seg[6] += x
seg[7] += y
break
case 'v':
seg[1] += y
break
case 'h':
seg[1] += x
break
default:
for (var i = 1; i < seg.length;) {
seg[i++] += x
seg[i++] += y
}
}
}
// update cursor state
switch (command) {
case 'Z':
x = startX
y = startY
break
case 'H':
x = seg[1]
break
case 'V':
y = seg[1]
break
case 'M':
x = startX = seg[1]
y = startY = seg[2]
break
default:
x = seg[seg.length - 2]
y = seg[seg.length - 1]
}
return seg
})
}