SHARE
TWEET

Untitled

a guest Sep 23rd, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int brushSize;
  2. float red;
  3. float g;
  4. float b;
  5. float q;
  6. float w;
  7. float e;
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14. void setup(){
  15.   size(1000, 1000);
  16.   background(255);
  17.   brushSize = 10;
  18.   red = 0;
  19.   g = 255;
  20.   b = 100;
  21.  
  22.  
  23.  
  24.  
  25.  
  26. }
  27.  
  28. void draw(){
  29.  
  30.   q = random(0,255);
  31.   w = random(50,2);
  32.   e = random(10,220);
  33.  
  34.   fill(255,0,0);
  35.   textSize(20);
  36.   text("Press R to gradually change color to Red",50,50);
  37.  
  38.   fill(0,255,0);
  39.   textSize(20);
  40.   text("Press G to gradually change color to Green",50,100);
  41.  
  42.   fill(0,0,255);
  43.   textSize(20);
  44.   text("Press B to gradually change color to Blue",50,150);
  45.  
  46.   fill(q,w,e);
  47.   textSize(20);
  48.   text("Press F to change color to Random Colors",50,200);
  49.  
  50.   fill(0,255,100);
  51.   textSize(20);
  52.   text("Press O to change color to Original Color",50,250);
  53.  
  54.   fill(255, 2);
  55.   rect(0, 0, width, height);
  56.  
  57.  
  58.  
  59.  
  60.   if(mousePressed){
  61.  
  62.     switch(key){     // similar to IF statments, but are in constant loop check for IFs
  63.     case 'r':
  64.     red+=5; b-=5; g-=5;
  65.     break;
  66.    
  67.     case 'g':
  68.     red -=5; b-=5; g +=5;
  69.     break;
  70.    
  71.     case 'b':
  72.     red-=5; b+=5; g-=5;
  73.     break;
  74.    
  75.      case 'f':
  76.     red = random(0,255); g = random(0,255); b = random(0,255);
  77.     break;
  78.    
  79.     case 'o':
  80.     red = 0; g=255; b=100;
  81.     break;
  82.     }
  83.    
  84.    
  85.     fill(red, g, b);
  86.     noStroke();
  87.     ellipse(mouseX, mouseY, brushSize, brushSize);
  88.    
  89.     if(red<0) red=0;
  90.     if(red>255) red=255;
  91.     if(g<0) g=0;
  92.     if(g>255) g=255;
  93.     if(b<0) b=0;
  94.     if(b>255) b=255;
  95.  
  96. }
  97.    
  98.  
  99.  
  100.  
  101.   //if(keyPressed){
  102.   //  brushSize += 10;
  103.   //}
  104. }
  105.  
  106. void keyPressed(){
  107.   if(key == CODED){
  108.     if(keyCode == UP && brushSize <= 500){
  109.       brushSize += 10;
  110.     }else if(keyCode == DOWN && brushSize >10){
  111.       brushSize -= 10;
  112.     }
  113.   }    
  114.    
  115.  
  116.  
  117.  
  118.  
  119.  
  120.    
  121.    
  122.  
  123. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top