Newer
Older
<template>
<div class="connections">
<canvas id="pixi"></canvas>
</div>
</template>
<script>
import { mapState } from 'vuex'
import * as PIXI from 'pixi.js'
export default {
name: 'ConnectionsLayer',
computed: mapState({
toolmode: (state) => state.ui.mode,
}),
// data() {
// // return {
// // // app: new PIXI.Application({
// // // width: window.innerWidth,
// // // height: window.innerHeight,
// // // antialias: true,
// // // transparent: true,
// // // view: canvas,
// // // }),
// // }
// },
methods: {
drawPixi() {
var canvas = document.getElementById('pixi')
const app = new PIXI.Application({
width: window.innerWidth,
height: window.innerHeight,
antialias: true,
transparent: true,
view: canvas,
})
let graphics = new PIXI.Graphics()
///graphics.x = app.renderer.width / 2
//graphics.y = app.renderer.width / 2
//document.body.appendChild(app.view)
// graphics.lineStyle(0)
// graphics.beginFill(0xde3249, 1)
// graphics.drawCircle(100, 250, 50)
// graphics.endFill()
// graphics.lineStyle(0)
// graphics.beginFill(0xde3249, 1)
// graphics.drawCircle(300, 250, 50)
// graphics.endFill()
graphics.lineStyle(8, 0x000000)
//start
graphics.moveTo(300, 250)
//end
graphics.lineTo(500, 250)
// graphics.lineStyle(2, 0xffffff, 1)
// graphics.moveTo(0, 0)
app.stage.addChild(graphics)
},
},
mounted() {
this.drawPixi()
},
}
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Opt-in to interactivity
// graphics.interactive = true
// // Shows hand cursor
// graphics.buttonMode = true
// graphics
// .on('pointerdown', onDragStart)
// .on('pointerup', onDragEnd)
// .on('pointerupoutside', onDragEnd)
// .on('pointermove', onDragMove)
// let lines = []
// let initialMoveTo
// function onDragStart(event) {
// this.dragging = true
// let mouseX = event.data.global.x
// let mouseY = event.data.global.y
// initialMoveTo = [mouseX, mouseY]
// let line = new PIXI.Graphics()
// line.lineStyle(6, 0xffffff)
// line.moveTo(mouseX, mouseY)
// lines = [line].concat(lines)
// app.stage.addChild(line)
// }
// function onDragEnd() {
// this.dragging = false
// }
// function onDragMove(event) {
// if (this.dragging) {
// let mouseX = event.data.global.x
// let mouseY = event.data.global.y
// lines[0].clear()
// lines[0].lineStyle(6, 0xffffff)
// lines[0].moveTo(initialMoveTo[0], initialMoveTo[1])
// lines[0].lineTo(mouseX, mouseY)
// }
// }
</script>