improve color palette in dark mode

This commit is contained in:
Stewart Allen 2022-01-22 10:55:00 -05:00
commit d40be9cdc0
7 changed files with 62 additions and 39 deletions

View file

@ -16,6 +16,7 @@ self.kiri.loader.push(function() {
speedIndex = 0,
speedLabel,
speed,
color = 0,
pauseButton,
playButton,
posOffset = { x:0, y:0, z:0 };
@ -129,7 +130,7 @@ self.kiri.loader.push(function() {
const mat = new THREE.LineBasicMaterial({
transparent: true,
opacity: 0.75,
color: 0
color
});
const mesh = new THREE.LineSegments(geo, mat);
WORLD.add(mesh);
@ -203,6 +204,7 @@ self.kiri.loader.push(function() {
if (KIRI.client)
KIRI.client.animate_setup = function(settings, ondone) {
color = settings.controller.dark ? 0x888888 : 0;
unitScale = settings.controller.units === 'in' ? 1/25.4 : 1;
KIRI.client.send("animate_setup", {settings}, ondone);
};

View file

@ -42,7 +42,7 @@
let { op, state } = this;
let { settings, widget, sliceAll } = state;
let { updateToolDiams, thruHoles, tabs, cutTabs } = state;
let { bounds, zMax, ztOff } = state;
let { bounds, zMax, ztOff, color } = state;
let { stock } = settings;
let toolDiam = new CAM.Tool(settings, op.tool).fluteDiameter();
@ -80,7 +80,7 @@
let slice = newSlice(z);
this.lines = slice.camLines = [ path ];
slice.output()
.setLayer("level", {face: 0, line: 0})
.setLayer("level", {face: color, line: color})
.addPolys(this.lines);
sliceAll.push(slice);
}
@ -104,7 +104,7 @@
slice(progress) {
let { op, state } = this;
let { settings, widget, slicer, sliceAll, unsafe } = state;
let { settings, widget, slicer, sliceAll, unsafe, color } = state;
let { updateToolDiams, thruHoles, tabs, cutTabs, cutPolys } = state;
let { tshadow, shadowTop, ztOff, zBottom, zMax } = state;
let { process, stock } = settings;
@ -139,7 +139,7 @@
slice.z = z;
slice.camLines = POLY.setZ(facing.clone(true), slice.z);
slice.output()
.setLayer("face", {face: 0, line: 0})
.setLayer("face", {face: color, line: color})
.addPolys(slice.camLines);
sliceAll.push(slice);
camFaces.push(slice);
@ -307,7 +307,7 @@
// .setLayer("rough shell", {line: 0xaa0000})
// .addPolys(shell);
slice.output()
.setLayer("roughing", {face: 0, line: 0})
.setLayer("roughing", {face: color, line: color})
.addPolys(offset);
progress(0.5 + (index / slices.length) * 0.5);
});
@ -411,7 +411,7 @@
slice(progress) {
let { op, state } = this;
let { settings, widget, slicer, sliceAll, tshadow, thruHoles, unsafe } = state;
let { settings, widget, slicer, sliceAll, tshadow, thruHoles, unsafe, color } = state;
let { updateToolDiams, zThru, zBottom, shadowTop, tabs, cutTabs, cutPolys } = state;
let { process, stock } = settings;
@ -550,7 +550,7 @@
.setLayer("slice", {line: 0xaaaa00}, false)
.addPolys(slice.topPolys())
slice.output()
.setLayer("outline", {face: 0, line: 0})
.setLayer("outline", {face: color, line: color})
.addPolys(offset);
});
@ -916,7 +916,8 @@
slice(progress) {
let { op, state } = this;
let { settings, sliceAll, tslices, updateToolDiams, zBottom, zThru, thruHoles } = state;
let { settings, sliceAll, tslices, updateToolDiams } = state;
let { zBottom, zThru, thruHoles, color } = state;
let drills = [],
drillTool = new CAM.Tool(settings, op.tool),
@ -970,7 +971,7 @@
}
slice.camLines = [ drill ];
slice.output()
.setLayer("drill", {face: 0, line: 0})
.setLayer("drill", {face: color, line: color})
.addPolys(drill);
sliceAll.push(slice);
sliceOut.push(slice);
@ -996,7 +997,7 @@
slice(progress) {
let { op, state } = this;
let { settings, widget, bounds, sliceAll, zMax, zThru } = state;
let { settings, widget, bounds, sliceAll, zMax, zThru, color } = state;
let { updateToolDiams } = state;
let tool = new CAM.Tool(settings, op.tool);
@ -1114,7 +1115,7 @@
});
slice.camLines = polys;
slice.output()
.setLayer("register", {face: 0, line: 0})
.setLayer("register", {face: color, line: color})
.addPolys(polys);
sliceAll.push(slice);
sliceOut.push(slice);

View file

@ -42,7 +42,8 @@
speed: false,
moves: true,
other: "moving",
action: "milling"
action: "milling",
maxspeed: settings.process.camFastFeed || 6000
});
return print.render;

View file

@ -40,6 +40,8 @@
minToolDiam = Infinity,
maxToolDiam = -Infinity,
thruHoles,
dark = settings.controller.dark ? true : false,
color = dark ? 0xbbbbbb : 0,
tabs = widget.anno.tab,
unsafe = proc.camExpertFast,
units = settings.controller.units === 'in' ? 25.4 : 1;
@ -117,7 +119,9 @@
ztOff,
zMax,
zTop,
unsafe
unsafe,
color,
dark
};
let opList = [

View file

@ -20,7 +20,7 @@
class Topo {
constructor(opt = {}) {
let { state, contour, onupdate, ondone } = opt;
let { widget, settings, tshadow, center, tabs } = opt.state;
let { widget, settings, tshadow, center, tabs, color } = opt.state;
let density = parseInt(settings.controller.animesh || 100) * 2500,
axis = contour.axis.toLowerCase(),
@ -263,7 +263,7 @@
if (nz > gridv) {
gridv = data[gridi] = Math.max(nz, zMin);
if (debug_topo) slice.output()
.setLayer("topo", {face: 0, line: 0})
.setLayer("topo", {face: color, line: color})
.addLine(
newPoint(p1.x, y, 0),
newPoint(p1.x, y, gridv)
@ -338,7 +338,7 @@
newslices.push(slice);
slice.camLines = sliceout;
slice.output()
.setLayer("contour y", {face: 0, line: 0})
.setLayer("contour y", {face: color, line: color})
.addPolys(sliceout);
}
onupdate(++stepsTaken, stepsTotal, "contour y");
@ -375,7 +375,7 @@
newslices.push(slice);
slice.camLines = sliceout;
slice.output()
.setLayer("contour x", {face: 0, line: 0})
.setLayer("contour x", {face: color, line: color})
.addPolys(sliceout);
}
onupdate(++stepsTaken, stepsTotal, "contour x");

View file

@ -733,7 +733,9 @@
}
FDM.rateToColor = function(rate, max) {
return currentColorFunction(rate/max, 1, 0.85);
return current.print.settings.controller.dark ?
darkColorFunction(rate/max, 1, 0.85) :
currentColorFunction(rate/max, 1, 0.85);
};
FDM.prepareRender = function(levels, update, opts = {}) {
@ -767,7 +769,7 @@
};
let minspd = Infinity;
let maxspd = 0;
let maxspd = opts.maxspeed || 0;
let maxtool = [];
for (let level of levels) {
@ -961,12 +963,13 @@
}
const colorFunctions = FDM.colorFunctions = {
default: hsv2rgb.bind({ seg: 5, fn: color5 }),
default: hsv2rgb.bind({ seg: 4, fn: color4d }),
simple: hsv2rgb.bind({ seg: 3, fn: color4 }),
dark: hsv2rgb.bind({ seg: 3, fn: color3 })
dark: hsv2rgb.bind({ seg: 4, fn: color4d })
};
let currentColorFunction = colorFunctions.default;
let darkColorFunction = colorFunctions.dark;
// hsv values all = 0 to 1
function hsv2rgb(h, s, v) {
@ -1015,6 +1018,38 @@
}
}
function color4d(rgb, inc, seg) {
const dec = 1 - inc;
switch (seg) {
case 0:
rgb.r = 1;
rgb.g = inc;
rgb.b = 0;
break;
case 1:
rgb.r = dec;
rgb.g = 1;
rgb.b = 0;
break;
case 2:
rgb.r = 0;
rgb.g = dec;
rgb.b = inc;
break;
case 3:
rgb.r = inc * 0.85;
rgb.g = 0;
rgb.b = 1;
break;
case 4:
rgb.r = 0.85;
rgb.g = 0;
rgb.b = 1;
break;
}
}
function color4(rgb, inc, seg) {
const dec = 1 - inc;
switch (seg) {
@ -1041,25 +1076,4 @@
}
}
function color3(rgb, inc, seg) {
const dec = 1 - inc;
switch (seg) {
case 0:
rgb.r = dec;
rgb.g = inc;
rgb.b = 0;
break;
case 1:
rgb.r = 0;
rgb.g = dec;
rgb.b = inc;
break;
case 2:
rgb.r = inc/2;
rgb.g = 0;
rgb.b = dec/2 + 0.5;
break;
}
}
})();

View file

@ -43,6 +43,7 @@
function slice(settings, widget, onupdate, ondone) {
let proc = settings.process;
let offset = proc.laserOffset;
let color = settings.controller.dark ? 0xbbbbbb : 0;
if (proc.laserSliceHeight < 0) {
return ondone("invalid slice height");
@ -59,7 +60,7 @@
let offsets = slice.offset = offset ?
POLY.offset(tops, offset, {z: slice.z, miter: 2 / offset}) : tops;
slice.output().setLayer("layer", { line: 0x888800 }).addPolys(tops);
slice.output().setLayer("cut").addPolys(offsets);
slice.output().setLayer("cut", { line: color }).addPolys(offsets);
onupdate(0.80 + (index/slices.length) * 0.20);
});
ondone();