我有以下检查,看看是否应该将元素视为"悬停".
我很困惑,因为我看到元素设置为state === 'hover'不应该的时候.
该alert消息更令人困惑,因为它告诉刚刚评估为true的表达式是不应该的表达式(如果您在逻辑上考虑它).
if( (ig.gui.cursor.pos.x >= element.pos.x)
&& (ig.gui.cursor.pos.x <= element.pos.x + element.size.x)
&& (ig.gui.cursor.pos.y >= element.pos.y)
&& (ig.gui.cursor.pos.y <= element.pos.y + element.size.y)
&& !element.disabled ) {
state = 'hover';
alert(
'This statement evaluates to true: '
+ ig.gui.cursor.pos.x
+ '>='
+ element.pos.x
+ '&&'
+ ig.gui.cursor.pos.x
+ '<='
+ element.pos.x
+ '+'
+ element.size.x
+ '&&'
+ ig.gui.cursor.pos.y
+ '>='
+ element.pos.y
+ '&&'
+ ig.gui.cursor.pos.y
+ '<='
+ element.pos.y
+ '+'
+ …Run Code Online (Sandbox Code Playgroud) 根据https://docs.ipfs.io/guides/concepts/pinning/,运行命令ipfs add hello.txt显然“固定”了文件“hello.txt”,但是为什么我在运行命令时没有看到后面列出的文件ipfs files ls? 它只列出我使用 IPFS 桌面应用程序添加的文件。为什么“hello.txt”现在不在列表中?
此外,我通过运行命令找到了一个所谓的“固定”对象列表ipfs pin ls,但是显示在那里的 CID 都没有对应于“hello.txt”,甚至没有任何前面提到的使用 IPFS 桌面添加的文件应用程序。
如何实际管理固定文件?
我写了一个脚本,它采用像这样的图像(通常黑色是alpha):

...并添加您喜欢的任何颜色的边框:

然而,它不是很快.创建边框图层需要大约130毫秒作为这种小字体的画布.更大的字体需要更长的时间!
逻辑很简单:
/* This is more or less psuedo-code. */
// Blank image data where I will put the border.
var newData = newContext.getImageData(0, 0, canvas.width, canvas.height);
// The image I will be analyzing.
var oldData = oldContext.getImageData(0, 0, this.data.width, this.data.height);
// Loop through every pixel in oldData and remember where non-alpha pixels are.
var fontPixels = this._getNonAlphaPixels(oldData);
// Loop through relevant pixels, remember neighboring pixels, and add border.
for (var px in fontPixels) {
for …Run Code Online (Sandbox Code Playgroud) 我想在我的控制台中看到"得到回复"或"得到错误".
我一直在尝试使用http.get()执行HTTP请求,但是当我尝试时出现以下错误.
D:\wamp\www\Chat\server\test.js:19
http.get("http://google.com", function(res) {
^
TypeError: Object #<Server> has no method 'get'
at Object.<anonymous> (D:\wamp\www\Chat\server\test.js:19:6)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
Run Code Online (Sandbox Code Playgroud)
这是test.js的全部内容:
var http = require('http').createServer(handler);
var fs = require('fs');
http.listen(9090);
function handler(req, res) {
fs.readFile(__dirname + '/index.html', function(err, data) {
if (err) {
res.writeHead(500);
return res.end('Error loading index.html');
}
res.writeHead(200);
res.end(data);
});
}
http.get("http://google.com", function(res) {
console.log("Got response: " + res.statusCode);
}).on('error', function(e) …Run Code Online (Sandbox Code Playgroud) javascript ×3
canvas ×1
evaluation ×1
expression ×1
http ×1
http-request ×1
ipfs ×1
logic ×1
node.js ×1