-
rt, 尝试设置了 const draw = new Group()
const pen = new Pen()
const eraser = new Pen()
draw.add(pen)
draw.add(eraser)
frame.on(DragEvent.START, (e: DragEvent) => {
const inner = e.getInner(pen)
pen.setStyle({
stroke: '#6652ff',
strokeWidth: samState.strokeWidth,
strokeCap: 'round',
strokeJoin: 'round',
opacity: 0.3,
})
eraser.setStyle({
stroke: '#6652ff',
strokeWidth: samState.strokeWidth,
strokeCap: 'round',
strokeJoin: 'round',
isEraser: true,
})
pen.moveTo(inner.x, inner.y)
eraser.moveTo(inner.x, inner.y)
})
frame.on(DragEvent.DRAG, (e: DragEvent) => {
if (samState.activeTool === TOOL_TYPE.PEN) {
const inner = e.getInner(pen)
pen.lineTo(inner.x, inner.y)
pen.paint()
} else if (samState.activeTool === TOOL_TYPE.ERASER) {
const inner = e.getInner(eraser)
eraser.lineTo(inner.x, inner.y)
eraser.paint()
}
}) 这样似乎不行 |
Beta Was this translation helpful? Give feedback.
Answered by
leaferjs
Aug 25, 2023
Replies: 1 comment
-
抱歉,刚看到这个板块,之前一直关注的是issues。 这样设置才能擦除另外一支Pen的内容: const eraser = new Pen({isEraser: true}) 当在setStyle时设置,橡皮擦功能只会对当前的Pen有效, setStyle本质上是创建了一条子路径。 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
leaferjs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
抱歉,刚看到这个板块,之前一直关注的是issues。
这样设置才能擦除另外一支Pen的内容:
const eraser = new Pen({isEraser: true})
当在setStyle时设置,橡皮擦功能只会对当前的Pen有效, setStyle本质上是创建了一条子路径。