Guest User

Untitled

a guest
Apr 4th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. canali c;
  2. int w = 320;
  3. int l = 240;
  4. int counter_r = 0;
  5. int counter_v = 0;
  6. int counter_b = 0;
  7. int ris = 0;
  8.  
  9. void setup()
  10. {
  11. size(w, l);
  12. smooth();
  13. stroke(255);
  14. frameRate(10000);
  15. c = new canali(255,255,255);
  16. background(0);
  17. fill(255,255,255);
  18. rect(0,0,310,240);
  19. }
  20.  
  21. void draw()
  22. {
  23. checksfondo();
  24. }
  25.  
  26. void checksfondo()
  27. {
  28. c.getcolor();
  29. ris = ((w*l)*70)/100;
  30. while (c.totcolori > ris)
  31. {
  32. fill(0,0,0);
  33. rect(10,10,20,20);
  34. }
  35. }
  36.  
  37. public class canali
  38. {
  39. public float rosso;
  40. public float verde;
  41. public float blu;
  42. public float totcolori;
  43.  
  44. canali(int r,int v,int b)
  45. {
  46. rosso = r;
  47. verde = v;
  48. blu = b;
  49. }
  50. void getcolor()
  51. {
  52. for (int x=0;x<w;x++)
  53. {
  54. for (int y=0;y<l;y++)
  55. {
  56. color grab = get(x,y);
  57. rosso = red(grab);
  58. verde = green(grab);
  59. blu = blue(grab);
  60. if (rosso > 200)
  61. {
  62. counter_r++;
  63. }
  64. if (verde > 200)
  65. {
  66. counter_v++;
  67. }
  68. if (blu > 200)
  69. {
  70. counter_b++;
  71. }
  72. totcolori = counter_r+counter_v+counter_b;
  73. }
  74. }
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment