首页 > 其他 > 详细

如何在Processing中用鼠标获取RGB颜色数值

时间:2014-07-27 21:53:49      阅读:514      评论:0      收藏:0      [点我收藏+]

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

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最后面,运行后在画布中单击鼠标就能获取当前像素的颜色值。

 

如何在Processing中用鼠标获取RGB颜色数值

原文:http://www.cnblogs.com/x5115x/p/3871235.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!