update sla driver code format
This commit is contained in:
parent
e22fe7d483
commit
ce031cdd84
7 changed files with 1843 additions and 1820 deletions
2
app.js
2
app.js
|
|
@ -432,6 +432,7 @@ const script = {
|
|||
"kiri/pack",
|
||||
"kiri/utils",
|
||||
"kiri/slice",
|
||||
"kiri/print",
|
||||
"kiri/layers",
|
||||
"kiri-mode/fdm/fill",
|
||||
"kiri-mode/fdm/driver",
|
||||
|
|
@ -454,7 +455,6 @@ const script = {
|
|||
"kiri-mode/cam/animate",
|
||||
"kiri-mode/laser/driver",
|
||||
"kiri/widget",
|
||||
"kiri/print",
|
||||
"kiri/codec",
|
||||
"kiri/worker"
|
||||
],
|
||||
|
|
|
|||
|
|
@ -2,14 +2,21 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
(function() {
|
||||
// dep: geo.base
|
||||
// dep: kiri-mode.sla.driver
|
||||
gapp.register("kiri-mode.sla.client", [], (root, exports) => {
|
||||
|
||||
let KIRI = self.kiri,
|
||||
BASE = self.base,
|
||||
UTIL = BASE.util,
|
||||
SLA = KIRI.driver.SLA;
|
||||
const { base, kiri } = root;
|
||||
const { driver } = kiri;
|
||||
const { util } = base;
|
||||
const { SLA } = driver;
|
||||
|
||||
SLA.init = function(kiri, api) {
|
||||
gapp.overlay(SLA, {
|
||||
init,
|
||||
printDownload
|
||||
});
|
||||
|
||||
function init(kiri, api) {
|
||||
api.event.on("mode.set", (mode) => {
|
||||
if (mode === 'SLA') {
|
||||
api.ui.func.preview.classList.add('hide');
|
||||
|
|
@ -17,17 +24,17 @@
|
|||
api.ui.func.preview.classList.remove('hide');
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
SLA.printDownload = function(output, API, names) {
|
||||
function printDownload(output, api, names) {
|
||||
const { file, width, height, layers, volume } = output;
|
||||
const fileroot = names[0] || "print";
|
||||
const filename = `${fileroot}-${new Date().getTime().toString(36)}`;
|
||||
|
||||
API.ajax("/kiri/output-sla.html", html => {
|
||||
API.ui.print.innerHTML = html;
|
||||
api.ajax("/kiri/output-sla.html", html => {
|
||||
api.ui.print.innerHTML = html;
|
||||
|
||||
let settings = API.conf.get(),
|
||||
let settings = api.conf.get(),
|
||||
process = settings.process,
|
||||
device = settings.device,
|
||||
print_sec = (process.slaBaseLayers * process.slaBaseOn) +
|
||||
|
|
@ -68,28 +75,28 @@
|
|||
switch (device.deviceName) {
|
||||
case 'Anycubic.Photon':
|
||||
download.innerText += " .photon";
|
||||
download.onclick = () => { saveFile(API, file, ".photon") };
|
||||
download.onclick = () => { saveFile(api, file, ".photon") };
|
||||
break;
|
||||
case 'Anycubic.Photon.S':
|
||||
download.innerText += " .photons";
|
||||
download.onclick = () => { saveFile(API, file, ".photons") };
|
||||
download.onclick = () => { saveFile(api, file, ".photons") };
|
||||
break;
|
||||
case 'Creality.Halot.Sky':
|
||||
default:
|
||||
download.innerText += " .cxdlp";
|
||||
download.onclick = () => { saveFile(API, file, ".cxdlp") };
|
||||
download.onclick = () => { saveFile(api, file, ".cxdlp") };
|
||||
break;
|
||||
}
|
||||
|
||||
API.modal.show('print');
|
||||
api.modal.show('print');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function saveFile(API, file, ext) {
|
||||
function saveFile(api, file, ext) {
|
||||
saveAs(
|
||||
new Blob([file], { type: "application/octet-stream" }),
|
||||
$('print-filename').value + ext);
|
||||
API.modal.hide();
|
||||
}
|
||||
api.modal.hide();
|
||||
}
|
||||
|
||||
})();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,26 +2,26 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
(function() {
|
||||
// use: kiri.print
|
||||
// use: kiri.worker
|
||||
gapp.register("kiri-mode.sla.driver", [], (root, exports) => {
|
||||
|
||||
if (!self.kiri.driver) self.kiri.driver = { };
|
||||
if (self.kiri.driver.SLA) return;
|
||||
const { kiri } = root
|
||||
const { driver } = kiri;
|
||||
|
||||
const KIRI = self.kiri,
|
||||
SLA = KIRI.driver.SLA = {
|
||||
// init, // src/mode/sla/client.js
|
||||
// slice, // src/mode/sla/slice.js
|
||||
const SLA = driver.SLA = {
|
||||
prepare,
|
||||
// export, // src/mode/sla/export.js
|
||||
// printDownload, // src/mode/sla/client.js
|
||||
legacy: false
|
||||
};
|
||||
};
|
||||
|
||||
if (SLA.legacy) console.log("SLA Driver in Legacy Mode");
|
||||
if (SLA.legacy) {
|
||||
console.log("SLA Driver in Legacy Mode");
|
||||
}
|
||||
|
||||
// runs in worker. would usually be in src/mode/sla/prepare.js
|
||||
function prepare(widgets, settings, update) {
|
||||
self.worker.print = KIRI.newPrint(settings, widgets);
|
||||
// runs in worker. would usually be in src/mode/sla/prepare.js
|
||||
// but the SLA driver skips the prepare step because there is no path routing
|
||||
function prepare(widgets, settings, update) {
|
||||
root.worker.print = kiri.newPrint(settings, widgets);
|
||||
if (!SLA.wasm) {
|
||||
fetch('/wasm/kiri-sla.wasm')
|
||||
.then(response => response.arrayBuffer())
|
||||
|
|
@ -44,6 +44,6 @@
|
|||
});
|
||||
}
|
||||
update(1);
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,20 +2,24 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
(function() {
|
||||
// dep: geo.base
|
||||
// dep: kiri-mode.sla.driver
|
||||
// dep: kiri-mode.sla.x_cxdlp
|
||||
// dep: kiri-mode.sla.x_photons
|
||||
gapp.register("kiri-mode.sla.export", [], (root, exports) => {
|
||||
|
||||
let KIRI = self.kiri,
|
||||
BASE = self.base,
|
||||
UTIL = BASE.util,
|
||||
SLA = KIRI.driver.SLA;
|
||||
const { base, kiri } = root
|
||||
const { driver } = kiri;
|
||||
const { util } = base;
|
||||
const { SLA } = driver;
|
||||
|
||||
/**
|
||||
* DRIVER PRINT CONTRACT - runs in worker
|
||||
/**
|
||||
* DRIVER CONTRACT - runs in worker
|
||||
* @param {Object} print state object
|
||||
* @param {Function} online streaming reply
|
||||
* @param {Function} ondone last reply
|
||||
*/
|
||||
SLA.export = function(print, online, ondone) {
|
||||
SLA.export = function(print, online, ondone) {
|
||||
let widgets = print.widgets,
|
||||
settings = print.settings,
|
||||
device = settings.device,
|
||||
|
|
@ -161,10 +165,10 @@
|
|||
}
|
||||
|
||||
console.log('print.export', Date.now() - mark);
|
||||
};
|
||||
};
|
||||
|
||||
function generateCXDLP(print, conf, progress) {
|
||||
function generateCXDLP(print, conf, progress) {
|
||||
console.log({generateCXDLP: print, conf, progress});
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,32 +2,35 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
(function() {
|
||||
// dep: geo.base
|
||||
// dep: geo.point
|
||||
// dep: geo.polygon
|
||||
// dep: geo.polygons
|
||||
// dep: kiri.slice
|
||||
// dep: kiri-mode.sla.driver
|
||||
gapp.register("kiri-mode.sla.slice", [], (root, exports) => {
|
||||
|
||||
let KIRI = self.kiri,
|
||||
BASE = self.base,
|
||||
POLY = BASE.polygons,
|
||||
UTIL = BASE.util,
|
||||
SLA = KIRI.driver.SLA,
|
||||
FDM = KIRI.driver.FDM.share,
|
||||
tracker = UTIL.pwait,
|
||||
newTop = KIRI.newTop,
|
||||
newSlice = KIRI.newSlice,
|
||||
newPoint = BASE.newPoint,
|
||||
newPolygon = BASE.newPolygon,
|
||||
fill_cache;
|
||||
const { base, kiri } = root;
|
||||
const { driver, newSlice, newTop } = kiri;
|
||||
const { util, newPoint, newPolygon, polygons } = base;
|
||||
const { SLA } = driver;
|
||||
|
||||
/**
|
||||
* DRIVER SLICE CONTRACT - runs in worker
|
||||
*
|
||||
const POLY = polygons;
|
||||
const FDM = driver.FDM.share;
|
||||
const tracker = util.pwait;
|
||||
|
||||
let fill_cache;
|
||||
|
||||
/**
|
||||
* DRIVER CONTRACT - runs in worker
|
||||
* @param {Object} settings
|
||||
* @param {Widget} Widget
|
||||
* @param {Function} onupdate (called with % complete and optional message)
|
||||
* @param {Function} ondone (called when complete with an array of Slice objects)
|
||||
*/
|
||||
SLA.slice = function(settings, widget, onupdate, ondone) {
|
||||
SLA.slice = function(settings, widget, onupdate, ondone) {
|
||||
let { process, device, controller } = settings,
|
||||
isConcurrent = controller.threaded && KIRI.minions.concurrent,
|
||||
isConcurrent = controller.threaded && kiri.minions.concurrent,
|
||||
work_total,
|
||||
work_remain;
|
||||
|
||||
|
|
@ -178,7 +181,7 @@
|
|||
let trims = slice.solids || [];
|
||||
traces.appendAll(trims);
|
||||
// slice.unioned = POLY.setZ(POLY.union(traces, undefined, true), slice.z);
|
||||
slice.unioned = POLY.setZ(await KIRI.minions.union(traces), slice.z);
|
||||
slice.unioned = POLY.setZ(await kiri.minions.union(traces), slice.z);
|
||||
} else {
|
||||
slice.unioned = traces;
|
||||
}
|
||||
|
|
@ -211,7 +214,7 @@
|
|||
let bounds = widget.getBoundingBox();
|
||||
let points = widget.getPoints();
|
||||
|
||||
BASE.slice(points, {
|
||||
base.slice(points, {
|
||||
indices: process.indices || process.xray,
|
||||
union: controller.healMesh,
|
||||
debug: process.xray,
|
||||
|
|
@ -221,7 +224,7 @@
|
|||
zInc: height,
|
||||
// slicer function (worker local or minion distributed)
|
||||
slicer(z, points, opts) {
|
||||
return (isConcurrent ? KIRI.minions.sliceZ : BASE.sliceZ)(z, points, opts);
|
||||
return (isConcurrent ? kiri.minions.sliceZ : base.sliceZ)(z, points, opts);
|
||||
},
|
||||
onupdate(v) {
|
||||
return onupdate(0.0 + v * 0.25);
|
||||
|
|
@ -234,9 +237,9 @@
|
|||
});
|
||||
onSliceDone(slices).then(ondone);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
function doRender(widget) {
|
||||
function doRender(widget) {
|
||||
widget.slices.forEach(slice => {
|
||||
const render = slice.output(), lopacity = 0.6, line = 0x010101;
|
||||
|
||||
|
|
@ -264,9 +267,9 @@
|
|||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function computeSupports(widget, process, progress) {
|
||||
function computeSupports(widget, process, progress) {
|
||||
let area = widget.union.reduce((t,p) => { return t + p.areaDeep() }, 0),
|
||||
perim = widget.union.reduce((t,p) => { return t + p.perimeter() }, 0),
|
||||
slices = widget.slices,
|
||||
|
|
@ -381,9 +384,9 @@
|
|||
slice.supports = POLY.union(slice.supports, 0, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function projectSupport(process, slice, poly, size, spacing) {
|
||||
function projectSupport(process, slice, poly, size, spacing) {
|
||||
let flat = poly.circularityDeep() > 0.1,
|
||||
arr = [ poly ];
|
||||
|
||||
|
|
@ -459,9 +462,9 @@
|
|||
// inset polygon for flat area support
|
||||
if (flat) poly.offset(Math.max(0.2, 1 - process.slaSupportDensity), arr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function projectPillar(process, slice, point, size, track) {
|
||||
function projectPillar(process, slice, point, size, track) {
|
||||
if (!slice.supports) slice.supports = [];
|
||||
if (!slice.pillars) slice.pillars = [];
|
||||
|
||||
|
|
@ -573,9 +576,9 @@
|
|||
projectPillar(process, slice.down, nextpoint, Math.min(size, max), track);
|
||||
}
|
||||
return track;
|
||||
}
|
||||
}
|
||||
|
||||
function fillPolys(slice, settings) {
|
||||
function fillPolys(slice, settings) {
|
||||
let process = settings.process,
|
||||
device = settings.device,
|
||||
polys = slice.unioned,
|
||||
|
|
@ -602,7 +605,7 @@
|
|||
if (!cached && seq_c !== 1)
|
||||
for (let x=start_x; x<end_x; x += step_x) {
|
||||
fill.push(
|
||||
BASE.newPolygon().centerRectangle({
|
||||
base.newPolygon().centerRectangle({
|
||||
x: x + step_x/2,
|
||||
y: 0,
|
||||
z: slice.z
|
||||
|
|
@ -613,7 +616,7 @@
|
|||
if (!cached && seq_c !== 3)
|
||||
for (let y=start_y; y<end_y; y += step_y) {
|
||||
fill.push(
|
||||
BASE.newPolygon().centerRectangle({
|
||||
base.newPolygon().centerRectangle({
|
||||
x: 0,
|
||||
y: y + step_y/2,
|
||||
z: slice.z
|
||||
|
|
@ -632,9 +635,9 @@
|
|||
fill = POLY.union(slice.unioned.appendAll(fill), 0, true);
|
||||
|
||||
slice.unioned = fill;
|
||||
}
|
||||
}
|
||||
|
||||
function pixAt(png,x,y) {
|
||||
function pixAt(png,x,y) {
|
||||
let idx = (x + png.width * y) * 4;
|
||||
let dat = png.data;
|
||||
return [
|
||||
|
|
@ -643,9 +646,9 @@
|
|||
dat[idx++],
|
||||
dat[idx++]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
function averageBlock(png,x1,y1,x2,y2) {
|
||||
function averageBlock(png,x1,y1,x2,y2) {
|
||||
let val = [0, 0, 0, 0], count = 0, x, y, z, v2;
|
||||
for (x=x1; x<x2; x++) {
|
||||
for (y=y1; y<y2; y++) {
|
||||
|
|
@ -660,9 +663,9 @@
|
|||
val[z] = Math.abs(val[z] / count);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
};
|
||||
|
||||
function samplePNG(png, width, height) {
|
||||
function samplePNG(png, width, height) {
|
||||
let th = width, tw = height,
|
||||
aspect = width / height, // was fixed at 4/3 for photon
|
||||
ratio = png.width / png.height,
|
||||
|
|
@ -697,6 +700,6 @@
|
|||
}
|
||||
|
||||
return {width, height, data:buf, png};
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
(function() {
|
||||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||
|
||||
const default_values = {
|
||||
"use strict";
|
||||
|
||||
gapp.register("kiri-mode.sla.x_cxdlp", [], (root, exports) => {
|
||||
|
||||
const default_values = {
|
||||
magic1: 'CXSW3DV2',
|
||||
magic2: 'CXSW3DV2',
|
||||
model: 'CL-89',
|
||||
|
|
@ -26,15 +30,15 @@
|
|||
base_light_pwm: 255,
|
||||
base_lift_dist: 5,
|
||||
base_lift_speed: 60
|
||||
};
|
||||
const data_term = 0x0d0a;
|
||||
};
|
||||
const data_term = 0x0d0a;
|
||||
|
||||
// https://github.com/sn4k3/UVtools/blob/v2.20.4/UVtools.Core/FileFormats/CXDLPFile.cs
|
||||
// CL-60 1620 x 2560
|
||||
// CL-89 3840 x 2400
|
||||
// CL-133 3840 x 2160
|
||||
// https://github.com/sn4k3/UVtools/blob/v2.20.4/UVtools.Core/FileFormats/CXDLPFile.cs
|
||||
// CL-60 1620 x 2560
|
||||
// CL-89 3840 x 2400
|
||||
// CL-133 3840 x 2160
|
||||
|
||||
class CXDLP {
|
||||
class CXDLP {
|
||||
constructor() {
|
||||
Object.assign(this, default_values);
|
||||
}
|
||||
|
|
@ -286,9 +290,9 @@
|
|||
|
||||
return output.toBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CXDLP.export = function(params) {
|
||||
CXDLP.export = function(params) {
|
||||
let { settings, width, height, slices } = params;
|
||||
let { thumb, preview1, preview2 } = params;
|
||||
let { device, process } = settings;
|
||||
|
|
@ -328,9 +332,9 @@
|
|||
cxdlp.base_lift_speed = process.slaBasePeelLiftRate * 60;
|
||||
|
||||
return cxdlp.write();
|
||||
};
|
||||
};
|
||||
|
||||
CXDLP.render = function(params) {
|
||||
CXDLP.render = function(params) {
|
||||
let { width, height, index, widgets, scaleX, scaleY } = params;
|
||||
let width2 = width / 2, height2 = height / 2;
|
||||
let array = [];
|
||||
|
|
@ -428,9 +432,9 @@
|
|||
}
|
||||
}
|
||||
return { lines, area };
|
||||
}
|
||||
}
|
||||
|
||||
if (!self.navigator && self.process && self.process.env) {
|
||||
if (!self.navigator && self.process && self.process.env) {
|
||||
let fs = require('fs');
|
||||
eval(fs.readFileSync("src/add/class.js").toString());
|
||||
let args = process.argv.slice(2);
|
||||
|
|
@ -444,7 +448,8 @@
|
|||
layers5: cxdlp.layers.slice(0,5),
|
||||
lines1: cxdlp.get_layer_lines(1)
|
||||
});
|
||||
} else if (self.navigator) {
|
||||
} else if (self.navigator) {
|
||||
self.CXDLP = CXDLP;
|
||||
}
|
||||
}());
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
(function() {
|
||||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||
|
||||
let KIRI = self.kiri,
|
||||
BASE = self.base,
|
||||
UTIL = BASE.util,
|
||||
SLA = KIRI.driver.SLA;
|
||||
"use strict";
|
||||
|
||||
function generatePhoton(print, conf, progress) {
|
||||
gapp.register("kiri-mode.sla.x_photons", [], (root, exports) => {
|
||||
|
||||
const { base, kiri } = root;
|
||||
const { driver } = kiri;
|
||||
const { util } = base;
|
||||
const { SLA } = driver;
|
||||
|
||||
function generatePhoton(print, conf, progress) {
|
||||
let printset = print.settings,
|
||||
process = printset.process,
|
||||
device = printset.device,
|
||||
|
|
@ -162,9 +166,9 @@
|
|||
}, filedat);
|
||||
|
||||
return filebuf;
|
||||
}
|
||||
}
|
||||
|
||||
function generatePhotons(print, conf, progress) {
|
||||
function generatePhotons(print, conf, progress) {
|
||||
let printset = print.settings,
|
||||
process = printset.process,
|
||||
device = printset.device,
|
||||
|
|
@ -249,9 +253,9 @@
|
|||
}
|
||||
|
||||
return filebuf;
|
||||
}
|
||||
}
|
||||
|
||||
function encodeLayers(input, type, progress) {
|
||||
function encodeLayers(input, type, progress) {
|
||||
let layers = [], length = 0, total = 0, count = 0;
|
||||
input.forEach(layer => {
|
||||
layer.subs.forEach(sub => total++);
|
||||
|
|
@ -275,9 +279,9 @@
|
|||
});
|
||||
}
|
||||
return { length, layers };
|
||||
}
|
||||
}
|
||||
|
||||
function rleEncode(data, type) {
|
||||
function rleEncode(data, type) {
|
||||
let maxlen = (type === 'photons') ? 128 : 125,
|
||||
color = data[0],
|
||||
runlen = 1,
|
||||
|
|
@ -301,9 +305,9 @@
|
|||
output.push(rleByte(color, runlen, type));
|
||||
}
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
function rleByte(color, length, type) {
|
||||
function rleByte(color, length, type) {
|
||||
switch (type) {
|
||||
case 'photon':
|
||||
return (length & 0x7f) | ((color << 7) & 0x80);
|
||||
|
|
@ -317,9 +321,9 @@
|
|||
(length & 32 ? 4 : 0) |
|
||||
(length & 64 ? 2 : 0) | color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function rleDecode(data, type) {
|
||||
function rleDecode(data, type) {
|
||||
let bytes = [];
|
||||
if (type === 'photon') {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
|
|
@ -348,10 +352,10 @@
|
|||
}
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
|
||||
// write out a thumbnail image
|
||||
function writePhotonImage(preview, writer) {
|
||||
// write out a thumbnail image
|
||||
function writePhotonImage(preview, writer) {
|
||||
let data = new Uint8Array(preview.data), len = data.byteLength;
|
||||
writer.writeU32(preview.width, true);
|
||||
writer.writeU32(preview.height, true);
|
||||
|
|
@ -369,24 +373,24 @@
|
|||
(((b/4)&0x1f) << 0) ;
|
||||
writer.writeU16(v, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for unbound workers
|
||||
// if (self.WASM) {
|
||||
// let {exports} = wasmInstance;
|
||||
// let heap = new Uint8Array(exports.memory.buffer);
|
||||
// self.wasm = {
|
||||
// heap,
|
||||
// memory: exports.memory,
|
||||
// // heap: wasmMemory,
|
||||
// // memory: memoryBytes,
|
||||
// render: exports.render,
|
||||
// rle_encode: exports.rle_encode
|
||||
// };
|
||||
// } else
|
||||
// for unbound workers
|
||||
// if (self.WASM) {
|
||||
// let {exports} = wasmInstance;
|
||||
// let heap = new Uint8Array(exports.memory.buffer);
|
||||
// self.wasm = {
|
||||
// heap,
|
||||
// memory: exports.memory,
|
||||
// // heap: wasmMemory,
|
||||
// // memory: memoryBytes,
|
||||
// render: exports.render,
|
||||
// rle_encode: exports.rle_encode
|
||||
// };
|
||||
// } else
|
||||
|
||||
// new WebAssembly rasterizer
|
||||
function renderLayerWasm(params) {
|
||||
// new WebAssembly rasterizer
|
||||
function renderLayerWasm(params) {
|
||||
let { width, height, index, widgets, scaleX, scaleY, masks } = params;
|
||||
let width2 = width / 2, height2 = height / 2;
|
||||
let array = [];
|
||||
|
|
@ -472,10 +476,10 @@
|
|||
}
|
||||
|
||||
return { image, layers, end: count === 0, area };
|
||||
}
|
||||
}
|
||||
|
||||
// legacy JS-only rasterizer uses OffscreenCanvas
|
||||
function renderLayer(params) {
|
||||
// legacy JS-only rasterizer uses OffscreenCanvas
|
||||
function renderLayer(params) {
|
||||
let {width, height, index, widgets, scaleX, scaleY} = params;
|
||||
let layer = new OffscreenCanvas(height,width);
|
||||
let opt = { scaleX, scaleY, width, height, width2: width/2, height2: height/2 };
|
||||
|
|
@ -515,9 +519,9 @@
|
|||
red[i] = data[i*4];
|
||||
}
|
||||
return { image: red, end: count === 0, area };
|
||||
}
|
||||
}
|
||||
|
||||
function polyout(poly, ctx, opt) {
|
||||
function polyout(poly, ctx, opt) {
|
||||
let { scaleX, scaleY, width, height, width2, height2 } = opt;
|
||||
poly.forEachPoint((p,i) => {
|
||||
if (i === 0) {
|
||||
|
|
@ -527,13 +531,13 @@
|
|||
}
|
||||
}, true);
|
||||
ctx.closePath();
|
||||
}
|
||||
}
|
||||
|
||||
self.photon = {
|
||||
self.photon = {
|
||||
generatePhoton,
|
||||
generatePhotons,
|
||||
renderLayer,
|
||||
renderLayerWasm
|
||||
};
|
||||
};
|
||||
|
||||
})();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue