Fixed issue with Illustrator import
This commit is contained in:
parent
36cc25edb8
commit
ba05da99fd
@ -47,24 +47,22 @@ function Generator (layer, style) {
|
||||
}
|
||||
|
||||
if (type == 'line') {
|
||||
html += `L${vertex.x},${vertex.y} `
|
||||
html += this._line(vertex)
|
||||
} else if (type == 'arc_c') {
|
||||
let clock = mirror > 0 ? '0,0' : '0,1'
|
||||
html += next ? `A${Math.abs(next.x - vertex.x)},${Math.abs(next.y - vertex.y)} 0 ${clock} ${next.x},${next.y} ` : ''
|
||||
html += this._arc(vertex, next, clock)
|
||||
} else if (type == 'arc_r') {
|
||||
let clock = mirror > 0 ? '0,1' : '0,0'
|
||||
html += next ? `A${Math.abs(next.x - vertex.x)},${Math.abs(next.y - vertex.y)} 0 ${clock} ${next.x},${next.y} ` : ''
|
||||
html += this._arc(vertex, next, clock)
|
||||
} else if (type == 'arc_c_full') {
|
||||
let clock = mirror > 0 ? '1,0' : '1,1'
|
||||
html += next ? `A${Math.abs(next.x - vertex.x)},${Math.abs(next.y - vertex.y)} 0 ${clock} ${next.x},${next.y} ` : ''
|
||||
html += this._arc(vertex, next, clock)
|
||||
} else if (type == 'arc_r_full') {
|
||||
let clock = mirror > 0 ? '1,1' : '1,0'
|
||||
html += next ? `A${Math.abs(next.x - vertex.x)},${Math.abs(next.y - vertex.y)} 0 ${clock} ${next.x},${next.y} ` : ''
|
||||
html += this._arc(vertex, next, clock)
|
||||
} else if (type == 'bezier') {
|
||||
html += next && after_next ? `Q${next.x},${next.y} ${after_next.x},${after_next.y} ` : ''
|
||||
html += this._bezier(next, after_next)
|
||||
skip = 1
|
||||
} else {
|
||||
console.warn(`unknown type:${type}`)
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,6 +73,24 @@ function Generator (layer, style) {
|
||||
return html
|
||||
}
|
||||
|
||||
this._line = function (a) {
|
||||
return `L${a.x},${a.y} `
|
||||
}
|
||||
|
||||
this._arc = function (a, b, c) {
|
||||
if (!a || !b || !c) { return '' }
|
||||
|
||||
const offset = { x: b.x - a.x, y: b.y - a.y }
|
||||
|
||||
if (offset.x === 0 || offset.y === 0) { return this._line(b) }
|
||||
return `A${Math.abs(b.x - a.x)},${Math.abs(b.y - a.y)} 0 ${c} ${b.x},${b.y} `
|
||||
}
|
||||
|
||||
this._bezier = function (a, b) {
|
||||
if (!a || !b) { return '' }
|
||||
return `Q${a.x},${a.y} ${b.x},${b.y} `
|
||||
}
|
||||
|
||||
this.convert = function (layer, mirror, angle) {
|
||||
let s = ''
|
||||
let prev = null
|
||||
|
@ -142,17 +142,20 @@ DOTGRID.Tool = function () {
|
||||
return null
|
||||
}
|
||||
|
||||
this.add_segment = function (type, vertices) {
|
||||
let append_target = this.can_append({ type: type, vertices: vertices })
|
||||
if (append_target) {
|
||||
this.layer()[append_target].vertices = this.layer()[append_target].vertices.concat(vertices)
|
||||
} else {
|
||||
this.layer().push({ type: type, vertices: vertices })
|
||||
}
|
||||
}
|
||||
|
||||
this.cast = function (type) {
|
||||
if (!this.layer()) { this.layers[this.index] = [] }
|
||||
if (!this.can_cast(type)) { console.warn('Cannot cast'); return }
|
||||
|
||||
let append_target = this.can_append({ type: type, vertices: this.vertices.slice() })
|
||||
|
||||
if (append_target) {
|
||||
this.layers[this.index][append_target].vertices = this.layers[this.index][append_target].vertices.concat(this.vertices.slice())
|
||||
} else {
|
||||
this.layer().push({ type: type, vertices: this.vertices.slice() })
|
||||
}
|
||||
this.add_segment(type, this.vertices.slice())
|
||||
|
||||
DOTGRID.history.push(this.layers)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user