picker starts withthe right color

This commit is contained in:
JFH
2021-01-01 12:35:16 +01:00
parent 9c0dedb89a
commit 7e33ea2bdc
2 changed files with 6 additions and 5 deletions

View File

@@ -6,15 +6,13 @@ class PaintBox {
/** /**
* @param {string|Element|external:jQuery} container * @param {string|Element|external:jQuery} container
* @param {"fill"} type * @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 // set up gradients to be used for the buttons
const svgdocbox = new DOMParser().parseFromString( const svgdocbox = new DOMParser().parseFromString(
`<svg xmlns="http://www.w3.org/2000/svg"> `<svg xmlns="http://www.w3.org/2000/svg">
<rect <rect
fill="#${color}" opacity="${opacity}" width="22" height="22"/> fill="#000000" opacity="1" width="22" height="22"/>
<defs><linearGradient id="gradbox_${PaintBox.ctr++}"/></defs> <defs><linearGradient id="gradbox_${PaintBox.ctr++}"/></defs>
</svg>`, </svg>`,
'text/xml' 'text/xml'
@@ -26,7 +24,7 @@ class PaintBox {
this.rect = docElem.firstElementChild; this.rect = docElem.firstElementChild;
this.defs = docElem.getElementsByTagName('defs')[0]; this.defs = docElem.getElementsByTagName('defs')[0];
this.grad = this.defs.firstElementChild; this.grad = this.defs.firstElementChild;
this.paint = new $.jGraduate.Paint({solidColor: color}); // this.paint = new $.jGraduate.Paint({solidColor: color});
this.type = type; this.type = type;
} }

View File

@@ -187,6 +187,9 @@ class BottomPanelHandlers {
$id('stroke_linecap').addEventListener('change', (evt) => this.handleStrokeAttr.bind(this)('stroke-linecap', evt)); $id('stroke_linecap').addEventListener('change', (evt) => this.handleStrokeAttr.bind(this)('stroke-linecap', evt));
$id('opacity_dropdown').addEventListener('change', this.handleOpacity.bind(this)); $id('opacity_dropdown').addEventListener('change', this.handleOpacity.bind(this));
$id('palette').addEventListener('change', this.handlePalette.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}));
} }
} }