redo colors again
This commit is contained in:
parent
1d3a76c982
commit
071955ea7c
5 changed files with 54 additions and 33 deletions
|
|
@ -221,6 +221,10 @@
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PRO.miter = function() {
|
||||||
|
// todo - to eliminate path sharps in renders
|
||||||
|
};
|
||||||
|
|
||||||
PRO.createConvexHull = function(points) {
|
PRO.createConvexHull = function(points) {
|
||||||
function removeMiddle(a, b, c) {
|
function removeMiddle(a, b, c) {
|
||||||
let cross = (a.x - b.x) * (c.y - b.y) - (a.y - b.y) * (c.x - b.x);
|
let cross = (a.x - b.x) * (c.y - b.y) - (a.y - b.y) * (c.x - b.x);
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ KIRI.work = {
|
||||||
update(reply.progress, reply.message);
|
update(reply.progress, reply.message);
|
||||||
}
|
}
|
||||||
if (reply.done) {
|
if (reply.done) {
|
||||||
done(reply.output, reply.speedColors);
|
done(reply.output, reply.maxSpeed);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -182,6 +182,12 @@ KIRI.work = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
colors : function(colors, max, done) {
|
||||||
|
send("colors", { colors, max }, function(reply) {
|
||||||
|
done(reply);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
parse : function(args, progress, done) {
|
parse : function(args, progress, done) {
|
||||||
// have to do this client side because DOMParser is not in workers
|
// have to do this client side because DOMParser is not in workers
|
||||||
if (args.type === 'svg') {
|
if (args.type === 'svg') {
|
||||||
|
|
|
||||||
|
|
@ -664,24 +664,30 @@
|
||||||
// UI.setMenu.style.display = andmenu ? 'none' : 'flex';
|
// UI.setMenu.style.display = andmenu ? 'none' : 'flex';
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSpeeds(speedColors) {
|
function updateSpeeds(maxSpeed) {
|
||||||
UI.speeds.style.display =
|
UI.speeds.style.display =
|
||||||
settings.mode !== 'SLA' &&
|
settings.mode !== 'SLA' &&
|
||||||
settings.mode !== 'LASER' &&
|
settings.mode !== 'LASER' &&
|
||||||
viewMode === VIEWS.PREVIEW &&
|
viewMode === VIEWS.PREVIEW &&
|
||||||
UI.showSpeeds.checked ? 'block' : '';
|
UI.showSpeeds.checked ? 'block' : '';
|
||||||
if (speedColors) {
|
if (maxSpeed) {
|
||||||
const list = [];
|
const colors = [];
|
||||||
Object.keys(speedColors).map(v => parseInt(v)).sort((a,b) => b-a).forEach(speed => {
|
for (let i=0; i<= maxSpeed; i += maxSpeed/20) {
|
||||||
const color = speedColors[speed];
|
colors.push(Math.round(Math.max(i,1)));
|
||||||
const hex = color.toString(16).padStart(6,0);
|
}
|
||||||
const r = (color >> 16) & 0xff;
|
KIRI.client.colors(colors, maxSpeed, speedColors => {
|
||||||
const g = (color >> 8) & 0xff;
|
const list = [];
|
||||||
const b = (color >> 0) & 0xff;
|
Object.keys(speedColors).map(v => parseInt(v)).sort((a,b) => b-a).forEach(speed => {
|
||||||
const style = `background-color:#${hex}`;
|
const color = speedColors[speed];
|
||||||
list.push(`<label style="${style}">${speed}</label>`);
|
const hex = color.toString(16).padStart(6,0);
|
||||||
|
const r = (color >> 16) & 0xff;
|
||||||
|
const g = (color >> 8) & 0xff;
|
||||||
|
const b = (color >> 0) & 0xff;
|
||||||
|
const style = `background-color:#${hex}`;
|
||||||
|
list.push(`<label style="${style}">${speed}</label>`);
|
||||||
|
});
|
||||||
|
UI.speedbar.innerHTML = list.join('');
|
||||||
});
|
});
|
||||||
UI.speedbar.innerHTML = list.join('');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -824,7 +830,7 @@
|
||||||
|
|
||||||
KIRI.client.prepare(settings, function(progress, message) {
|
KIRI.client.prepare(settings, function(progress, message) {
|
||||||
API.show.progress(progress, message);
|
API.show.progress(progress, message);
|
||||||
}, function (output, speedColors) {
|
}, function (output, maxSpeed) {
|
||||||
API.show.progress(0);
|
API.show.progress(0);
|
||||||
if (!isCam) setOpacity(0);
|
if (!isCam) setOpacity(0);
|
||||||
|
|
||||||
|
|
@ -844,7 +850,7 @@
|
||||||
SPACE.update();
|
SPACE.update();
|
||||||
updateSliderMax(true);
|
updateSliderMax(true);
|
||||||
setVisibleLayer(-1, 0);
|
setVisibleLayer(-1, 0);
|
||||||
updateSpeeds(speedColors);
|
updateSpeeds(maxSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof(callback) === 'function') {
|
if (typeof(callback) === 'function') {
|
||||||
|
|
|
||||||
|
|
@ -128,20 +128,11 @@ KIRI.worker = {
|
||||||
|
|
||||||
const print = current.print || {};
|
const print = current.print || {};
|
||||||
const maxSpeed = print.maxSpeed || undefined;
|
const maxSpeed = print.maxSpeed || undefined;
|
||||||
const thinColor = print.thinColor || false;
|
|
||||||
let speedColors = {};
|
|
||||||
if (maxSpeed) {
|
|
||||||
const FDM = KIRI.driver.FDM;
|
|
||||||
for (let i=0, sd=maxSpeed/19, so=0; i<20; i++) {
|
|
||||||
speedColors[Math.round(so)] = FDM.rateToColor(so, maxSpeed + 1, thinColor);
|
|
||||||
so += sd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
send.done({
|
send.done({
|
||||||
done: true,
|
done: true,
|
||||||
output: KIRI.codec.encode(layers),
|
output: KIRI.codec.encode(layers),
|
||||||
speedColors
|
maxSpeed
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -169,6 +160,15 @@ KIRI.worker = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
colors: function(data, send) {
|
||||||
|
const { colors, max } = data;
|
||||||
|
const colorMap = {};
|
||||||
|
colors.forEach(color => {
|
||||||
|
colorMap[color] = KIRI.driver.FDM.rateToColor(color, max);
|
||||||
|
});
|
||||||
|
send.done(colorMap);
|
||||||
|
},
|
||||||
|
|
||||||
parse: function(args, send) {
|
parse: function(args, send) {
|
||||||
const { settings, code, type } = args;
|
const { settings, code, type } = args;
|
||||||
const origin = settings.origin;
|
const origin = settings.origin;
|
||||||
|
|
|
||||||
|
|
@ -397,8 +397,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FDM.rateToColor = function(rate, max, ext) {
|
FDM.rateToColor = function(rate, max) {
|
||||||
return hsv2rgb({h: rate/max, s:1, v:ext ? 0.7 : 0.8}, ext);
|
return hsv2rgb({h: rate/max, s:1, v:0.85});
|
||||||
};
|
};
|
||||||
|
|
||||||
FDM.prepareRender = function(levels, update, options) {
|
FDM.prepareRender = function(levels, update, options) {
|
||||||
|
|
@ -427,7 +427,7 @@
|
||||||
let current = null;
|
let current = null;
|
||||||
|
|
||||||
function color(point) {
|
function color(point) {
|
||||||
return FDM.rateToColor(point.speed, maxspd, thin);
|
return FDM.rateToColor(point.speed, maxspd);
|
||||||
}
|
}
|
||||||
|
|
||||||
levels.forEach((level, index) => {
|
levels.forEach((level, index) => {
|
||||||
|
|
@ -508,9 +508,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// hsv values all = 0 to 1
|
// hsv values all = 0 to 1
|
||||||
function hsv2rgb(hsv, ext) {
|
function hsv2rgb(hsv) {
|
||||||
const { h, s, v } = hsv;
|
const { h, s, v } = hsv;
|
||||||
const ss = 1 / (ext ? 4 : 3);
|
const ss = 1 / 5;
|
||||||
const seg = Math.floor(h / ss);
|
const seg = Math.floor(h / ss);
|
||||||
const rem = h - (seg * ss);
|
const rem = h - (seg * ss);
|
||||||
const inc = (rem / ss);
|
const inc = (rem / ss);
|
||||||
|
|
@ -525,14 +525,19 @@
|
||||||
case 1:
|
case 1:
|
||||||
rgb.r = dec;
|
rgb.r = dec;
|
||||||
rgb.g = 1;
|
rgb.g = 1;
|
||||||
rgb.b = inc;
|
rgb.b = 0;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
rgb.r = inc;
|
rgb.r = 0;
|
||||||
rgb.g = dec;
|
rgb.g = dec;
|
||||||
rgb.b = 1;
|
rgb.b = inc;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
rgb.r = inc;
|
||||||
|
rgb.g = 0;
|
||||||
|
rgb.b = 1;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
rgb.r = dec;
|
rgb.r = dec;
|
||||||
rgb.g = 0;
|
rgb.g = 0;
|
||||||
rgb.b = dec;
|
rgb.b = dec;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue