modify draw style
Browse files51 unmodified lines525354555657581 unmodified line606162636465664 unmodified lines717273747576771 unmodified line7980818283843 unmodified lines88899091929394959697989910025 unmodified lines126127128129130131123 unmodified lines25525625725825926026126251 unmodified lines}function drawBodyPose(candidate, subset) {const stickwidth = 4;const limbSeq = [[2, 3], [2, 6], [3, 4], [4, 5], [6, 7], [7, 8], [2, 9], [9, 10],[10, 11], [2, 12], [12, 13], [13, 14], [2, 1], [1, 15], [15, 17],[1, 16], [16, 18], [3, 17], [6, 18]];1 unmodified lineconst colors = [[255, 0, 0], [255, 85, 0], [255, 170, 0], [255, 255, 0], [170, 255, 0], [85, 255, 0], [0, 255, 0],[0, 255, 85], [0, 255, 170], [0, 255, 255], [0, 170, 255], [0, 85, 255], [0, 0, 255], [85, 0, 255],[170, 0, 255], [255, 0, 255], [255, 0, 170], [255, 0, 85]];for (let i = 0; i < 17; i++) {for (let n = 0; n < subset.length; n++) {const index0 = subset[n][limbSeq[i][0]-1];4 unmodified linesconst [X0, Y0] = candidate[index0].slice(0, 2);const [X1, Y1] = candidate[index1].slice(0, 2);ctx.beginPath();ctx.lineWidth=stickwidth;ctx.strokeStyle = `rgb(${colors[i].join(',')})`;ctx.moveTo(X0, Y0);ctx.lineTo(X1, Y1);1 unmodified line}}ctx.font = '12px serif';for (let i = 0; i < 18; i++) {for (let n = 0; n < subset.length; n++) {3 unmodified lines}const [x, y] = candidate[index].slice(0, 2);ctx.beginPath();ctx.arc(x, y, 4, 0, 2 * Math.PI);ctx.fillStyle = `rgb(${colors[i].join(',')})`;ctx.fill();ctx.fillStyle = 'rgb(255,255,255)'// ctx.fillText(index, x-3, y+4);}}}function drawUI() {25 unmodified lines}let dragRange = 64;// ドラッグ中に座標を保持するための変数let isDragging = false;123 unmodified linesfunction handleMouseUp(event) { isDragging = false; }document.addEventListener("keydown", (event) => {if (event.code == "BracketLeft") {dragRange = Math.max(1, dragRange - 8);}if (event.code == "BracketRight") {dragRange = Math.min(256, dragRange + 8);}keyDownFlags[event.code] = true;Redraw();});51 unmodified lines525354555657581 unmodified line606162636465666768694 unmodified lines747576777879801 unmodified line828384858687883 unmodified lines929394959697989910010110210310410510625 unmodified lines132133134135136137138123 unmodified lines26226326426526626726826951 unmodified lines}function drawBodyPose(candidate, subset) {const stickWidth = 6;const limbSeq = [[2, 3], [2, 6], [3, 4], [4, 5], [6, 7], [7, 8], [2, 9], [9, 10],[10, 11], [2, 12], [12, 13], [13, 14], [2, 1], [1, 15], [15, 17],[1, 16], [16, 18], [3, 17], [6, 18]];1 unmodified lineconst colors = [[255, 0, 0], [255, 85, 0], [255, 170, 0], [255, 255, 0], [170, 255, 0], [85, 255, 0], [0, 255, 0],[0, 255, 85], [0, 255, 170], [0, 255, 255], [0, 170, 255], [0, 85, 255], [0, 0, 255], [85, 0, 255],[170, 0, 255], [255, 0, 255], [255, 0, 170], [255, 0, 85]];ctx.globalAlpha = 0.7;// edgefor (let i = 0; i < 17; i++) {for (let n = 0; n < subset.length; n++) {const index0 = subset[n][limbSeq[i][0]-1];4 unmodified linesconst [X0, Y0] = candidate[index0].slice(0, 2);const [X1, Y1] = candidate[index1].slice(0, 2);ctx.beginPath();ctx.lineWidth=stickWidth;ctx.strokeStyle = `rgb(${colors[i].join(',')})`;ctx.moveTo(X0, Y0);ctx.lineTo(X1, Y1);1 unmodified line}}// nodectx.font = '12px serif';for (let i = 0; i < 18; i++) {for (let n = 0; n < subset.length; n++) {3 unmodified lines}const [x, y] = candidate[index].slice(0, 2);ctx.beginPath();ctx.arc(x, y, stickWidth*1.2, 0, 2 * Math.PI);ctx.fillStyle = `rgb(${colors[i].join(',')})`;ctx.fill();ctx.fillStyle = 'rgb(255,255,255)'// ctx.fillText(index, x-3, y+4);}}ctx.globalAlpha = 1.0;}function drawUI() {25 unmodified lines}let dragRange = 64;let dragRangeDelta = 16;// ドラッグ中に座標を保持するための変数let isDragging = false;123 unmodified linesfunction handleMouseUp(event) { isDragging = false; }document.addEventListener("keydown", (event) => {if (event.code == "BracketLeft") {dragRange = Math.max(dragRangeDelta, dragRange - dragRangeDelta);}if (event.code == "BracketRight") {dragRange = Math.min(512, dragRange + dragRangeDelta);}keyDownFlags[event.code] = true;Redraw();});
static/poseEditor.js+13-6