Processing 入门教程(二十九) get() 得到图像像素点颜色

void setup() {
  size(500, 400);
  
  for(int x = 0; x < width; x++) {
    for(int y = 0; y < 120; y++) {
      float r = map(noise(x / 80.0, y / 80.0, 10.0), 0, 1, 0, 255);
      float g = map(noise(x / 80.0, y / 80.0, 20.0), 0, 1, 0, 255);
      float b = map(noise(x / 80.0, y / 80.0, 30.0), 0, 1, 0, 255);
      stroke(r, g, b);
      point(x, y);
    }
  }
}

void draw() {
  color color_under_mouse = get(mouseX, mouseY);
  fill(color_under_mouse);
  rect(0, 120, width, 280);
}



效果图如下:得到鼠标位置的坐标点的颜色赋值给下面那个的矩形

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值