所以我正在创建一个计时器,到目前为止它完成它所需要的,在两次点击OK之间显示正确的时间,但现在我想将输出颜色更改为绿色,如果它低于0.5秒,我已经尝试下面这样做,但颜色不会改变任何解决方案将有所帮助。
额外:我还想让Else IF声明0.5-1秒为橙色,任何超过1秒的声明为红色。任何指导都会很棒
var canvas;
canvas = openGraphics();
alert("Press \"OK\" to start the timer.");
var starttime = Date.now();
alert("Press \"OK\" to stop the timer.");
var stoptime = Date.now();
var seconds_between = (stoptime - starttime) / 1000;
alert(seconds_between + " seconds");
var phrase1;
phrase1 = " seconds.";
var message;
message = seconds_between + phrase1;
if (seconds_between < 0 || seconds_between > 0.50) {
message.fontcolor("green");
}
canvas.drawString(message, 10, 10);
canvas.paint();
答案 0 :(得分:1)
if (seconds_between < 0 || seconds_between > 0.50) {
message.fontcolor("green");
}
需要
if (seconds_between > 0 || seconds_between < 0.50) {
message.fontcolor("green");
}