Guest User

Untitled

a guest
Oct 17th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. int r = 10;
  2. int g = 10;
  3. int b = 10;
  4.  
  5. void setup()
  6. {
  7. size(850,1100);
  8. background(255);
  9. }
  10.  
  11. void draw() {
  12.  
  13. fill(r,g,b);
  14. noStroke();
  15. rect(0,0,100,12);
  16. fill(255);
  17. text((r + "," + g + "," + b),10,10);
  18.  
  19. if(key == 'r')
  20. {
  21. r++;
  22. }
  23.  
  24. //FIGURE 8-3:
  25. //The RGB color setting for
  26. //your pen. Use the R, G,
  27. //and B keys to change the
  28. //color.
  29. //142 • PROJECT 8
  30. key = ' ';
  31. if(r > 255)
  32. {
  33. r = 0;
  34. }
  35.  
  36. else if(key == 'g')
  37. {
  38. g++;
  39. key = ' ';
  40. if(g > 255)
  41. {
  42. g = 0;
  43. }
  44. }
  45.  
  46. else if(key == 'b')
  47. {
  48. b++;
  49. key = ' ';
  50. if(b > 255)
  51. {
  52. b = 0;
  53. }
  54. }
  55. }
  56. void mouseDragged()
  57. {
  58. if(mouseButton == LEFT)
  59. {
  60. strokeWeight(50);
  61. stroke(r,g,b);
  62. line(pmouseX,pmouseY,mouseX,mouseY);
  63. }
  64. }
Add Comment
Please, Sign In to add comment