我正在努力学习Rust,并且我开始考虑chars是4字节宽.我可以将a转换char为a u32并且它可以工作(它们都是4字节宽),但是,当我从a转换u32为a时char,Rust抱怨:
fn main() {
let pizza_hex: u32 = 0x1f355;
let pizza: char = ''; // (pizza char: http://www.fileformat.info/info/unicode/char/1f355/index.htm)
// pizza as hex = 1f355
println!("pizza as hex = {:x}", pizza as u32);
// size of pizza = 4
println!("size of pizza = {}", std::mem::size_of_val(&pizza));
// This doesn't work super well
println!("{} == {}", pizza_hex as char, pizza);
}
Run Code Online (Sandbox Code Playgroud)
error[E0604]: only `u8` can be cast as `char`, not `u32`
--> src/main.rs:12:26 …Run Code Online (Sandbox Code Playgroud) 我注意到这CanvasRenderingContext2D.createLinearGradient是 CanvasRenderingContext2D 的原型。
这意味着鼓励人们在想要绘制的上下文中创建渐变(以及一些其他资源)。
但是,我可以在画布上创建资源并在另一个画布上使用它:
const ctx1 = document.getElementById('canv1').getContext('2d');
const ctx2 = document.getElementById('canv2').getContext('2d');
const grad = ctx1.createLinearGradient(0, 0, 100, 100);
grad.addColorStop(0, 'white');
grad.addColorStop(1, 'black');
ctx2.fillStyle = grad;
ctx2.fillRect(0, 0, 100, 100);
Run Code Online (Sandbox Code Playgroud)
除了幕后的资源生命周期管理之外,还有其他原因吗?
谢谢!
我已经到了几乎放弃尝试使用PlayN的地步.我试过PlayN的入门指南这里,以及GamesFromScratch的更新的指南在这里,没有运气.每次我尝试使用code.googlecode.playn 1.3.1原型创建一个New-> Other - >"Maven Project"时,我收到以下错误消息:
'创建playn-archetype'遇到了问题
无法从原型创建项目[com.googlecode.playn:playn-archetype:1.3.1]已定义的工件不是原型
我想知道我做错了什么?我已经读过Eclipse附带Maven版本3.0.2(我正在使用Eclipse Juno),所以我安装了Maven 3.0.4,虽然我不知道如何升级Eclipse的版本(或者它有什么不同).
非常感谢您的时间,
我有兴趣查看是否可以将功能绑定到用户按下/释放键盘上的键。
到目前为止,我已经能够使用keypress模块和 process.stdin原始模式获取按键事件:
var keypress = require('keypress');
keypress(process.stdin);
process.stdin.on('keypress', function(ch, key) {
console.log('got "keypress"', key);
if (key && key.ctrl && key.name == 'c') {
process.exit();
}
});
process.stdin.setRawMode(true);
process.stdin.resume();
Run Code Online (Sandbox Code Playgroud)
甚至可以在终端中捕获键盘按下和释放事件吗?
值得注意的是,我对任何浏览器实现都不感兴趣;我正在寻找在终端中在 NodeJS 中运行的东西。
谢谢,所有。
我想知道是否有可能告诉 Visual Studio 打印外部构建工具的输出。
我有一个从我的文件中调用的外部构建工具 ( JSIL ),.csproj如下所示:
...
<Target Name="AfterBuild" Condition="$(JSIL) != 'building'">
<Exec Command="JSILc.exe $(SolutionPath)" />
</Target>
...
Run Code Online (Sandbox Code Playgroud)
这工作正常 - 输出进入 Visual Studio 输出窗口。但是,Visual Studio 似乎会缓冲命令的输出,直到它退出,然后一次性完整地打印该输出。
由于 JSIL 编译器需要相对较长的时间并且有相当多的输出,我希望输出窗口在构建时反映这一点。
JSIL 通过打印到stdout或来输出命令stderr,但手动.Flush()输入这些流似乎不会影响输出窗口。是否需要调用一些特殊的 API 来更新有关自定义构建工具进度的 Visual Studio?
谢谢!