From 8ba2585c6eaf6f51a0e8069a0d06c7743b8b6158 Mon Sep 17 00:00:00 2001 From: Devin Elrose Date: Thu, 14 Dec 2023 21:06:35 -0800 Subject: [PATCH] =?UTF-8?q?Closes=20#44=20Also=20adds=20a=20makeLayer,=20w?= =?UTF-8?q?hich=20is=20a=20refactor,=20not=20a=20fix.=20I=20don't=20want?= =?UTF-8?q?=20to=20hear=20any=20sass.=20It's=20my=20side=20project=20and?= =?UTF-8?q?=20I=20can=20be=20as=20messy=20as=20I=20want=20=F0=9F=98=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- libs/drawing-engine/src/engine/DrawingEngine.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libs/drawing-engine/src/engine/DrawingEngine.ts b/libs/drawing-engine/src/engine/DrawingEngine.ts index d171ea5..becfc3c 100644 --- a/libs/drawing-engine/src/engine/DrawingEngine.ts +++ b/libs/drawing-engine/src/engine/DrawingEngine.ts @@ -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" @@ -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) @@ -103,6 +103,10 @@ export class DrawingEngine { this.callListeners("changeTool", { tool: this.state.tool }) } + private makeLayer(options?: Partial) { + return new Layer(this.gl, options) + } + public get pixelDensity() { return this.state.pixelDensity } @@ -138,7 +142,6 @@ export class DrawingEngine { } public setColor(color: Color) { - this.commitToSavedLayer() this.state.color = color }