Clean up Drawing example

This commit is contained in:
Sven Adlung
2021-11-15 18:17:15 +01:00
parent 42b71abbd3
commit 2e9b3ac252

View File

@@ -29,7 +29,6 @@
import { NodeViewWrapper, nodeViewProps } from '@tiptap/vue-3'
import { v4 as uuid } from 'uuid'
import * as d3 from 'd3'
import simplify from 'simplify-js'
const getRandomElement = list => {
return list[Math.floor(Math.random() * list.length)]
@@ -101,15 +100,10 @@ export default {
this.id = uuid()
},
simplifyPoints(points) {
return simplify(points.map(point => ({ x: point[0], y: point[1] }))).map(point => [point.x, point.y])
},
tick() {
requestAnimationFrame(() => {
this.path.attr('d', points => {
const path = d3.line().curve(d3.curveBasis)(points)
// const simplifiedPath = d3.line().curve(d3.curveBasis)(this.simplifyPoints(points))
const lines = this.node.attrs.lines.filter(item => item.id !== this.id)
this.updateAttributes({
@@ -120,7 +114,6 @@ export default {
color: this.color,
size: this.size,
path,
// path: simplifiedPath,
},
],
})
@@ -128,7 +121,6 @@ export default {
return path
})
})
},
clear() {