Skip to content

Commit

Permalink
修改绘图工具方法
Browse files Browse the repository at this point in the history
  • Loading branch information
zcZhang123 committed Oct 23, 2019
1 parent 845025d commit d0a453c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 35 deletions.
21 changes: 2 additions & 19 deletions src/components/klineChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,7 @@
<div class="canvas-toolbar-div">
<!-- <div class="toolbar"> -->
<span class="toolbar-iconfont toolbar-span" title="绘制直线" @click="drawLine">&#xe653;</span>
<span class="toolbar-iconfont toolbar-span" title="绘制矩形" @click="drawRect">&#xe648;</span>
<span class="toolbar-iconfont toolbar-span" title="铅笔" @click="drawTablet">&#xe6be;</span>
<span class="toolbar-iconfont toolbar-span" title="橡皮擦" @click="eraser">&#xe6b8;</span>
<span class="toolbar-iconfont toolbar-span">
<el-color-picker v-model="drawColor" @change="changeDrawColor"></el-color-picker>
</span>
Expand All @@ -327,9 +325,8 @@
<el-slider v-model="lineWidth" :min="1" :max="40" @change="changeLineWidth"></el-slider>
</div>
</span>
<span class="toolbar-iconfont toolbar-span" title="撤销" @click="withdraw">&#xe699;</span>
<span class="toolbar-iconfont toolbar-span" title="刷新画板" @click="refresh">&#xe747;</span>
<span class="toolbar-iconfont toolbar-span" title="保存" @click="save">&#xe69d;</span>
<span class="toolbar-iconfont toolbar-span" title="撤销绘图工具" @click="withdraw">&#xe699;</span>
<span class="toolbar-iconfont toolbar-span" title="移除绘图工具" @click="refresh">&#xe747;</span>
<!-- </div> -->
</div>
<!-- 图表 -->
Expand Down Expand Up @@ -857,11 +854,6 @@ export default {
this.p.style = "drawLine";
this.p.drawing();
},
// 绘制矩形
drawRect() {
this.p.style = "drawRect";
this.p.drawing();
},
// 绘制写字板
drawTablet() {
this.p.style = "drawTablet";
Expand All @@ -884,11 +876,6 @@ export default {
hiddenChangeLineWidthSlider() {
this.showSlider = false;
},
// 橡皮擦
eraser() {
this.p.style = "eraser";
this.p.drawing();
},
// 撤销
withdraw() {
this.p.withdraw();
Expand All @@ -897,10 +884,6 @@ export default {
refresh() {
this.p.history.length = 0;
this.p.ctx.clearRect(0, 0, this.p.canvasW, this.p.canvasH);
},
// 保存
save() {
this.p.save();
}
}
};
Expand Down
16 changes: 0 additions & 16 deletions src/js/DrawToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,12 @@ class DrawToolbar {
this.ctx.stroke();
}

//绘制矩形
drawRect(x1, y1, x2, y2) {
this.ctx.beginPath();
this.ctx.rect(x1 - 0.5, y1 - 0.5, x2 - x1, y2 - y1);
this.ctx.closePath();
this.ctx[this.type]();
}

// 绘制写字板
drawTablet(x2, y2) {
this.ctx.lineTo(x2, y2);
this.ctx[this.type]();
}

// 橡皮擦
eraser(x2, y2) {
this.ctx.clearRect(x2, y2, 10, 10);
}
// 保存
save() {
location.href = this.canvas.toDataURL().replace('image/png', 'image/stream');
}
// 撤回
withdraw() {
if (this.history.length == 0) {
Expand Down

0 comments on commit d0a453c

Please sign in to comment.