From 7e33ea2bdc97191c5a736d986ceb4f30ccdff9f9 Mon Sep 17 00:00:00 2001 From: JFH <20402845+jfhenon@users.noreply.github.com> Date: Fri, 1 Jan 2021 12:35:16 +0100 Subject: [PATCH] picker starts withthe right color --- src/editor/components/PaintBox.js | 8 +++----- src/editor/panels/BottomPanelHandlers.js | 3 +++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/editor/components/PaintBox.js b/src/editor/components/PaintBox.js index eb2a89e2..e5979386 100644 --- a/src/editor/components/PaintBox.js +++ b/src/editor/components/PaintBox.js @@ -6,15 +6,13 @@ class PaintBox { /** * @param {string|Element|external:jQuery} container * @param {"fill"} type - * @param {string} color - * @param {number} opacity */ - constructor (container, type, color, opacity) { + constructor (container, type) { // set up gradients to be used for the buttons const svgdocbox = new DOMParser().parseFromString( ` + fill="#000000" opacity="1" width="22" height="22"/> `, 'text/xml' @@ -26,7 +24,7 @@ class PaintBox { this.rect = docElem.firstElementChild; this.defs = docElem.getElementsByTagName('defs')[0]; this.grad = this.defs.firstElementChild; - this.paint = new $.jGraduate.Paint({solidColor: color}); + // this.paint = new $.jGraduate.Paint({solidColor: color}); this.type = type; } diff --git a/src/editor/panels/BottomPanelHandlers.js b/src/editor/panels/BottomPanelHandlers.js index dc812f03..72d69554 100644 --- a/src/editor/panels/BottomPanelHandlers.js +++ b/src/editor/panels/BottomPanelHandlers.js @@ -187,6 +187,9 @@ class BottomPanelHandlers { $id('stroke_linecap').addEventListener('change', (evt) => this.handleStrokeAttr.bind(this)('stroke-linecap', evt)); $id('opacity_dropdown').addEventListener('change', this.handleOpacity.bind(this)); $id('palette').addEventListener('change', this.handlePalette.bind(this)); + const {curConfig} = this.editor.configObj; + $id('fill_color').setPaint(new $.jGraduate.Paint({alpha: 100, solidColor: curConfig.initFill.color})); + $id('stroke_color').setPaint(new $.jGraduate.Paint({alpha: 100, solidColor: curConfig.initStroke.color})); } }