要做一个抠图应用,所以随手做了个鼠标取色,代码如下:

1 void mousePressed(){
2   int imgC = get(mouseX,mouseY);
3   int R = (imgC >> 16) & 0xFF;
4   int G = (imgC >> 8) & 0xFF;
5   int B = imgC & 0xFF;
6   println("Current position color: Red = "+R+", Green = "+G+", Blue = "+B);
7 }

放到sketch最后面,运行后在画布中单击鼠标就能获取当前像素的颜色值。

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-09-29
  • 2022-02-04
  • 2022-12-23
  • 2021-04-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-04
  • 2021-06-09
  • 2021-12-28
  • 2022-12-23
  • 2021-12-29
相关资源
相似解决方案