switching colors with opacity now works

master
Mark MacKay 2021-04-15 20:48:37 -05:00
parent 4574d2d0a1
commit b9f2640b3d
2 changed files with 7 additions and 18 deletions

View File

@ -213,19 +213,6 @@ MD.PaintBox = function(container, type){
}); });
$('#tool_switch').on("click touchstart", function(){ $('#tool_switch').on("click touchstart", function(){
var stroke_rect = document.querySelector('#tool_stroke rect'); editor.switchPaint();
$("#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 = editor.paintBox.stroke.getPaint(stroke_color, stroke_opacity, "stroke");
var fill = editor.paintBox.fill.getPaint(fill_color, fill_opacity, "fill");
editor.paintBox.fill.setPaint(stroke, true);
editor.paintBox.stroke.setPaint(fill, true);
}); });
})(); })();

View File

@ -120,10 +120,12 @@ MD.Editor = function(){
var fill_rect = document.querySelector('#tool_fill rect'); var fill_rect = document.querySelector('#tool_fill rect');
var fill_color = fill_rect.getAttribute("fill"); var fill_color = fill_rect.getAttribute("fill");
var stroke_color = stroke_rect.getAttribute("fill"); var stroke_color = stroke_rect.getAttribute("fill");
var stroke_opacity = parseFloat(stroke_rect.getAttribute("stroke-opacity")); var stroke_opacity = parseFloat(stroke_rect.getAttribute("opacity"));
if (isNaN(stroke_opacity)) {stroke_opacity = 100;} if (isNaN(stroke_opacity)) {stroke_opacity = 1;}
var fill_opacity = parseFloat(fill_rect.getAttribute("fill-opacity")); var fill_opacity = parseFloat(fill_rect.getAttribute("opacity"));
if (isNaN(fill_opacity)) {fill_opacity = 100;} if (isNaN(fill_opacity)) {fill_opacity = 1;}
stroke_opacity *= 100;
fill_opacity *= 100;
var stroke = editor.paintBox.stroke.getPaint(stroke_color, stroke_opacity, "stroke"); var stroke = editor.paintBox.stroke.getPaint(stroke_color, stroke_opacity, "stroke");
var fill = editor.paintBox.fill.getPaint(fill_color, fill_opacity, "fill"); var fill = editor.paintBox.fill.getPaint(fill_color, fill_opacity, "fill");
editor.paintBox.fill.setPaint(stroke, true); editor.paintBox.fill.setPaint(stroke, true);