add modifier key guide
Browse filesFiles changed (2)
- app.py+17-12
- static/poseEditor.js+32-4
108 unmodified lines1091101111121131141151161171181 unmodified line120121122119120121122123124125126127128129130123124125126127128129130131132133134135136137138108 unmodified lines json = gr.JSON(label="Json")
jsonInput = gr.Textbox(label="Json source", lines=10)
jsonInputBtn = gr.Button(value="Import Json")
with gr.Accordion(label="Notes", open=False):
gr.Markdown("""
Points to note for pseudo-3D rotation: When performing pseudo-3D rotation on the X and Y axes, the projection is converted to 2D and Z-axis information is lost when the mouse button is released. This means that if you finish dragging while the shape is collapsed, you may not be able to restore it to its original state. In such a case, please use the "undo" function.
""")
with gr.Column(scale=2):
html = gr.HTML(html_text)
with gr.Row():1 unmodified line saveBtn = gr.Button(value="Save")
with gr.Column(scale=7):
gr.Markdown("""
- "ctrl + drag" to scale
- "alt + drag" to translate
- "shift + drag" to rotate(move right first, release shift, then up or down)
- "space + drag" to move within range
- "[", "]" or mouse wheel to shrink or expand range
- "ctrl + z", "shift + ctrl + z" to undo, redo
- "a" add new person
- "q + click" to delete person
- "x + drag" to x-axis pseudo-3D rotation
- "c + drag" to y-axis pseudo-3D rotation
- "r + click" to repair
Points to note for pseudo-3D rotation: When performing pseudo-3D rotation on the X and Y axes, the projection is converted to 2D and Z-axis information is lost when the mouse button is released. This means that if you finish dragging while the shape is collapsed, you may not be able to restore it to its original state. In such a case, please use the "undo" function.
- "ctrl + drag" to **scale**
- "alt + drag" to **move**
- "shift + drag" to **rotate** (move right first, release shift, then up or down)
- "space + drag" to **range-move**
- "[", "]" or mouse wheel to shrink or expand **range**
- "ctrl + z", "shift + ctrl + z" to **undo**, **redo**
- "ctrl + N" **add** new person
- "Q + click" to **delete** person
- "X + drag" to **x-axis** pseudo-3D rotation
- "C + drag" to **y-axis** pseudo-3D rotation
- "R + click" to **repair**
When using Q, X, C, R, pressing and dont release until the operation is complete.
""")
width.change(fn=None, inputs=[width], _js="(w) => { resizeCanvas(w,null); }")1 unmodified line23456789250 unmodified lines2602612622612632642652668 unmodified lines275276277278279280281282283284285286287288289290291292293294295296297298299300301302303201 unmodified lines5055065075085095105115125134884895145155165175185195205215225235245254995265275285294 unmodified lines5345355365375385395401 unmodified linevar canvas = null;
var ctx = null;
const wheelDisplayTime = 500;
const limbSeq = [
[1, 2], [2, 3], [3, 4], // 右腕
[1, 5], [5, 6], [6, 7], // 左腕250 unmodified lines
function drawUI() {
if (keyDownFlags['Space'] || keyDownFlags['BracketLeft'] || keyDownFlags['BracketRight'] ||
new Date().getTime() - lastWheeling < 100) {
new Date().getTime() - lastWheeling < wheelDisplayTime) {
ctx.beginPath();
ctx.arc(mouseCursor[0], mouseCursor[1], dragRange, 0, 2 * Math.PI);
ctx.strokeStyle = 'rgb(255,255,255)';8 unmodified lines ctx.lineTo(dragStart[0]+rotateBaseVector[0], dragStart[1]+rotateBaseVector[1]);
ctx.stroke();
}
let operationTextFlags = {
"Space": "Range Move",
"AltLeft": "Body Move",
"AltRight": "Body Move",
"ControlLeft": "Scale",
"ControlRight": "Scale",
"ShiftLeft": "Rotate",
"ShiftRight": "Rotate",
"KeyQ": "Delete",
"KeyX": "X-Axis",
"KeyC": "Y-Axis",
"KeyR": "Repair",
}
// operationTextFlagsに含まれるものがkeyDownFlagsに含まれるばあい、そのキーの文字列を取得
let activeOperations = Object.keys(operationTextFlags).filter(key => keyDownFlags[key]);
if (activeOperations.length > 0) {
// 左上に表示
ctx.font = '20px serif';
ctx.fillStyle = 'rgb(255,255,255)';
ctx.fillText(operationTextFlags[activeOperations[0]], 10, 30);
}
}
function Redraw() {201 unmodified linesfunction ModifyDragRange(delta) { dragRange = Math.max(dragRangeDelta, Math.min(512, dragRange + delta)); }
document.addEventListener('wheel', function(event) {
event.preventDefault();
const deltaY = event.deltaY;
if (deltaY < 0) {ModifyDragRange(-dragRangeDelta);}
if (0 < deltaY) {ModifyDragRange(dragRangeDelta);}
lastWheeling = new Date().getTime();
Redraw();
window.setTimeout(function() { Redraw(); }, 100);
}, {passive: true});
window.setTimeout(function() { Redraw(); }, wheelDisplayTime+10);
}, {passive: false});
document.addEventListener("keydown", (event) => {
if (event.code == "BracketLeft") { ModifyDragRange(-dragRangeDelta); }
if (event.code == "BracketRight") { ModifyDragRange(dragRangeDelta); }
keyDownFlags[event.code] = true;
Redraw();
event.preventDefault();
});
document.addEventListener("keyup", (event) => {
keyDownFlags[event.code] = false;
if (event.code == "KeyA") {
if (event.ctrlKey && event.code == "KeyN") {
addPerson();
}
if (event.ctrlKey && event.code == "KeyZ") {4 unmodified lines }
}
Redraw();
event.preventDefault();
});
function initializeEditor() {app.py+17-12
static/poseEditor.js+32-4