1
0
Fork 0

fix(core): Do no round point coordinates

This commit is contained in:
Joost De Cock 2021-04-11 16:20:39 +02:00
parent 550fdb22cb
commit 8924f2d40b
3 changed files with 5 additions and 10 deletions

View file

@ -7,8 +7,7 @@ import {
curvesIntersect, curvesIntersect,
pointOnLine, pointOnLine,
pointOnCurve, pointOnCurve,
curveEdge, curveEdge
round
} from './utils' } from './utils'
function Path(debug = false) { function Path(debug = false) {
@ -207,7 +206,7 @@ Path.prototype.length = function () {
if (op.to) current = op.to if (op.to) current = op.to
} }
return round(length) return length
} }
/** Returns the startpoint of the path */ /** Returns the startpoint of the path */

View file

@ -1,9 +1,8 @@
import Attributes from './attributes' import Attributes from './attributes'
import { round } from './utils'
function Point(x, y, debug = false) { function Point(x, y, debug = false) {
this.x = round(x) this.x = x
this.y = round(y) this.y = y
this.attributes = new Attributes() this.attributes = new Attributes()
Object.defineProperty(this, 'debug', { value: debug, configurable: true }) Object.defineProperty(this, 'debug', { value: debug, configurable: true })
} }
@ -49,7 +48,7 @@ Point.prototype.dist = function (that) {
let dx = this.x - that.x let dx = this.x - that.x
let dy = this.y - that.y let dy = this.y - that.y
return round(Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2))) return Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2))
} }
/** Returns slope of a line made by this point and that point */ /** Returns slope of a line made by this point and that point */

View file

@ -1,3 +0,0 @@
export default function round(value) {
return Math.round(value * 1e2) / 1e2
}