From 9c48896059f8a5c23a9ee450f26ddbc407acaaa6 Mon Sep 17 00:00:00 2001 From: Mark MacKay Date: Mon, 22 Feb 2021 09:01:18 -0600 Subject: [PATCH] color box switch works now --- src/js/PaintBox.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/js/PaintBox.js b/src/js/PaintBox.js index dc2cc19..1e71ff5 100644 --- a/src/js/PaintBox.js +++ b/src/js/PaintBox.js @@ -1,5 +1,5 @@ MD.PaintBox = function(container, type){ - + var _self = this; var colorPicker = function(elem) { var picker = elem[0].id == 'stroke_color' ? 'stroke' : 'fill'; var is_background = elem[0].id == "canvas_color" @@ -59,6 +59,23 @@ MD.PaintBox = function(container, type){ colorPicker($('#canvas_color')); }); + $('#tool_switch').on("click touchstart", function(){ + var stroke_rect = document.querySelector('#tool_stroke rect'); + $("#tool_stroke").toggleClass('active') + $("#tool_fill").toggleClass('active') + var fill_rect = document.querySelector('#tool_fill rect'); + var fill_color = fill_rect.getAttribute("fill"); + var stroke_color = stroke_rect.getAttribute("fill"); + var stroke_opacity = parseFloat(stroke_rect.getAttribute("stroke-opacity")); + if (isNaN(stroke_opacity)) {stroke_opacity = 100;} + var fill_opacity = parseFloat(fill_rect.getAttribute("fill-opacity")); + if (isNaN(fill_opacity)) {fill_opacity = 100;} + var stroke = _self.getPaint(stroke_color, stroke_opacity, "stroke"); + var fill = _self.getPaint(fill_color, fill_opacity, "fill"); + editor.paintBox.fill.setPaint(stroke, true); + editor.paintBox.stroke.setPaint(fill, true); + }); + function createBackground(fill) { const res = svgCanvas.getResolution(); svgCanvas.createLayer("background");