Update spline_editor.js

This commit is contained in:
kijai 2024-05-06 21:39:22 +03:00
parent 3b999778f0
commit 07ba67864a

View File

@ -207,6 +207,8 @@ app.registerExtension({
function createSplineEditor(context, reset=false) { function createSplineEditor(context, reset=false) {
console.log("creatingSplineEditor") console.log("creatingSplineEditor")
// context menu
function createContextMenu() {
document.addEventListener('contextmenu', function(e) { document.addEventListener('contextmenu', function(e) {
e.preventDefault(); e.preventDefault();
}); });
@ -260,9 +262,9 @@ function createSplineEditor(context, reset=false) {
} }
console.log(dotShape) console.log(dotShape)
updatePath(); updatePath();
}); });
context.menuItem4.addEventListener('click', function(e) { context.menuItem4.addEventListener('click', function(e) {
// Create file input element // Create file input element
const fileInput = document.createElement('input'); const fileInput = document.createElement('input');
fileInput.type = 'file'; fileInput.type = 'file';
@ -293,11 +295,13 @@ context.menuItem4.addEventListener('click', function(e) {
fileInput.click(); fileInput.click();
} }
context.contextMenu.style.display = 'none'; context.contextMenu.style.display = 'none';
}); });
}
var dotShape = "circle"; var dotShape = "circle";
var drawSamplePoints = false; var drawSamplePoints = false;
createContextMenu();
function updatePath() { function updatePath() {
let coords = samplePoints(pathElements[0], points_to_sample, samplingMethod, w); let coords = samplePoints(pathElements[0], points_to_sample, samplingMethod, w);
@ -478,6 +482,7 @@ context.menuItem4.addEventListener('click', function(e) {
} }
}) })
var backgroundImage = vis.add(pv.Image) var backgroundImage = vis.add(pv.Image)
.visible(false)
vis.add(pv.Rule) vis.add(pv.Rule)
.data(pv.range(0, h, 64)) .data(pv.range(0, h, 64))
.bottom(d => d) .bottom(d => d)