Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. int brushSize;
  2. color brushColor = color(0, 0, 0);
  3.  
  4. void setup() {
  5. size(1000, 1000);
  6. background(255);
  7. brushSize = 10;
  8. }
  9.  
  10. void draw() {
  11. fill(255, 2);
  12. rect(0, 0, width, height);
  13. showText();
  14. showColorChoice();
  15. if (mousePressed && mouseY>=width/7+50) {
  16. fill(brushColor);
  17. noStroke();
  18. ellipse(mouseX, mouseY, brushSize, brushSize);
  19. }
  20. if (keyPressed) {
  21. }
  22. changeColor();
  23. }
  24.  
  25. void keyPressed() {
  26. if (key == CODED) {
  27. if (keyCode == UP && brushSize <= 500) {
  28. brushSize += 10;
  29. } else if (keyCode == DOWN && brushSize >10) {
  30. brushSize -= 10;
  31. }
  32. }
  33. }
  34.  
  35. void showText() {
  36. textSize(32);
  37. textAlign(CENTER);
  38. fill(0);
  39. text("Choose your color", width/2, 35);
  40. }
  41.  
  42. void showColorChoice() {
  43. noStroke();
  44. fill(#D31717);
  45. rect(0, 50, width/7, width/7);
  46. fill(#FF9305);
  47. rect(width/7, 50, width/7, width/7);
  48. fill(#F7F716);
  49. rect(width/7*2, 50, width/7, width/7);
  50. fill(#2DD322);
  51. rect(width/7*3, 50, width/7, width/7);
  52. fill(#2FF0F5);
  53. rect(width/7*4, 50, width/7, width/7);
  54. fill(#0549FF);
  55. rect(width/7*5, 50, width/7, width/7);
  56. fill(#6C05FF);
  57. rect(width/7*6, 50, width/7, width/7);
  58. }
  59.  
  60. void changeColor(){
  61. if(mousePressed && mouseX<width/7 && mouseY>50 && mouseY<50+width/7){
  62. brushColor=color(#D31717);
  63. }
  64. if(mousePressed && mouseX>width/7 && mouseX<width/7*2 && mouseY>50 && mouseY<50+width/7){
  65. brushColor=color(#FF9305);
  66. }
  67. if(mousePressed && mouseX>width/7*2 && mouseX<width/7*3 && mouseY>50 && mouseY<50+width/7){
  68. brushColor=color(#F7F716);
  69. }
  70. if(mousePressed && mouseX>width/7*3 && mouseX<width/7*4 && mouseY>50 && mouseY<50+width/7){
  71. brushColor=color(#2DD322);
  72. }
  73. if(mousePressed && mouseX>width/7*4 && mouseX<width/7*5 && mouseY>50 && mouseY<50+width/7){
  74. brushColor=color(#2FF0F5);
  75. }
  76. if(mousePressed && mouseX>width/7*5 && mouseX<width/7*6 && mouseY>50 && mouseY<50+width/7){
  77. brushColor=color(#0549FF);
  78. }
  79. if(mousePressed && mouseX>width/7*6 && mouseY>50 && mouseY<50+width/7){
  80. brushColor=color(#6C05FF);
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement