add color and size

This commit is contained in:
Philipp Kühn
2020-12-05 23:27:50 +01:00
parent 9a6049f4c4
commit ec62582770

View File

@@ -1,5 +1,12 @@
<template> <template>
<node-view-wrapper class="draw"> <node-view-wrapper class="draw">
<input type="color" v-model="color">
<input
type="number"
min="1"
max="10"
v-model="size"
>
<button @click="clear"> <button @click="clear">
clear clear
</button> </button>
@@ -10,6 +17,8 @@
:key="item.id" :key="item.id"
:d="item.d" :d="item.d"
:id="`id-${item.id}`" :id="`id-${item.id}`"
:stroke="item.color"
:stroke-width="item.size"
/> />
</template> </template>
</svg> </svg>
@@ -35,6 +44,8 @@ export default {
data() { data() {
return { return {
color: '#000000',
size: 2,
currentId: uuid(), currentId: uuid(),
ptdata: [], ptdata: [],
path: null, path: null,
@@ -63,6 +74,8 @@ export default {
...lines, ...lines,
{ {
id: this.currentId, id: this.currentId,
color: this.color,
size: this.size,
d, d,
}, },
], ],
@@ -81,6 +94,8 @@ export default {
.data([this.ptdata]) .data([this.ptdata])
.attr('id', `id-${this.currentId}`) .attr('id', `id-${this.currentId}`)
.attr('d', this.line) .attr('d', this.line)
.attr('stroke', this.color)
.attr('stroke-width', this.size)
const moveEvent = event.type === 'mousedown' const moveEvent = event.type === 'mousedown'
? 'mousemove' ? 'mousemove'
@@ -139,8 +154,8 @@ export default {
path { path {
fill: none; fill: none;
stroke: #000; stroke-linecap: round;
stroke-width: 2; stroke-linejoin: round;
} }
} }
</style> </style>