码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-07-27 21:53:49      阅读:197      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!