diff --git a/src/interface.js b/src/interface.js
index daf405e033d480e768740c0aeef2f9f0f53bc70a..2e6e9b7cb3435e7586f40a89732baedb0467971e 100644
--- a/src/interface.js
+++ b/src/interface.js
@@ -161,9 +161,10 @@ function updateSVG(fromSettingsChange=false) {
globalXMLRoot.setAttribute("viewBox", vb.join(' '));
globalXMLRoot.setAttribute("width", `${(vb[2]/1000).toFixed(3)}mm`);
globalXMLRoot.setAttribute("height", `${(vb[3]/1000).toFixed(3)}mm`);
+ let backgroundElem;
if (!globalSettings.transparent) {
- let backgroundElem = globalXMLRoot.ownerDocument.createElement("rect");
- if (globalSettings.blackAndWhite && layersSorted.length >= 2) {
+ backgroundElem = globalXMLRoot.ownerDocument.createElement("rect");
+ if (globalSettings.blackAndWhite) {
backgroundElem.setAttribute("fill", "rgb(0,0,0)");
} else {
backgroundElem.setAttribute("fill", "rgb(255,255,255)");
@@ -175,6 +176,8 @@ function updateSVG(fromSettingsChange=false) {
globalXMLRoot.appendChild(backgroundElem);
}
+ let only_drills = true;
+
for ([layerName, layerTxt] of layersSorted) {
layerXML = parser.parseFromString(layerTxt, "text/xml");
layerXMLRoot = layerXML.childNodes[0];
@@ -196,13 +199,13 @@ function updateSVG(fromSettingsChange=false) {
// let ty = Number(m[1]) + (layerVB[3]-(yMax-yMin))/2;
if (globalSettings.blackAndWhite) {
g.setAttribute("opacity", 1.0);
- if(layerName === "drill"){
- g.setAttribute("fill", "rgb(0,0,0)");
+ if (layerName === "drill") {
+ g.setAttribute("fill", "rgb(0,0,0)");
g.setAttribute("stroke", "rgb(0,0,0)");
-
} else {
g.setAttribute("fill", "rgb(255,255,255)");
g.setAttribute("stroke", "rgb(255,255,255)");
+ only_drills = false;
}
} else {
g.setAttribute("opacity", layerOpacity);
@@ -220,7 +223,9 @@ function updateSVG(fromSettingsChange=false) {
globalXMLRoot.appendChild(g.cloneNode(true));
}
}
-
+ if (!globalSettings.transparent && globalSettings.blackAndWhite && only_drills) {
+ backgroundElem.setAttribute("fill", "rgb(255,255,255)");
+ }
renderSVG();
}