Skip to content

Commit

Permalink
feat: 新增drawing-tool工具
Browse files Browse the repository at this point in the history
  • Loading branch information
Yan Heng committed Jul 28, 2023
1 parent f599e7c commit 5c3bf19
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main/src/view/canvas/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { App, ellipseTool, polylineTool, rectTool, selectTool, triangleTool } from '@pictode/core';
import { App, drawingTool, ellipseTool, polylineTool, rectTool, selectTool, triangleTool } from '@pictode/core';
import { HistoryPlugin } from '@pictode/plugin-history';
const containerRef = ref<HTMLDivElement>();
Expand All @@ -20,11 +20,11 @@ onMounted(() => {
<button @click="app.undo()">回退</button>
<button @click="app.redo()">恢复</button>
<button @click="app.setTool(selectTool)">选择🖱️</button>
<!-- <button @click="app.setModel('drawing')">铅笔✏️</button> -->
<button @click="app.setTool(rectTool)">矩形⬜️</button>
<button @click="app.setTool(ellipseTool)">圆形⭕️</button>
<button @click="app.setTool(triangleTool)">三角形🔺</button>
<button @click="app.setTool(polylineTool)">线条📉</button>
<button @click="app.setTool(drawingTool)">铅笔✏️</button>
</div>
<div ref="containerRef" class="container"></div>
</div>
Expand Down
11 changes: 11 additions & 0 deletions packages/core/src/tools/drawing-tool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Tool } from '../types';

export const drawingTool: Tool = {
name: 'drawingTool',
drawable: true,
onMouseDown({ app }) {
app.canvas.isDrawingMode = true;
},
};

export default drawingTool;

0 comments on commit 5c3bf19

Please sign in to comment.