Skip to content

Commit

Permalink
Closes #44
Browse files Browse the repository at this point in the history
Also adds a makeLayer, which is a refactor, not a fix.
I don't want to hear any sass. It's my side project and I can be as messy as I want 😤

Plus, vscode doesn't give me an easy interface to only commit specific lines. I'm guessing there's a plugin that can do that, but... that would require me actually looking.
  • Loading branch information
hiddenist committed Dec 15, 2023
1 parent e679bf4 commit 8ba2585
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions libs/drawing-engine/src/engine/DrawingEngine.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TextureDrawingProgram } from "../programs/TextureDrawingProgram"
import type { Vec2 } from "@libs/shared"
import { Color } from "@libs/shared"
import { Layer } from "./Layer"
import { Layer, LayerSettings } from "./Layer"
import { SourceImage } from "../utils/image/SourceImage"
import { ToolName, ToolNames } from "../exports"
import { LineHistoryEntry, LineTool } from "../tools/LineTool"
Expand Down Expand Up @@ -89,8 +89,8 @@ export class DrawingEngine {
prevTool: defaultTool,
}

this.savedDrawingLayer = new Layer(gl)
this.activeDrawingLayer = new Layer(gl, { clearBeforeDrawing: true })
this.savedDrawingLayer = this.makeLayer()
this.activeDrawingLayer = this.makeLayer({ clearBeforeDrawing: true })

this.program = new TextureDrawingProgram(gl, this.state.pixelDensity)

Expand All @@ -103,6 +103,10 @@ export class DrawingEngine {
this.callListeners("changeTool", { tool: this.state.tool })
}

private makeLayer(options?: Partial<LayerSettings>) {
return new Layer(this.gl, options)
}

public get pixelDensity() {
return this.state.pixelDensity
}
Expand Down Expand Up @@ -138,7 +142,6 @@ export class DrawingEngine {
}

public setColor(color: Color) {
this.commitToSavedLayer()
this.state.color = color
}

Expand Down

0 comments on commit 8ba2585

Please sign in to comment.