我想知道是否有在线或可下载的程序允许您设置所需的窗口大小,绘制线条以绘制图形,然后它打印原点(x,y)值和结束(x,y)值所有画线。这真的会加快我对Tkinter的线条画,因为我不必继续尝试和错误来让我的线条匹配并加入。如果没有这样的程序,是否有任何方法可以比(x,y)试验和错误更快地在画布上绘图。谢谢:)
答案 0 :(得分:1)
我给你做了一些事情:)
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<meta charset="utf-8">
<title>Example</title>
<style>
body {
height: 3000px;
}
.dot {
width: 2px;
height: 2px;
background-color: black;
position: absolute;
}
</style>
</head>
<body>
<div>Click mouse to start then click again to pause or click clear</div>
<button id="clear">Mouse over to clear</button>
<textarea id="results"></textarea>
<script>
(function() {
"use strict";
var draw = false;
function clear() {
$(".dot").remove();
$("#results").html("");
}
function stop() {
draw = false;
}
function start() {
draw = true;
}
$("#clear").mouseover(clear);
document.onmousedown = start;
document.onmouseup = stop;
document.onmousemove = handleMouseMove;
function handleMouseMove(event) {
if (draw == false) return;
var dot, eventDoc, doc, body, pageX, pageY;
event = event || window.event; // IE-ism
// If pageX/Y aren't available and clientX/Y
// are, calculate pageX/Y - logic taken from jQuery
// Calculate pageX/Y if missing and clientX/Y available
if (event.pageX == null && event.clientX != null) {
eventDoc = (event.target && event.target.ownerDocument) || document;
doc = eventDoc.documentElement;
body = eventDoc.body;
event.pageX = event.clientX +
(doc && doc.scrollLeft || body && body.scrollLeft || 0) -
(doc && doc.clientLeft || body && body.clientLeft || 0);
event.pageY = event.clientY +
(doc && doc.scrollTop || body && body.scrollTop || 0) -
(doc && doc.clientTop || body && body.clientTop || 0);
}
// Add a dot to follow the cursor
dot = document.createElement('div');
dot.className = "dot";
dot.style.left = event.pageX + "px";
dot.style.top = event.pageY + "px";
dot.style.position = "absolute";
document.body.appendChild(dot);
var result = event.pageX + "," + event.pageY + "\n";
$("#results").append(result);
}
})();
</script>
</body>
</html>
&#13;
只需单击鼠标并在输出上绘图,然后就可以复制文本框输出。