我拥有的。
我想要实现的目标:
所以这是我的问题:
如何将三个js中的位置x和y转换为浏览器坐标,以便我可以将文本正确定位在行的中心?我只添加了垂直线的示例,我将有不同的线,例如水平线和对角线。
如何剪切中心的箭头线以便为文本留出空间?
这是我的代码
var gridCanvas = document.getElementById('gridcanvas');
var ctx = gridCanvas.getContext('2d');
ctx.beginPath();
for(var x=0.5; x<gridCanvas.width; x+=20) {
ctx.moveTo(x, 0);
ctx.lineTo(x, gridCanvas.height);
}
for(var y=0.5; y<gridCanvas.height; y+=20) {
ctx.moveTo(0, y);
ctx.lineTo(gridCanvas.width, y);
}
ctx.strokeStyle = 'lightgrey';
ctx.stroke();
var container = document.getElementById( '3dcontainer' );
var aspect = 400 / 400;
var viewHeight = 400;
var viewWidth = viewHeight * aspect;
var scene = new THREE.Scene();
var camera = new THREE.OrthographicCamera(
viewWidth / - 2, viewWidth / 2, viewHeight / …Run Code Online (Sandbox Code Playgroud)您好,我正在尝试使用 bash 创建日志,但我得到的时间是错误的。我在后台运行这个。
# log code here before executing curl script log "Yay I was started"
curl https://example.com/process | sed "s/^/$(date -u) /" >> /path/to/logs.log &
Run Code Online (Sandbox Code Playgroud)
处理curl后设置的时间是执行它的时间,而不是我得到响应后的时间。我需要得到回复后的时间。
这是示例输出(错误响应)
Fri Aug 21 01:43:12 UTC 2020 Yay I was started
Fri Aug 21 01:43:12 UTC 2020 Yay I was the response returned by the url
Run Code Online (Sandbox Code Playgroud)
这里的 urlhttps://example.com/process会休眠 2 秒,但正如您所看到的,时间与执行时和执行后我们收到响应的时间相同。
正确反应
Fri Aug 21 01:43:12 UTC 2020 Yay I was started
Fri Aug 21 01:43:14 UTC 2020 Yay I was the …Run Code Online (Sandbox Code Playgroud)