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