处理:与UnHex的混淆,有没有更简单的方法?

Processing: Confusion with UnHex, is there an easier way?

进行 uni 赋值,需要导入 table 数据并将数字转换为十六进制数。 我尝试使用 unHex() 但它在转换字符串时变得非常混乱。 有没有更简单的方法来转换它们?

这是table数据的截图:

Table table;

void setup() {
  size(200, 200);
 background(255);
  table = loadTable("msfw15.csv", "header");



}

void draw() {
  //Getting tags, probably an easier way.
  String work = table.getString(0, 1);
  String fashion = table.getString(1, 1);
  String blogger = table.getString(2, 1);
  String girlsnight = table.getString(3, 1);
  String backstage = table.getString(4, 1);
  String ootd = table.getString(5, 1);
  String melbourne = table.getString(6, 1);
  String sydney = table.getString(7, 1);
  String emergingdesigner = table.getString(8, 1);
  String fashiongram = table.getString(9, 1);
  String foodblogger = table.getString(10, 1);
  String hiphop = table.getString(11, 1);
  String muji = table.getString(12, 1);
  String monochrome = table.getString(13, 1);
  String swag = table.getString(14, 1);
  String alannahhill = table.getString(15, 1);
  String popsofcolour = table.getString(16, 1);
  String stylesketch = table.getString(17, 1);
  String artist = table.getString(18, 1);
  String designer = table.getString(19, 1);
  String model = table.getString(20, 1);
  String vogue = table.getString(21, 1);
  String knitwear = table.getString(22, 1);
  String knitting = table.getString(23, 1);

  color workd = unhex("FF" + work);
  fill(workd);
  noStroke();
  rect(50, 50, 100, 100);

}

首先,我认为您确实需要了解 for 循环。完成 table 应该只需要几行代码。 Here 是对 for 循环引用的 link。

接下来,我建议您查看 the unhex() reference:

String hs = "FF006699";
int hi = unhex(hs);
fill(hi);
rect(30, 20, 55, 55);

除此之外,您需要更具体地说明您到底对什么感到困惑。 unhex() 函数没有按您预期的方式运行怎么办?