Skip to content

Commit

Permalink
refactor(SvgDrawing): refactor pen config update flow
Browse files Browse the repository at this point in the history
  • Loading branch information
kmkzt committed May 28, 2019
1 parent cb6c899 commit 7838f16
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/SvgDrawing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export class SvgDrawing extends Two {
this.drawingStart = this.drawingStart.bind(this)
this.drawingMove = this.drawingMove.bind(this)
this.drawingEnd = this.drawingEnd.bind(this)
this.drawingConfigUpdate = this.drawingConfigUpdate.bind(this)
this.mouseUp = this.mouseUp.bind(this)
this.mouseMove = this.mouseMove.bind(this)
this.mouseDown = this.mouseDown.bind(this)
Expand Down Expand Up @@ -102,10 +101,6 @@ export class SvgDrawing extends Two {
/**
* Drawing Line methods
*/
private drawingConfigUpdate({ x, y }: { x: number; y: number }) {
this.drawingEnd()
this.drawingStart({ x, y })
}
private drawingStart({ x, y }: { x: number; y: number }) {
this.current.set(x, y)
}
Expand All @@ -118,7 +113,7 @@ export class SvgDrawing extends Two {
this.line.linewidth !== this.penWidth ||
this.line.stroke !== this.penColor
) {
this.drawingConfigUpdate({ x, y })
this.drawingEnd()
return
}
const v: Two.Vector = makePoint(x, y)
Expand All @@ -127,6 +122,7 @@ export class SvgDrawing extends Two {
}
const vprev: Two.Vector = makePoint(this.current.x, this.current.y)
const vnext: Two.Vector = makePoint(x, y)
this.current.set(x, y)
this.line = this.makeCurve([vprev, vnext], true)
this.line.noFill().stroke = this.penColor
this.line.linewidth = this.penWidth
Expand Down

0 comments on commit 7838f16

Please sign in to comment.