Skip to content

Commit

Permalink
adds tool classes to reduce DrawingEngine bloat (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddenist authored Dec 11, 2023
1 parent 7713878 commit e26167c
Show file tree
Hide file tree
Showing 10 changed files with 305 additions and 208 deletions.
Empty file removed apps/.gitkeep
Empty file.
13 changes: 6 additions & 7 deletions apps/web/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "./style.css"

import { WebDrawingEngine, Tools } from "@libs/drawing-engine"
import { WebDrawingEngine, ToolNames } from "@libs/drawing-engine"
import { ColorPicker } from "@libs/color-picker"
import { Color } from "@libs/shared"

Expand All @@ -24,9 +24,8 @@ function main() {
})

const tools = [
{ value: Tools.brush, label: "Brush" },
{ value: Tools.pressureSensitiveBrush, label: "Pressure-Sensitive Brush" },
{ value: Tools.eyedropper, label: "Grab Color" },
{ value: ToolNames.line, label: "Brush" },
{ value: ToolNames.eyedropper, label: "Grab Color" },
// { value: "erase", label: "Eraser" },
] as const

Expand All @@ -37,7 +36,7 @@ function main() {
state,
initialColor: engine.getCurrentColor(),
initialOpacity: (engine.getOpacity() * 100) / 255,
initialWeight: engine.lineWeight,
initialWeight: engine.tools.line.getLineWeight(),

onClear() {
engine.clearCanvas()
Expand All @@ -46,7 +45,7 @@ function main() {
engine.setOpacity((opacity * 255) / 100)
},
onSetLineWeight(weight) {
engine.setLineWeight(weight)
engine.tools.line.setLineWeight(weight)
},
onSetColor(color) {
engine.setColor(color)
Expand All @@ -65,7 +64,7 @@ function main() {
link.click()
},
tools: tools,
initialTool: engine.getCurrentTool(),
initialTool: engine.activeTool.toolName,

addListener: engine.addListener.bind(engine),
})
Expand Down
Loading

0 comments on commit e26167c

Please sign in to comment.