Outline progress

This commit is contained in:
Bán Dénes 2020-06-02 22:59:05 +02:00
parent 8e9cdd1364
commit c0a7fb4552
4 changed files with 127 additions and 55 deletions

View file

@ -21,13 +21,21 @@ exports.circle = (p, r) => {
return new m.paths.Circle(p, r)
}
exports.rect = (w, h, o=[0, 0]) => {
return m.model.move({paths: {
exports.rect = (w, h, o=[0, 0], mirrored=false) => {
const res = {
top: line([0, h], [w, h]),
right: line([w, h], [w, 0]),
bottom: line([w, 0], [0, 0]),
left: line([0, 0], [0, h])
}}, o)
}
if (mirrored) {
for (const [key, val] of Object.entries(res)) {
const tmp = val.origin
val.origin = val.end
val.end = tmp
}
}
return m.model.move({paths: res}, o)
}
exports.poly = (arr) => {
@ -41,4 +49,8 @@ exports.poly = (arr) => {
prev = p
}
return res
}
exports.eq = (a, b) => {
return a[0] === b[0] && a[1] === b[1]
}