Advertisement
if-then-else

Untitled

Jan 28th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.51 KB | None | 0 0
  1. public class Mycelium extends PApplet{
  2.     PImage img;
  3.    
  4.     public static void main(String[] args) {
  5.         PApplet.main("Mycelium");
  6.  
  7.     }
  8.    
  9.     public void settings(){
  10.         size(400,400);
  11.     }
  12.    
  13.     public void setup(){
  14.         img = loadImage("picture.png");
  15.         loadPixels();
  16.         //image(img,0,0);
  17.         background(0);
  18.         fill(255);
  19.         getMaxBrightness((int)random(img.width), (int)random(img.height));
  20. //      int bright =
  21. //      for (int i = 0; i < img.height; i++) {
  22. //          for (int j = 0; j < img.width; j++) { // image is an array of pixels, randomly selects pixels to look at, less precise when smaller size (larger zoom) for better fps
  23. //              int pxlen = (i + img.width * j);// 2D array using 1D array of image
  24. //              if()
  25. //          }
  26. //      }
  27.     }
  28.    
  29.     public void draw(){
  30.        
  31.     }
  32.  
  33.     /*public void myc(float x, float y){
  34.         if(x < img.width && x > 0 && y > 0 && y<img.height){
  35.             int pxlen = (x + img.width * y);
  36.             if(red(img.pixels[pixlen+1])>red(im))
  37.         }
  38.     }*/
  39.     public void getMaxBrightness(int a, int b){
  40.         //loadPixels();
  41.         if(a > 1 && a < img.width-1 && b > 1 && b < img.height-1){
  42.         int max = 0;
  43.         /*for (int x = a - 1; x <= a + 1; x++) {
  44.             for (int y = b-1; y <= b+1; y++ ) {
  45.                 int pxlen = (x + img.width * y);
  46.                 if(red(img.pixels[pxlen])> max){
  47.                     max=img.pixels[pxlen];
  48.                 }
  49.             }
  50.          }*/
  51.         for (int x = a - 1; x <= a + 1; x++) {
  52.             for (int y = b-1; y <= b+1; y++ ) {
  53.                 int pxlen = (x + img.width * y);
  54.                 if(red(img.pixels[pxlen]) >= max){
  55.                     ellipse(x,y,5,5);
  56.                     getMaxBrightness(x,y);
  57.                 }
  58.             }
  59.          }
  60.         }
  61.     }  
  62.  
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement