【问题标题】:processingjs red() green() blue()processingjs 红色()绿色()蓝色()
【发布时间】:2012-01-03 17:25:53
【问题描述】:

我想发送一个从处理 js 到 javascript 的字符串,其中包含要在 css 中使用的颜色。 格式如下: “RGB(255, 0, 0)” (或任何颜色值)。

无论我尝试什么,我都会收到此错误:

未捕获的类型错误:数字不是函数

我做了几个测试,它总是红色(....导致错误(可能是绿色和蓝色)。

String getRowColor(int r) {
  if (r > rows || r < 0) {
    return null;
  } 
  else {
    color c= colors[r];
    String cStr = "rgb(";
    cStr += red(c)+", ";
    cStr += green(c)+", ";
    cStr += blue(c)+")";
    return cStr;
  }
}

【问题讨论】:

  • 您的问题是“Javascript”,但您已将此标记为“Java”。是哪个?
  • 如果是java,使用StringBuffer进行连接。
  • 有红色(c)、绿色(c)、蓝色(c)的函数吗?
  • 我对 processing.js 不是很熟悉,但你可以试试cStr = join(cStr,str(red(c)),", ");
  • 哎呀,它是 javascript。大多数时候我使用java,我的错误。其余的 processingjs 作为处理都具有 red(c) 等功能。

标签: javascript processing.js


【解决方案1】:

我认为: color c= colors[r]; 应该是:color c= color(r);

【讨论】:

  • 其余代码暗示colorsColor的数组
猜你喜欢
  • 2013-12-19
  • 2014-08-26
  • 2011-10-28
  • 1970-01-01
  • 1970-01-01
  • 2020-06-10
  • 2016-01-01
  • 1970-01-01
  • 2011-09-22
相关资源
最近更新 更多