From fcc6a2b04a4cda9051573cdce7044de34c553577 Mon Sep 17 00:00:00 2001 From: Jonas de Luna Skulberg Date: Thu, 8 Aug 2024 10:13:01 +0200 Subject: [PATCH] Add color to plot again --- src/Components/Plot.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Components/Plot.ts b/src/Components/Plot.ts index cf38e56..de7f612 100644 --- a/src/Components/Plot.ts +++ b/src/Components/Plot.ts @@ -11,6 +11,7 @@ type PlotOptions = { coefficients?: Coefficients; plotRange?: number; plotBetween: [number, number] | undefined; + color: number; }; const defaultPlotOptions = { @@ -19,6 +20,7 @@ const defaultPlotOptions = { lineWidth: 4, coefficients: {}, plotBetween: undefined, + color: undefined, }; type Coefficients = { @@ -50,7 +52,6 @@ class Plot extends Component { constructor(func: string, options?: PlotOptions) { super(); this.setFuncName(); - this.setColor(); const { numPoints = 1000, @@ -58,8 +59,13 @@ class Plot extends Component { lineWidth = 1, coefficients = {}, plotBetween = undefined, + color, } = { ...defaultPlotOptions, ...options }; - + if (!color) { + this.setColor(); + } else { + this.color = color; + } const minX = (-this.PLOTRANGE / 1) * 2 + 0; const maxX = (this.PLOTRANGE / 1) * 2 + 0; const initialCurve = new CatmullRomCurve3(